From dc6752bd0ca0cf62373277051b1015f121ff9c56 Mon Sep 17 00:00:00 2001 From: Patrice Neff Date: Thu, 10 Jun 2010 14:33:49 +0200 Subject: [PATCH] Calculate the map bounds and zoom level correctly so the displayed map area shows all the included POIs. --- scripts/maps.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/maps.js b/scripts/maps.js index d1ef0c0..d7f1b55 100644 --- a/scripts/maps.js +++ b/scripts/maps.js @@ -1,6 +1,7 @@ var gmap_data = Array(); var gmap_centered = false; +var gmap_bounds = new GLatLngBounds(); function gmap_loader(){ if (!GBrowserIsCompatible()) { @@ -29,10 +30,11 @@ function gmap_add(map,gc,adr,info,t){ if (!point) { //alert(address + " not found"); } else { - if(!gmap_centered){ - map.setCenter(point, 5); - gmap_centered = true; - } + gmap_bounds.extend(point); + var zoom = map.getBoundsZoomLevel(gmap_bounds); + if (zoom > 17) zoom = 17; + map.setCenter(gmap_bounds.getCenter(), zoom); + var marker = new GMarker(point); map.addOverlay(marker); GEvent.addListener(marker, "click", function(){