Answer the question
In order to leave comments, you need to log in
How to gradually display coordinates on Yandex Map?
Good day to all! How can I gradually, after a certain period of time, display the coordinates stored in the array on Yandex Map? I understand that this is a somewhat artificial situation, but still. The first thing that came to my mind was to use setTimeout and setInterval before calling the draw point function.
// Функция ready вызовется тогда, когда API будет загружен и DOM сформирован
ymaps.ready(init);
var myMap, myPlacemark;
// Массивы координат
var Latitude = [53.8912, 53.8916, 53.8923, 53.8928,]
var Longitude = [27.5669, 27.5669, 27.5663, 27.5662,]
function init(){
myMap = new ymaps.Map("map", {
center: [Latitude[0], Longitude[0]],
zoom: 10
});
for(i = 0; i < Latitude.length; i++) {
setTimeout(addPoint, 5000, myMap, Latitude[i], Longitude[i]);
}
}
function addPoint(Map, lat, lon) {
myPlacemark = new ymaps.Placemark([lat, lon, {
content: 'Current location',
balloonContent: 'myBalloonContent'
});
Map.geoObjects.add(myPlacemark);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question