开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜