How can I delete specific marker in google maps ? I tried code below but I get TypeError: marker[1] is undefined
error. Without [1] it deletes the first marker only.
google.maps.event.addDomListener(deletemark, 'click', function() {
marker[1].setMap(null);
});
}
(from the comments, slightly edited) This is how I create markers, and marker's lat,long in array
var locations = [ [56.066877,21.069274], [55.279849,26.048155] ]; // removed "hanging comma"
for (i = 0; i < locations.length; i++)
{
marker = new MarkerWithLabel({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
map: map // removed "hanging comma"
});
} // added missing close bracket