There is an array in which 5 values of longitude and latitude, that is, the location of different objects. Looked at the documentation, made an array like there. Happened. The data is displayed, but in the interval, when data is updated in the array, it does not want to change its position. Why? This is about myLatLng data
Here is a piece of code:
//Получаю значения и обновляю.ве ок var znak = parseFloat($('td').eq(2).html()) || 0, lng0 = znak; var znac = setInterval(function (){ znak = lng0 = parseFloat($('td').eq(2).html()); },2000); var znak1 = parseFloat($('td').eq(3).html()) || 0, lat1 = znak1; var znac = setInterval(function (){ znak1 = lat1 = parseFloat($('td').eq(3).html()); },2000); console.log(znak); console.log(znak1); // then put it in an array;
var myLatLng ={lat:znak,lng:znak1}; var locations = [ ['Azer', myLatLng, 4], ['Coogee Beach', -33.923036, 151.259052, 5], ['Cronulla Beach', -34.028249, 151.157507, 3], ['Manly Beach', -33.80010128657071, 151.28747820854187, 2], ['Maroubra Beach', -33.950198, 151.259302, 1] ]; I add to the map and here everything is well displayed
var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); // but here is the problem: further in the interval the array does not want to change its value
var setId=setInterval(function (){ for (i = 0; i < locations.length; i++){ marker.setPosition( new google.maps.LatLng(locations[i][1], locations[i][2])) console.log(locations[i][1]); } }, 2500);