Closed pawelbrachaczek closed 8 years ago
did you tried an absolute path?
How to do it?
marker.setIcon("http://yourdomain.com/.../assets/img/pin.png");
Paths to images are correct. New icon is visible, but old icon not dissapar (it's bigger). So there are two icons in the same place.
I never saw this kind of problem with google maps, I guess, you're creating another marker instead of updating one existing. Can you provide a piece of your code
Yes, probably I was creating a new marker in the same place. I fixed it like that:
for(var i=0; i < markersLength; i++){ if($map.gmap3().get(i).icon == "/assets/img/pin-on.png"){ $map.gmap3().get(i).setIcon("/assets/img/pin.png"); } }
Hi,
How can I change the icon of a specyfic marker?
I tried like this, but old icon dosn't dissapear:
$map.gmap3().marker({ position: [selecledMarker.lat, selecledMarker.lng] }).then(function(marker){ if(marker.icon == "/assets/img/pin-on.png"){ marker.setIcon("/assets/img/pin.png"); } });