I agree with you...but I can't make it work...help me ;)
(points is an object)
function map(points) {
// Impostazioni Generali della mappa
var size = new google.maps.Size(points[0].map_w, points[0].map_h,
'px', 'px');
var j = 0;
var center = new google.maps.LatLng(0,0);
var accuracy = 10;
var control = true;
var sw = true;
var options = {
zoom: accuracy,
center: center,
// Scelta del tipo di mappa
mapTypeControl: true,
mapTypeControlOptions: {style:
google.maps.MapTypeControlStyle.DROPDOWN_MENU},
mapTypeId: google.maps.MapTypeId.HYBRID,
// Navigazione
navigationControl: control,
navigationControlOptions: {style:
google.maps.NavigationControlStyle.ZOOM_PAN},
mapTypeControl: true,
// Scala della mappa
scaleControl: true,
size: size,
streetViewControl: sw
};
var map = new
google.maps.Map(document.getElementById(points[0].map_id), options);
// Per ogni punto
var i = 0;
for (i=0; i<points.length; i++)
{
var latlng = new google.maps.LatLng(points[i].latitude,
points[i].longitude);
marker[i] = new google.maps.Marker({
position: latlng,
visible: true,
clickable: true,
map: map
});
var infowindow = new google.maps.InfoWindow({
content: points[i].text
});
google.maps.event.addListener(marker, 'click',
function() {
infowindow.open(map,marker);
});
}
return map;
}
On 17 Gen, 06:48, Chris Broadfoot <[email protected]> wrote:
> On Mon, Jan 17, 2011 at 6:44 AM, lorenzo83 <[email protected]> wrote:
> > I want to add an infowindow for each marker shown on a map, but with
> > the same code if I click on a marker the infowindow appears only on
> > the last marker created.
>
> Sounds like pitfall #3 as described here:http://econym.org.uk/gmap/basic1.htm
>
> Chris
--
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.