G
G
grendel2014-01-14 19:45:35
JavaScript
grendel, 2014-01-14 19:45:35

How can I remove added tags from Yandex.Maps 2.0?

Good evening!
How can I remove added markers from the map? I'm using this example from the docs, just changing the code slightly to add a new label each time the map is clicked:

myMap.events.add('click', function (e) {
        var coords = e.get('coords');
            myPlacemark = createPlacemark(coords);
            myMap.geoObjects.add(myPlacemark);
            myPlacemark.events.add('dragend', function () {
                getAddress(myPlacemark.geometry.getCoordinates());
            });
        }
        getAddress(coords);
    });

What do I need to do so that when I click on a label, for example, a balloon with a delete button opens, because after creating a new label, myPlacemark already points to a new one? I believe that we need to do something with the GeoObjectCollection (add each label to the GeoObjectCollection. and display the GeoObjectCollection on the map, and hang something like , but how to get a pointer to the label we clicked on, and how to delete it further , I don't understand. myCollection.events.add('click', function (e) {…})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dimik, 2014-01-15
@grendel

You need to create your own layout of the balloon, in it you can access the label object and hang a click handler on the link in the balloon content that will delete it
Wrote an example for you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question