0
我有一个地图与标记动画集成在我的网页上。我在地图上有多个标记。我想实现类似的效果,当点击任何一个标记时,其他标记的动画应该停止,当前正在运行。带有多个标记的谷歌地图中的停止标记动画
目前我能够停止标记点击上相同标记的动画。在多个标记的情况下,我应该得到一些标记对象。
到目前为止,我已经做到了这一点。
latlngarray是一个具有对象格式的经度和纬度的数组。
var centerlatlng={center lat lng are here};
var zoomlevel=zoomlevel is here;
function initMap(){
map = new google.maps.Map(document.getElementById('map'),{
center: centerlatlng,
zoom: zoomlevel
});
if(latlngarray.length > 0){
for(i=0; i < latlngarray.length; i++){
marker = new google.maps.Marker({
position: latlngarray[i],
map: map
});
marker.addListener('click', function(){
toggleBounce(this);
map.setZoom(10);
map.setCenter(marker.getPosition());
});
}
}}
function toggleBounce(ele){
if(ele.getAnimation() !== null){
ele.setAnimation(null);
}else{
ele.setAnimation(google.maps.Animation.BOUNCE);
}}
使您的代码的的jsfiddle和分享链接 –
这里提琴链接 https://开头的jsfiddle .net/sandeeppujare/prqvfmbf/1/ –