Toggling on/off Markers in Google Maps API v3 -


i'm having trouble getting setmap(null); function seems recommending work.

i believe may problem way i've implemented markers.

if take , let me know if see wrong i'd appreciate it.

link: http://www.dougglover.com/samples/uoitmap/v2/

please note: old link above, doesn't go anywhere.

the basic problem if want work you've got make mind markerstest object supposed hold. can't seem decide whether elements in markerstest should markers or should arrays tell markers going placed.

quoting javascript file, here 2 functions executed when check/clear checkbox:

15  function addtestmarkers(){ 16      for(var in markerstest) { 17          var location = new google.maps.latlng(markerstest[i][1], markerstest[i][2]); 18          marker = new google.maps.marker({ 19              position: location, 20              map: map 21          }); 22      } 23  } 24   25  // removes overlays map, keeps them in array 26  function clearoverlays() { 27      if (markerstest) { 28          (i in markerstest) { 29              markerstest[i].setmap(null); 30          } 31      } 32  } 

for addtestmarkers work, markerstest object needs hold descriptions of markers should go. clearoverlays work, markerstest object needs hold markers.

here's suggestion: change markerstest object set @ top of javascript file markerdestinations, , @ top of javascript file have markerstest initialized with:

markerstest = {}; 

then, modify addtestmarkers to:

function addtestmarkers() {     for(var in markerdestinations) {         var location = new google.maps.latlng(markersdestinations[i][1], markersdestinations[i][2]);         markerstest[i] = new google.maps.marker({             position: location,             map: map         });     } } 

the key change make addtestmarkers put markers markerstest object.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -