谷歌地图→fitBounds手动 [英] google maps → fitBounds manually

查看:121
本文介绍了谷歌地图→fitBounds手动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

$ p $ map $ fit $()(53.399999, 9.73215099999993),(53.717145,10.123491999999942));

解决方案

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

参考:


I am currently stuck with google maps v3. I try to add bounds manually in this way, but it doesn't work!?

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

解决方案

fitBounds expects an object of the type LatLngBounds, which in turn is initialized with two LatLng objects.

This should work:

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

map.fitBounds(bounds);

Reference:

这篇关于谷歌地图→fitBounds手动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆