【问题标题】:Gmap Angularjs Gif Markers Doesn't LoopGmap Angularjs Gif标记不循环
【发布时间】:2016-12-22 19:49:08
【问题描述】:

我正在使用带有 angularjs 的 gmap。我创建了一个变量作为 json 数组,用于包含 id 和坐标的标记,如下所示:

{ "id": 1, "coords": { "latitude": 20 , "longitude": 30 } ,"icon": {"url": 'image.gif'}}, 

但问题是 gif 标记图标不循环。我也尝试过输入optimized : false,但没有任何改变。当我打开 panaroma 视图时,gif 循环但在法线贴图上它不循环。你能帮我怎么做吗?或者任何例子。

【问题讨论】:

    标签: java html angularjs google-maps


    【解决方案1】:

    既然你已经设置了optimized: false,你可以试试这个thread中的代码示例。

    <!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>
    

    您还可以查看相关的SO question,它指出标记使用了一种称为优化渲染的东西,它始终将标记呈现为静态。查看生成标记的示例代码:

    var marker = new google.maps.Marker({
        position: latLng,
        map: map,
        icon: icon,
        optimized: false
      });
    

    希望这会有所帮助!

    【讨论】:

    • 我之前已经看过这个答案,但我使用的是 ui-gmap-google-map ,所以代码不同,我不使用新的 google.maps.Marker 所以当我把优化的 : false 放入 $ scope.markers 不起作用..但感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-11
    相关资源
    最近更新 更多