Hello,
I wrote the following JS function which load all saved Markers and
show them onto a map.
All this works, but if I click over a marker, the infowindows is even
open in others coordinates.
Please, look this code:
*************************************
function getSavedMarkers()
{
$.post("LoadCoordinate.php", function(data)
{
var loadCoordinates = data;
var i=0;
for(i=0; i<loadCoordinates.length; i++)
{
var loadedMarker = new google.maps.Marker(
{
position: new
google.maps.LatLng(loadCoordinates[i]['lat'],
loadCoordinates[i]['lng']),
map: map,
title: loadCoordinates[i]['name']
});
var tooltip2 = '<div id="tooltip">'+
'<img src="staticimage.jpg"
alt="Image">'+
'</div>';
var infowindow = new google.maps.InfoWindow(
{
content: tooltip2,
//position: getPosition(loadCoordinates[2]['lat'],
loadCoordinates[2]['lng'])
//position: loadedMarker.getPosition()
position: new
google.maps.LatLng(loadCoordinates[2]['lat'],
loadCoordinates[2]['lng'])
});
google.maps.event.addListener(loadedMarker, 'click', function()
{
infowindow2.open(map,loadedMarker);
//infowindow2.setPosition(loadedMarker.getPosition());
});
}
}, "json");
**********************************
Why does not correctly set the position?
I tried in many way (look the commented lines) but the infowindow was
opened in the coordinates of the last marker loaded.
I hope you can help me.
Thankyou in advance.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.