How to change categoryIcon of existing poi
What is the best way to change the image for the categoryIcon of a poi already on the map?
I tried changing the image of an existing poi by using:
poi.categoryIcon = img;
but that didn't work.
the only way I could do it was to do that and then put all of the pois in the map again:
map.pois = pois;
but even that only worked with one image and then I could not change a second poi to a different image.
Thanks
Tom
Re: How to change categoryIcon of existing poi
I guess you could take a look at the customization zip file in the api. More specifically "How to customize.pdf". It has an entire category on how to customize markers/icons/elements.
Re: How to change categoryIcon of existing poi
I'm not trying to customize it. I'm just trying to change the marker image from the one I loaded initially to a new one. It should be one line of code i.e.
poi.categoryIcon = new_img;
but it's not working for me.
Thanks
Tom
Re: How to change categoryIcon of existing poi
The "categoryIcon" property is used only if you call createPoi method. To change the image you have to reset the image property of the poi:
var image = new Image();
image.onload = function() {
myMap.pois[0].image = image;
}
image.src = "myUrl.png";
Leo
Re: How to change categoryIcon of existing poi