The problem is that
GEvent.addListener(map.getTabbedMaxContent()
is a *map* listener, not a *marker* listener.
What you're doing for each marker is:
GEvent.addListener(marker, "click", function(){
...
}
GEvent.addListener(map.getTabbedMaxContent(), 'selecttab',
function(tab){
...
}
Which means that you set up a marker "click" listener and a map
"selecttab" listener for every marker. When a tab is selected, *all*
those "selecttab" listeners get triggered in turn, each attempting to
display the content for their marker. Only one can win, and the same one
wins every time.
What you need to do is move your
GEvent.addListener(map.getTabbedMaxContent()
outside your newMarker() function, and outside the loop, and load the
data corresponding to the marker.
That's going to mean remembering which marker was clicked, by storing a
reference to the last clicked marker in a global variable:
var lastMarker; // global
...
GEvent.addListener(marker, "click", function(){
lastMarker = marker;
...
}
Then when your "selecttab" triggers, grab the data from the data that
you stored in the marker
case 'Production Info':
// do a quick check to avoid repeat call
if (document.getElementById('productionInfo').innerHTML == '') {
document.getElementById('sum').innerHTML =
'Production of the clicked point: <b>'
+ lastMarker.myname + '</b>';
document.getElementById('productionInfo').innerHTML =
'<tr><td><b>Address: </b>' +
lastMarker.myaddress +
...
i.e. replacing "production" with "lastMarker.myname"; "address" with
"lastMarker.myaddress", etc.
You'll need to store more data in your marker, because not all the
variables that you use have stored equivalents.
--
Mike Williams
http://econym.org.uk/gmap
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---