我可以在Google Maps API上使用自己的自定义动画GIF作为标记吗?

时间:2014-04-24 03:06:15

标签: google-maps google-maps-api-3 google-maps-markers

我想在谷歌地图上使用不同的动画图像(GIF)作为标记;我可以使用API​​吗?

2 个答案:

答案 0 :(得分:8)

是的,你可以Live Example):

var position = new google.maps.LatLng(59.219521,15.1419873);
var marker;
var map;

function initialize() {
    var mapOptions = {
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: position
    };

    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

    marker = new google.maps.Marker({
        map:map,
        draggable:false,
        animation: google.maps.Animation.DROP,
        position: position,
        icon: "http://heera.it/wp-content/themes/heerait/img/blog/me.png"
    });
}

您只需在创建标记时使用icon:icon-url

<强>更新

marker = new google.maps.Marker({
  map:map,
  draggable:false,
  optimized:false, // <-- required for animated gif
  animation: google.maps.Animation.DROP,
  position: position,
  icon: "http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-01-35/e8nZC.gif"
});

Example Here.

答案 1 :(得分:0)

我以为你可以这样做:

function showMarkerFeature(p) {
var oF = new google.maps.Marker({
    map: map,
    position: p,
    //set the image src path here
    icon: "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png" 
});
identifyMarker.setVisible(false);
map.setCenter(p);

return oF;
}