Javascript 当我一个接一个地删除每个标记时,如何在Google Map V3标记上添加自定义动画?

Javascript 当我一个接一个地删除每个标记时,如何在Google Map V3标记上添加自定义动画?,javascript,android,jquery,google-maps,google-maps-api-3,Javascript,Android,Jquery,Google Maps,Google Maps Api 3,这是我在GoogleMapV3上逐个删除每个标记的简单工作示例。 我已经设置了将标记添加到Google地图时的放置动画 但是我想定制带有淡入淡出动画的拖放,是否可以使用任何Javascript材料或其他库 Google在名称空间中有这个选项我们可以在名称空间中添加自定义动画选项吗 google.maps.Animation.DROP google.maps.Animation.BOUNCE google.maps.Animation.CUSTOM_淡入淡出(可能吗?) 我的谷歌地图V3工作代

这是我在GoogleMapV3上逐个删除每个标记的简单工作示例。 我已经设置了将标记添加到Google地图时的放置动画

但是我想定制带有淡入淡出动画的拖放,是否可以使用任何Javascript材料或其他库

Google在名称空间中有这个选项我们可以在名称空间中添加自定义动画选项吗

  • google.maps.Animation.DROP
  • google.maps.Animation.BOUNCE
  • google.maps.Animation.CUSTOM_淡入淡出(可能吗?)
我的谷歌地图V3工作代码

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>
</head> 
<body>
  <div id="map" style="width: 500px; height: 400px;"></div>

  <script type="text/javascript">
    var locations = [
      ['Bondi Beach', -33.890542, 151.274856, 4],
      ['Coogee Beach', -33.923036, 151.259052, 5],
      ['Cronulla Beach', -34.028249, 151.157507, 3],
      ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
      ['Maroubra Beach', -33.950198, 151.259302, 1]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker, i;

    function marker(i) {
        if (i > locations.length) return;

        var marker;

        marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][1], locations[i][2]),
            animation: google.maps.Animation.DROP,
            map: map
            });

        var t=setTimeout("marker("+(i+1)+")",500);
    }
    marker(0);

  </script>
</body>
</html>

谷歌地图多个标记
变量位置=[
[Bondi Beach',-33.890542151.274856,4],
[Coogee Beach',-33.923036151.259052,5],
[Cronulla Beach',-34.028249151.157507,3],
[‘曼利海滩’,-33.80010128657071151.28747820854187,2],
[‘马鲁布拉海滩’,-33.950198151.259302,1]
];
var map=new google.maps.map(document.getElementById('map'){
缩放:10,
中心:新谷歌地图LatLng(-33.92151.25),
mapTypeId:google.maps.mapTypeId.ROADMAP
});
var infowindow=new google.maps.infowindow();
var标记,i;
功能标记(一){
如果(i>位置.长度)返回;
var标记;
marker=新的google.maps.marker({
位置:新的google.maps.LatLng(位置[i][1],位置[i][2]),
动画:google.maps.animation.DROP,
地图:地图
});
var t=setTimeout(“标记(“+(i+1)+”),500);
}
标记(0);

以下是我取得的成绩。 GoogleMapsAPI在页面的内部添加了一个CSS关键帧片段

在页面内部,它看起来像这样

@-webkit-keyframes _gm2657 {
0 % {
    -webkit-transform: translate3d(0px, 0px, 0); -webkit-animation-timing-function: ease-out;
}
50 % {
    -webkit-transform: translate3d(0px, -20px, 0); -webkit-animation-timing-function: ease-in ;
}
100 % {
    -webkit-transform: translate3d(0px, 0px, 0); -webkit-animation-timing-function: ease-out;
}
}

其中的函数被压缩为

function uJ(a, b) {
var c = [];
c[A]("@-webkit-keyframes ", b, " {\\n");
K(a.b, function (a) {
    c[A](100 * a[$k], "% { ");
    c[A]("-webkit-transform: translate3d(", a[Fv][0], "px,", a[Fv][1], "px,0); ");
    c[A]("-webkit-animation-timing-function: ", a.wa, "; ");
    c[A]("}\\n")
});
c[A]("}\\n");
return c[Mc]("")
}
我现在无法再深入研究这个问题来找出如何侵入那个物体

问题是我不知道他们是如何创建关键帧动画名称的。我从上面的文件中得到了
a.d=“_gm”+l[B](1E4*l[Qb]())
,但祝你好运,追踪到l[B]是什么,或者1E4*l等于什么,或者Qb是如何定义的

我的下一个方法是在HTML中搜索包含@-webkit keyframes\u gm的脚本标记,并查看如何提取使用的数字,然后用它来编写自己的关键帧动画,并希望google maps使用您注入的CSS而不是自己的CSS

根据这些思路,我编写了一个小jQuery方法来搜索样式属性部分匹配“\u gm”的所有div

var投票;
var ntrvl=设置间隔(函数(){
poll=$(“div[style*=''u gm']);
如果(poll.length>0){
craftNewAnimation(poll.css('-webkit animation name');
净距(ntrvl);
}
}, 10);
函数名为newanimation(名称){
console.log(名称);
var标记=['',
'@-webkit关键帧'+name+'{',
'0%{不透明度:0;}',
'100%{opacity:1;}',
'}',
“
var位置=[
[Surat',21.205386,72.847301,4],
[孟买,19.068789,72.870265,5]
];
var map=new google.maps.map(document.getElementById('map'){
缩放:7,
中心:新google.maps.LatLng(20.120783371.8517917),
mapTypeId:google.maps.mapTypeId.ROADMAP,
});
var infowindow=new google.maps.infowindow();
var标记,i;
对于(i=0;i
您可以使用它,它允许您使用html元素作为标记。现在您可以根据需要为元素提供css动画,例如使用

例如:

    var pictureLabel = document.createElement("img");
    pictureLabel.src = YOUR_SOURCE;
    pictureLabel.width = SOME_WIDTH;
    pictureLabel.height = SOME_HEIGHT;
    // daneden even got the exact animation your'e looking for :)
    pictureLabel.className = pictureLabel.className + " animated fadeInDown";

    var marker = new RichMarker({
    position: new google.maps.LatLng(YOUR_LAT, YOUR_LNG),
        map: YOUR_MAP,
        content: pictureLabel
    });

如果您使用Google的rich marker,请不要忘记

animation:function(marker){//做一些可能的事情?}animation:function()将不工作,因为它是常量值应该在那里。很好的努力,感谢我改变到动画:2它将有点闪烁我们可以做的顺利这里可能是一个更好的主意,使用另一个映射应用程序与更好的API,如Mapbox。我见过Mapbox它会提供所有的功能作为Gmap V3提供?如添加Dynemic具有不同图像的标记。标记动画在地图上添加圆形/多边形从圆形导航中查找值?StreetView我建议使用Mapbox是基于自定义插针放置的特定愿望。Mapbox API相当健壮。请看一看示例,并通过API查看它是否符合您的要求。老实说,我只是想fice自定义pin动画,或了解如何侵入Google Map API并获取神奇的css关键帧标识符。@CMN您的建议()用于Chrome浏览器。对于firefox和explorer,仅显示反弹效果。我们如何对firefox和explorer使用淡入淡出效果?-->
    var locations = [
      ['Surat', 21.205386, 72.847301, 4],
      ['Mumbai', 19.068789, 72.870265, 5]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 7,
      center: new google.maps.LatLng(20.120783, 71.8517917),
      mapTypeId: google.maps.MapTypeId.ROADMAP,

    });

    var infowindow = new google.maps.InfoWindow();

    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map,
        draggable:true,
        animation: google.maps.Animation.DROP,
        animation: google.maps.Animation.BOUNCE,    
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
        var bounds = new google.maps.LatLngBounds();
// in the marker-drawing loop:
bounds.extend(pos);
// after the loop:
map.fitBounds(bounds);
    var pictureLabel = document.createElement("img");
    pictureLabel.src = YOUR_SOURCE;
    pictureLabel.width = SOME_WIDTH;
    pictureLabel.height = SOME_HEIGHT;
    // daneden even got the exact animation your'e looking for :)
    pictureLabel.className = pictureLabel.className + " animated fadeInDown";

    var marker = new RichMarker({
    position: new google.maps.LatLng(YOUR_LAT, YOUR_LNG),
        map: YOUR_MAP,
        content: pictureLabel
    });