我有以下代码,可以使点击的标记在谷歌地图上反弹。
但是,我不确定如何在 2 秒后停止动画。一定是我可以设置的某种定时器功能吗?
这是代码:
google.maps.event.addListener(marker, 'click', function()
{
map.setCenter(marker.getPosition());
map.setZoom(17);
if(marker.getAnimation() != null)
{
marker.setAnimation(null);
}
else
{
marker.setAnimation(google.maps.Animation.BOUNCE);
}
} );
任何建议都会很棒
google.maps.event.addListener(marker, 'click', function () {
map.setCenter(marker.getPosition());
map.setZoom(17);
if (marker.getAnimation() != null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
window.setTimeout(
function() {
marker.setAnimation(null);
},
2000
);
}
});