T
T
temamagic2015-11-20 02:12:27
JavaScript
temamagic, 2015-11-20 02:12:27

Yandex Maps get Placemark coordinates after moving?

There are many Placemarks, each with its own text, added via add(

myMap.geoObjects
      .add(myPolyline)
      .add(new ymaps.Placemark([53.8, 36.3], {
          iconContent: '1',
          iconColor: '#3caa3c',
          balloonContent: '1| 06:51'
      }, {
          draggable: true
      })).add(new ymaps.Placemark([53.9, 36.2], {
          iconContent: '2',
          iconColor: '#4d7198',
          balloonContent: '2| 07:26'
      }, {
          draggable: true
      }));
  myMap.geoObjects.events.add([
      'dragend'
  ], function(e) {
      //надо получить lat и lon точки куда переместили placemark
  });

you need to get lat and lon points where the placemark was moved,
and how to get balloonContent/iconContent there?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
temamagic, 2015-11-20
@temamagic

Solution found:

myMap.geoObjects.events.add([
        'dragend'
    ], function (e) {
    var placemarkPosition = myMap.options.get('projection').fromGlobalPixels(
            myMap.converter.pageToGlobal(e.get('position')),
            myMap.getZoom()
        );
    console.log(placemarkPosition); // - координаты.
    e.get('target').properties.get('iconContent'); // - iconContent
    });

V
Vladimir Sergeevich, 2016-01-21
@VladimirZhid

iw.luna.kg/test_map_functional
You will see the script in the code, you can read it right away.... Added comments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question