弹跳针在谷歌地图一旦 [英] Bounce a pin in google maps once

查看:244
本文介绍了弹跳针在谷歌地图一旦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在谷歌地图上反弹针一次。下面code将使标记反弹,但它只是不断去...

I want to bounce a pin on a google map once. The following code will make the marker bounce but it just keeps going...

myPin.setAnimation(google.maps.Animation.BOUNCE);

然后调用

myPin.setAnimation(null);

使得动画停止。设置超时工作,但反弹的持续时间并不像它是一个圆形的号码,这样

makes the animation stop. Setting a timeout works but the duration of a bounce doesn't look like it is a round number so doing this

  setTimeout(function(){ myPin.setAnimation(null); }, 1000);

请弹跳动画结束prematurely和看起来可怕。

Make the bounce animation end prematurely and look terrible.

有谁知道一个更好的方式来做到这一点?

Does anyone know of a better way to accomplish this?

推荐答案

的一种简单的方法位:
谷歌的反弹动画将采取正是750毫秒为一个周期。因此,只需将超时设置为750毫秒,动画将在第一个反弹的结束正好停下来。对我的作品在FF​​ 7,Chrome的14和IE 8:

Bit of a simple approach: Google's bounce animation appears to take exactly 750 ms for one cycle. Thus, simply set the timeout to 750 ms and the animation will stop exactly at the end of the first bounce. Works for me on FF 7, Chrome 14 and IE 8:

    marker.setAnimation(google.maps.Animation.BOUNCE);
    setTimeout(function(){ marker.setAnimation(null); }, 750);

这篇关于弹跳针在谷歌地图一旦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆