javascript – Move label Yandex.Maps 2.1


Greetings. There is a great example of changing coordinates.

How to supplement it so that the marker (mark) appears on the first click, and when you click to another place on the map, it is rearranged?

I ask in advance in detail, tk. newbie.


For example like this:

 ymaps.ready(init); var myMap, myPlacemark; function init() { myMap = new ymaps.Map('map', { center: [57.5262, 38.3061], // Углич zoom: 13 }); myPlacemark = new ymaps.Placemark();'click', function(e) { myPlacemark.geometry.setCoordinates(e.get('coords')); // устанавливаем метке координаты, высчитанные из положения клика myMap.geoObjects.add(myPlacemark); // ставим метку на карту }); }
 html, body, #map { width: 100%; height: 100%; padding: 0; margin: 0; }
 <script src="//" type="text/javascript"></script> <div id="map"></div>
Scroll to Top