google map API v3 change marker icon on click?
Try this.
//open onclick
google.maps.event.addListener(marker, 'click', function() {
marker.setIcon("Your Image");
infowindow.open(map);
});
You need to set the marker icon in the click event.
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map);
//Change the marker icon
marker.setIcon('https://www.google.com/mapfiles/marker_green.png');
});
Here is an example: jsfiddle
I have modified the previous fiddle and enabled to deselect the marker.
http://jsfiddle.net/zsw76pq9/
google.maps.event.addListener( map,'click', function () {
infoWindow.close();
//Change the marker icon
marker.setIcon('https://www.google.com/mapfiles/marker_black.png');
});