2

converting my Google maps code over to Yandex maps.

I have a function which updates the markers (placemarks) icon on the map.

In google maps i can do:

var newImage = new google.maps.MarkerImage('img/presence/' + marker.state.toLowerCase() + '_map.png');
marker.setIcon(newImage); 

I cannot find an equivilent method for setIcon in Yandex.

I can set the image at marker creation with:

var marker = new ymaps.Placemark(point, null, {
    iconImageHref: 'img/presence/'+state+'_map.png', 
    iconImageSize: [20, 20], 
    iconImageOffset: [-10, -20]
});

Any idea how i can update the icon image?

Vince Lowe
  • 3,521
  • 7
  • 36
  • 63

1 Answers1

3

You can update options of existing placemark (marker):

marker.options.set('iconImageHref', 'img/newImage.png');
Mariya Steksova
  • 850
  • 9
  • 14
  • Hi Mariya, I see you have experience working with Yandex Maps. I'm currently using Yandex maps and have posted my issue here: http://stackoverflow.com/questions/31739389/yandex-markers-current-latlong-values-in-android/31787015. Can you please check and provide your feedback or solution? – Hemant Aug 04 '15 at 13:22