Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One example of animating a marker along a polyline is:</p> <p><a href="http://www.geocodezip.com/v3_animate_marker_xml.html" rel="nofollow">http://www.geocodezip.com/v3_animate_marker_xml.html</a></p> <p>Code ported from <a href="http://econym.org.uk/gmap/" rel="nofollow">Mike Williams' v2 tutorial</a>.</p> <pre><code>//=============== animation functions ====================== function updatePoly(d) { // Spawn a new polyline every 20 vertices, because updating a 100-vertex poly is too slow if (poly2.getPath().getLength() &gt; 20) { poly2=new google.maps.Polyline([polyline.getPath().getAt(lastVertex-1)]); // map.addOverlay(poly2) } if (polyline.GetIndexAtDistance(d) &lt; lastVertex+2) { if (poly2.getPath().getLength()&gt;1) { poly2.getPath().removeAt(poly2.getPath().getLength()-1) } poly2.getPath().insertAt(poly2.getPath().getLength(),polyline.GetPointAtDistance(d)); } else { poly2.getPath().insertAt(poly2.getPath().getLength(),polyline.getPath().getAt(polyline.getPath().getLength()-1)); } } function animate(d) { if (d&gt;eol) { var endlocation = polyline.getPath().getAt(polyline.getPath().getLength()-1); map.panTo(endlocation); marker.setPosition(endlocation); return; } var p = polyline.GetPointAtDistance(d); map.panTo(p); marker.setPosition(p); updatePoly(d); timerHandle = setTimeout("animate("+(d+step)+")", tick); } function startAnimation() { if (timerHandle) clearInterval(timerHandle); eol=polyline.Distance(); map.setCenter(polyline.getPath().getAt(0)); if (marker) { marker.setMap(null); delete marker; marker = null; } if (!marker) marker = new google.maps.Marker({location:polyline.getPath().getAt(0), map:map} /* ,{icon:car} */); poly2 = new google.maps.Polyline({path: [polyline.getPath().getAt(0)], strokeColor:"#0000FF", strokeWeight:10}); setTimeout("animate(50)",2000); // Allow time for the initial map display } //=============== ~animation functions ===================== </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload