我从谷歌得到这个修改后的示例代码
var stockholm = new google.maps.LatLng(59.32522, 18.07002);
var parliament = new google.maps.LatLng(59.327383, 18.06747);
var marker;
var map;
function initialize() {
var mapOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: stockholm
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
marker = new google.maps.Marker({
map:map,
draggable:true,
animation: google.maps.Animation.DROP,
position: parliament,
icon: '/img/marker.png'
});
google.maps.event.addListener(marker, 'click', toggleBounce);
setTimeout(function() { marker.setAnimation(google.maps.Animation.BOUNCE); }, 2000);
}
function toggleBounce() {
if (marker.getAnimation() != null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
我想知道在 DROP 动画停止后是否可以将标记动画从 DROP 更改为 BOUNCE?
我设法使用 setTimeout() 函数对其进行了更改,但它做得并不顺利。任何帮助将不胜感激。