Google Maps JS API v3 and loop animated gif

I can’t imagine the animation using the Google Maps API. It plays the animation for the first time, but will not play after that.

Can someone point me in the right direction? I have a lot of code in this file, so I pulled out the important bits, I will be happy to come up with something else if necessary.

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 }); 
0
javascript google-maps-api-3 google-maps-markers
source share
1 answer

The key is to set optimized: false , but since you already have it and it doesn't work - I tested creating my own simple example, and it worked.

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

Change it as you wish, according to your needs, you can also try swapping with google.maps.MarkerImage to google.maps.icon , because MarkerImage seems deprecated: MarkerImage and Icon .

Good luck with the da code!

+6
source share

All Articles