So im trying to move marker smoothly, but id doesnt work. Marker is moving, but not smoothly, the same result i can have if i will write
marker[n].setPosition(moveto);
i have displayed all variables in console, and its fine, all increases by right way, but it seems like
marker[n].setPosition(latlng);
is called only at the last iteration of cycle.
here is my code:
function animatedMove(n, current, moveto){
var lat = current.lat();
var lng = current.lng();
var deltalat = (moveto.lat() - current.lat())/100;
var deltalng = (moveto.lng() - current.lng())/100;
for(var i=0;i<100;i++){
lat += deltalat;
lng += deltalng;
latlng = new google.maps.LatLng(lat, lng);
setTimeout(
function(){
marker[n].setPosition(latlng);
},10
);
}
}