my teeth just plunged into the Google Maps API.
I am trying to build a pair of markers on a map. Done. However, I recycle the variable / object for each marker.
First, I create a marker with parameters and add to the map, then I take the same marker variable, rearrange it and add it to the map again. This creates two unique markers with separate title tags.
I want to display an info window for each marker, but I doubt this is the best way to do this. I also see that an error icon appears on each marker, which assigns click events, since I use the same variable to add each marker, I'm not sure how to add its click event to unique markers (by name, as the name same for both since it never gets any identifier?)
var marker_obj = new google.maps.Marker({ position: myLatlng, title:"This is Marker 1", }); marker_obj.setMap(map); marker_obj = new google.maps.Marker({ position: myLatlng, title:"This is Marker 2", }); marker_obj.setMap(map);
To create information windows, I thought about using one variable / object to save the information window, and then reprogram it with new text in each marker click event.
Questions I have:
1: Should I use a separate unique variable / object for each marker (overhead?), If not, how to determine its click event.
2: Did you succeed in reassigning (reassigning) the information window object with new text before it pops up, or did you create a unique information window for each marker?
I am a bit of Java n00b, so any help would be greatly appreciated.