# How to calculate the zoom level if i have arrays of lattitude and longitude?

• ### Question

• Hi,

I need to calculate the zoom level dynamically so that all pushpins appear in the visibility of the map. I have arrays of latitude and longitude which can be treated as inputs to caluculate the zoom level dynamically.

If anyone has already written a method to achive this, please do share the same with me so that it can be helpful to me.

Monday, January 15, 2007 5:40 AM

• Its strangly named but it is called SetMapView() and takes an array of VELatLong so I think you are set.

John.

<script>
var map = null;

function GetMap()
{
map = new VEMap('myMap');

var pinid=0;
var locs = new Array;
var loc = new VELatLong(40, -123);
locs.push(loc);
var loc = new VELatLong(42, -122);
locs.push(loc);
var loc = new VELatLong(44, -118);
locs.push(loc);
var loc = new VELatLong(46, -118);
locs.push(loc);

for (i=0; i < locs.length; i++)
{
var pin = new VEPushpin(pinid, locs, null, 'A point', 'location number '+i);
pinid++;
}

DoBestMap(locs);
}
function DoBestMap(locs)
{
map.SetMapView(locs);
}
</script>

Monday, January 15, 2007 5:54 AM

### All replies

• Its strangly named but it is called SetMapView() and takes an array of VELatLong so I think you are set.

John.

<script>
var map = null;

function GetMap()
{
map = new VEMap('myMap');

var pinid=0;
var locs = new Array;
var loc = new VELatLong(40, -123);
locs.push(loc);
var loc = new VELatLong(42, -122);
locs.push(loc);
var loc = new VELatLong(44, -118);
locs.push(loc);
var loc = new VELatLong(46, -118);
locs.push(loc);

for (i=0; i < locs.length; i++)
{
var pin = new VEPushpin(pinid, locs, null, 'A point', 'location number '+i);
pinid++;
}

DoBestMap(locs);
}
function DoBestMap(locs)
{
map.SetMapView(locs);
}
</script>

Monday, January 15, 2007 5:54 AM
• Hi John,