Answer the question
In order to leave comments, you need to log in
Why is the object created by the function not deleted in Yandex.maps?
Hello.
I use something like this code (I cut it a little to the very essence, which I don’t get)
myMap.events.add('click', function (e) {
var coords = e.get('coords');
var iAmHerePlaceMark1 = new ymaps.Placemark(coords, {}, {
preset: 'islands#geolocationIcon',draggable:true,
});
myMap.geoObjects.remove(iAmHerePlaceMark1);
window.myMap.geoObjects.add(iAmHerePlaceMark1);
});
Answer the question
In order to leave comments, you need to log in
I figured it out myself. It should be something like this:
var myCollection = new ymaps.GeoObjectCollection();
myMap.events.add('click', function (e) {
myCollection.removeAll();
var coords = e.get('coords');
var placeMark = new ymaps.Placemark(coords, {}, {
preset: 'islands#geolocationIcon',draggable:true,
});
myCollection.add(placeMark);
myMap.geoObjects.add(myCollection);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question