javascript - Reset pin graphic when infobox closes -


i have simple google maps (api v3) code changes icon orange when particular marker clicked , infobox opens. code notices if infobox open , if so, resets marker icon on old infobox.

however, can't figure out how reset marker icon default if infobox closed.

i use 1 infobox , fill details each time marker clicked:

google.maps.event.addlistener(marker, 'click', (function(marker, i) {     return function() {          if(previousmarker) {             // if marker icon changed before, change default             previousmarker.seticon('/img/location_pin.png');         }         ib.close();               // close infobox open         ib.setoptions(opt[i]);    // set new options infobox         ib.open(map, this);       // open on marker          // , change marker color orange         marker.seticon('/img/location_pin-orange.png');          previousmarker = marker;  // remember marker next time          map.panto(markerdata[i].latlng);     } })(marker, i)); 

how can have markers on map (or previousmarker, really) go default color when infobox closed?

reset marker options inside callback closeclick event on infowindow.

google.maps.event.addlistener(ib, 'closeclick', function(){      // add code reset marker options  }); 

see api reference events associated infowindow object.

if using infobox library, events still same same event listener can applied: api reference infobox


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -