Reputation: 686
I am a newbie in android development and currently working on an app where i need to show a marker moving along a path(poly-line). I have googled a lot for the functionality and got various answers too but for now i have selected the answer from this question which better suits the requirements. But the problem with the solution is the marker moving very fast. Please suggest me any correction or other solution that will slow down the speed of animation of moving marker or something like that.
Thanks
Upvotes: 1
Views: 4975
Reputation: 13469
From this answer in related SO post, you need to update the marker more than every 1/10 fraction of the polyline (at least every few pixels). Call the update method more frequently and don't delete and re-add the marker.
Sample code:
var counter = 0; interval = window.setInterval(function() { counter++; // just pretend you were doing a real calculation of // new position along the complex path var pos = new google.maps.LatLng(35, -110 + counter / 100); marker.setPosition(pos); if (counter >= 1000) { window.clearInterval(interval); } }, 10);
Check these related SO threads which might help:
Hope this helps!
Upvotes: 1