0

I have a problem on google maps that my marker moves too fast along the maps when coordinates for the certain marker changes, can anyone help me how can I make it smoothly moving? Thanks!

<script type="text/javascript">
var values = [];
var map;
var markers = [];
function    initMap()
{
            var options = {
                center: {lat: -33.890542, lng: 151.274856},
                zoom: 4
            };
            map = new google.maps.Map(document.getElementById('map'), options);
            var count = 0; 
            setInterval(function() {
                getGps();
                for(var i = 0; i < markers.length; i++){
                        markers[i].setPosition(new google.maps.LatLng(values[count][1], values[count][2]));
                        count++;
                    }
            }, 1000);
}
function getGps() {
            xmlhttp.onreadystatechange=function() {    
                if( xmlhttp.readyState==4 && xmlhttp.status==200 ) {
                    var res = xmlhttp.responseText; 
                    var split1 = res.split("|");
                        for(var i = 0; i <= split1.length; i++){
                            var split2 = split1[i].toString().split(","); 
                            var holder1 = holder = [split2[0],split2[1],split2[2]];
                            values.push(holder1);
                            var marker1 = marker = new google.maps.Marker({map: map, icon: 'images/mapvehicle.png', draggable: true});
                            markers.push(marker1);
                        }   
                }
            };
            xmlhttp.open("POST","GpsPost",true);
            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            xmlhttp.send();

}

Marvs.M
  • 13
  • 7
  • Hope this link helps: https://stackoverflow.com/questions/5892113/extend-google-maps-marker-to-animate-smoothly-on-update – xoxo Oct 18 '18 at 06:45
  • I am very new on google maps I can't understand some of it :( – Marvs.M Oct 18 '18 at 07:07

0 Answers0