如果我单击某项向 map 添加 5 个标记,这些标记分布在 100 英里范围内,则标记会被添加,并且 map 会缩小以容纳所有标记。
如果我单击显示分布在(例如 2 英里)范围内的标记的某个内容...标记会正确消失,但 map 不会放大。
我使用的是2.1.1
这是我的 JavaScript 调用:
Gmaps.store.handler.removeMarkers(Gmaps.store.markers);
Gmaps.store.markers = Gmaps.store.handler.addMarkers(<%= raw @hash.to_json %>, {
draggable: false,
animation: google.maps.Animation.DROP
});
Gmaps.store.handler.bounds.extendWith(Gmaps.store.markers);
Gmaps.store.handler.fitMapToBounds();
我是不是漏接电话了?我以为 removeMarkers
现在清除了集群器?
最佳答案
您必须明确重置您的界限:
handler.resetBounds();
关于javascript - gmaps4rails v2 fitMapToBounds(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20526597/