> Have you seen this page on Mike Williams' tutorial?
> Part 14 Fitting the map zoom to the datahttp://econym.org.uk/gmap/basic14.htm
>
> -- Larry
Thank you Larry, I'm trying the example, but I can't understand why it
doesn't work, here my code, if I comment the line with bounds.extend I
can see all of the markers in the map, if I leave the bound.extend
call It stops after the first marker is put on the page.
I can't se any js error in the console. :-(
function createMarker(point, title, descrizione) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml('<h2>'+title+'</h2>'+descrizione);
});
return marker;
}
$(window).load(function() {
if($('#mappa_percorso').length > 0) {
if (!GBrowserIsCompatible()) {
alert("Sorry, the Google Maps API is not compatible
with this
browser");
} else {
map = new
GMap2(document.getElementById("mappa_percorso"));
//map.setCenter(new GLatLng(41.900948271303726
,12.483307599759428),
11);
map.setCenter(new GLatLng(0,0),0);
map.addControl(new GLargeMapControl());
bounds = new GLatLngBounds();
for(var i = 0; i < markers_list.length; i++) {
marker = markers_list[i];
lat = parseFloat(marker.lat);
lng = parseFloat(marker.lng);
log('Lat:'+lat+"\n"+'Lng:'+lng);
point = new GPoint(lng, lat);
map.addOverlay(createMarker(point, marker.nome,
marker.descrizione));
bounds.extend(point);
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter())
}
}
});
--
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.