P
P
Petr Ponomarev2017-04-05 14:38:07
Yandex
Petr Ponomarev, 2017-04-05 14:38:07

How to get object data on the map when clicked?

There is a map marked up with json array prntscr.com/esphkn
the price variable is added to the array
how can I get the price variable of the selected object when clicking?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petr Ponomarev, 2017-04-06
@Petrdis

// Listen for a click on the map.
objectManager.events.add('click', function (e) {
inc_items = e.get('objectId');
item = objectManager.objects.getById(inc_items).properties.description;
var coords = e.get('coords ');
// If the placemark is already created, just move it
if (myPlacemark) {
myPlacemark.geometry.setCoordinates(coords);
}
// If not, create it
else {
myPlacemark = createPlacemark(coords);
map.geoObjects.add (myPlacemark);
// Listen for the drag end event on the placemark.
myPlacemark.events.add('dragend', function () {
getAddress(myPlacemark.geometry.getCoordinates());
});
}
getAddress(coords);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question