Answer the question
In order to leave comments, you need to log in
How to get the id of the label that was clicked?
Yandex.Maps API version - 2.1
I'm trying to get the id of the clicked tag, but it doesn't work.
There is the following code in TypeScript:
var map = new ymaps.Map( 'map', {
center : [55.76, 37.64],
zoom : 7
} );
var objectManager = new ymaps.ObjectManager( {} );
this.objectManager.events.add(['click'], function(event){
// Здесь я хочу получить id метки
});
map.geoObjects.add( objectManager );
$.get( "/getObjects", {}, ( response:ServerResponse ) => {
objectManager.add( data.objects );
}, "json" );
interface ServerResponse {
status : string;
count : number;
objects: {
id : number; // id, который я хочу получить
type : string;
geometry: {
type : string;
coordinates: string[]
};
}[]
}
Answer the question
In order to leave comments, you need to log in
Watching the sandbox
this.objectManager.objects.events.add(['click'], function (e) {
var objectId = e.get('objectId'); //Твоя цепочка?
console.log(objectId); //Мой..)
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question