Answer the question
In order to leave comments, you need to log in
How to access a label by id?
I create labels like this
addressPointsCollection = new ymaps.GeoObjectCollection()
addedAddressesCount = 0
for address in addresses
geoObject = new ymaps.GeoObject
geometry:
type: 'Point'
coordinates: [address.latitude, address.longitude]
properties:
# iconContent: address.service.name
hintContent: address.location
id: address.id
, preset: 'islands#darkGreenCircleDotIcon'
addressPointsCollection.add geoObject
addedAddressesCount += 1
searchMap.geoObjects.add addressPointsCollection
searchMap.setBounds(addressPointsCollection.getBounds(), { checkZoomRange: true });
id: address.id
) to refer to the label, for example, to change the icon? Answer the question
In order to leave comments, you need to log in
You won't be able to access the label through properties.id. You can create a global object (array) and add labels to it.
Add a label:
Then, at the right time, access the label, for example, to change the color:
objects[id].options.set('preset', 'islands#greenCircleDotIcon');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question