I store all of the Google Maps marker objects in a single array. Right now I am trying to set up a function that will delete all of the markers in the array from the map, but I'm having trouble with the loop.
First, I put each marker in an array like so:
eval("markerZip"+value.zip+" = new google.maps.Marker({map: map, icon: '/images/mapmarker.php?m=zip_marker.png', position: zipCenter});");
eval("markersArray['markerZip"+value.zip+"'] = markerZip"+value.zip);
Then when I want to delete the markers I do this:
function removeAllMarkers(exceptId) {
$.each(markersArray, function(index, value) {
if(value != exceptId) {
value.setMap(null);
console.log(value);
}
});
}
However, iterating through the array doesn't seem to be doing anything. It's as if the array is empty because the console.log line returns nothing. When I display the array in my console, it shows "[]" (which I then click to display the child objects) which contains:
markerZip01002
U { gm_accessors_={...}, map=U, b=U, more...}
markerZip02111
U { gm_accessors_={...}, map=U, b=U, more...}
markerZip02135
U { gm_accessors_={...}, map=U, b=U, more...}
markerZip02139
U { gm_accessors_={...}, map=U, b=U, more...}
markerZip02466
U { gm_accessors_={...}, map=U, b=U, more...}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)