Can I use my own custom animated gifs as markers on Google Maps API?

a 夏天 提交于 2019-12-05 14:51:03

Yes you can 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"
    });
}

You just need to use icon:icon-url when creating the marker.

Update:

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.

I assumed you can do this:

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!