Instantiate google map object with a defined set of bounds?
I want to c开发者_StackOverflow中文版reate google map using a pre-defined set of bounds.
So instead of the usual:
var map = new GMap2(document.getElementById('map'));
map.setCenter(new GLatLng(0,0),5);
I want to do something like:
var map = new GMap2(document.getElementById('map'));
map.setBounds(new GLatLng(10,10), new GLatLng(20,20));
Is this possible?
Yes, see below:
var map = new GMap2(document.getElementById('map'));
var bounds = new GLatLngBounds(new GLatLng(10,10), new GLatLng(20,20));
map.setCenter(bounds.getCenter());
map.setZoom(map.getBoundsZoomLevel(bounds));
精彩评论