【问题标题】:bouncing marker, not bouncing after zoom弹跳标记,缩放后不弹跳
【发布时间】:2014-06-01 06:39:35
【问题描述】:

我在使用谷歌地图时遇到了这个问题,我发了一个fiddle here。

marker = new google.maps.Marker({
        position: latlng, 
        map: map, 
        animation: google.maps.Animation.BOUNCE,
        title:"Hello World!"
    }),

如果我将地图拖到无法再看到标记的位置,然后放大(通常为 3 或 4 级),在我缩小可以看到标记的位置后,它不再弹跳,如果我点击它,它会再次弹跳。

这是浏览器问题吗?我在这里遇到什么问题?

【问题讨论】:

  • 奇怪。当地图足够缩小时,似乎会触发click 事件。见updated fiddle。当您放大并单击标记时,控制台日志中的事件处理程序会传递两条消息。
  • 你有没有看到标记仍然静止不动!
  • 是的。如果有人没有找到解释,则可能会被报告为问题。

标签: javascript google-maps google-maps-api-3 google-maps-markers


【解决方案1】:

我认为这是 Google Marker 动画的默认行为。由于您离开了地图范围,因此无需在幕后继续动画。

如果您真的想让标记在看到它时弹跳,您可以添加“bounds_changed”地图事件。每次缩放或拖动地图时,它应该检查您的标记是否在可见的地图区域内,如果是,则刷新反弹行为:

google.maps.event.addListener(map, 'bounds_changed', function(event) {

    if(map.getBounds().contains(marker.position)){

        marker.setAnimation(google.maps.Animation.BOUNCE);
    };
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2013-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多