Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望你能帮助解决我的问题;) 我正在使用谷歌地图 api 和 jquery 从 xml 文件动态加载标记。一切都按我的预期工作,除了一件事。当我加载第二组标记时,地图会失去缩放级别。这是我的示例尝试单击地图下的按钮,然后尝试单击第二个按钮。你会明白我的意思。这是我的js 代码。谢谢!
我认为,问题在于MYMAP.bounds.extend(point);,因为您只在边界上添加新点。
MYMAP.bounds.extend(point);
要从您的函数 MYMAP.placeMarkers() 开始,您必须清除界限。 MYMAP.bounds = new GLatLngBounds();
MYMAP.bounds = new GLatLngBounds();
正确的是
MYMAP.bounds = new google.maps.LatLngBounds();