【问题标题】:Dynamically add markers on changed map - Google Maps API在更改的地图上动态添加标记 - Google Maps API
【发布时间】:2013-05-21 09:00:22
【问题描述】:

我有一张谷歌地图,上面标有零售店的位置。

效果很好。

如果用户通过拖放更改地图焦点(更改地图提取) 如果在此地图中提取的是商店,我想动态添加新标记。

我不知道在哪里可以找到这样的例子或其他东西。

【问题讨论】:

标签: javascript google-maps


【解决方案1】:

首先,您需要加载第一批标记,然后监听 "bounds_changed" 事件。当该事件触发时,只需获取新坐标和缩放级别并相应地加载标记。

你可以在这里找到一个例子:https://developers.google.com/maps/documentation/javascript/events

google.maps.event.addListener(map, 'bounds_changed', function() {
    //Get the new location and zoom parameters
    //and print the new markers
});

【讨论】:

    猜你喜欢
    • 2010-12-28
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多