I have created an array of markers on a map. And I have a list of these markers outside of the canvas. I would like to learn about and create some interaction between these.
My markers are created like so:
var markers = [];
var marker = [];
var i;
// var places is an array of locations
for (var i=0;i<places.length;i++) {
var place = places[i];
var latLng = new google.maps.LatLng(place[1], place[2]);
marker[i] = new google.maps.Marker({
position: new google.maps.LatLng(place[1], place[2]),map: map
});
marker[i].set('id','marker_'+i);
markers.push(marker[i]);
}
I thought perhaps by using MVCObject I could set the id of the marker, and perhaps my marker would have an id of 'marker_1' for example, which I could access in the DOM with jquery via something like:
$('#marker_0').doSomething();
But this doesn't seem to be the case.
How can I give each marker a unique Id to access in the DOM outside the map canvas and API?