0

I need to set up a map with several markers.

I know it is possible to change the icon marker on click, and to change the icon marker on click on an external link. I would like to know if it is possible with the Google Maps API do to the following :

  • On clic on a marker, changing the icons of all other markers (in order to have the marker I clicked on be on highlight and the others fade) ?
  • On clic on an element, change the icon of all other markers (for exemple, clicking on "show event" would put the corresponding marker on highlight and the others would fade) ?

Thank you !

HIMALAYA
  • 11
  • 2
  • possible duplicate of [Change Google Maps marker icon when clicking on other](http://stackoverflow.com/questions/27754101/change-google-maps-marker-icon-when-clicking-on-other) – geocodezip Jul 13 '16 at 23:02

1 Answers1

1

You need the collection of all the markers in an arrays ..

 var  myMarkers[]

Then preserve the marker you click doing a copy so you can iterate over this array of markers and change the icon for all the markers

  myMarker[i].setIcon('my_new_icon.png');

and last preserve le marker icon

  myCopiedMarker.setIcon(my_old_icon.png');
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107