0

我似乎无法使用 Google Maps API 循环播放动画 gif。它第一次播放动画,但之后不会再播放。

谁能指出我正确的方向?我在这个文件中有很多代码,所以我已经拖出了重要的部分,如果需要,我会很乐意提供更多。

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
});
4

1 回答 1

6

关键是要设置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>

随意编辑它以满足您的需要,您也可以尝试使用 to 交换,google.maps.MarkerImage因为google.maps.iconMarkerImage 似乎已被弃用,请参阅:MarkerImageIcon

祝你好运!

于 2013-01-31T15:35:16.947 回答