谷歌地图JS API v3和循环gif动画的(Google Maps JS API v3 and l

2019-08-16 16:09发布

我似乎环GIF动画与谷歌地图API不能。 它可以播放动画的第一次左右,但不会以后再次播放。

任何人都可以点我在正确的方向? 我在这个文件中大量的代码,所以我已经拖出重要位,如果需要的话我会高兴地竖起一些。

var marker = new google.maps.MarkerImage(
    'library/img/gmap_marker.gif',
    new google.maps.Size(100, 100),
    new google.maps.Point(0, 0),
    new google.maps.Point(100, 100)
);

var shadow = new google.maps.MarkerImage(
    'library/img/gmap_shadow.png',
    new google.maps.Size(100, 100),
    new google.maps.Point(0, 0),
    new google.maps.Point(100, 100)
);

// set the personmarker
var person = new google.maps.Marker({
    position: currentPos,
    icon: marker,
    draggable: false,
    raiseOnDrag: false,
    shadow: shadow,
    animation: google.maps.Animation.DROP,
    map: app.map,
    optimized: false
});

Answer 1:

关键是要设置optimized: false ,但既然你已经有了和它不工作-我测试,以创建自己的简单的例子,它的工作。

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Google Maps JavaScript API v3 Example: Marker Simple</title>
    <link href="https://google-developers.appspot.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
    <script src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
    <script>
      function initialize() {
        var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
        var mapOptions = {
          zoom: 4,
          center: myLatlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: 'Hello World!',
            icon: "http://gwtportlets.googlecode.com/svn-history/r46/trunk/src/org/gwtportlets/portlet/public/img/portlet-loading-32x32.gif",
          optimized: false
        });
      }
    </script>
  </head>
  <body onload="initialize()">
    <div id="map_canvas">

    </div>
   </body>
</html>

编辑它,请你根据自己的需要,你也可以尝试使用的交换google.maps.MarkerImagegoogle.maps.icon因为MarkerImage似乎被弃用见: MarkerImage和图标 。

祝你好运与DA代码!



文章来源: Google Maps JS API v3 and looping animated gif's