google maps→fitBounds手动

Lup*_*upo 0 javascript google-maps google-maps-api-3

我目前卡在谷歌地图v3.我尝试以这种方式手动添加边界,但它不起作用!?

map.fitBounds((53.399999, 9.73215099999993), (53.717145, 10.123491999999942));

Pek*_*ica 5

fitBounds期望一个该类型的对象,该对象LatLngBounds又用两个LatLng对象初始化.

这应该工作:

sw = new LatLng(53.399999, 9.73215099999993);
ne = new LatLng(53.717145, 10.123491999999942);
bounds = new LatLngBounds(sw, ne)

map.fitBounds(bounds);
Run Code Online (Sandbox Code Playgroud)

参考: