Saturday, February 6, 2010

google map - auto adjust the zoom level

//init the zoom level 
map.setCenter(new GLatLng(0,0),0);  
bounds = new GLatLngBounds();


//update the boundary by the position of markers
for(var i = 0; i < points.length; i++)
{
 bounds.extend(new GLatLng(lat,lng));  //lat = result_.lat, lng = result_.lng    
}



//update the zoom level
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());

No comments:

Post a Comment