Skip to content

Commit

Permalink
Calculate the map bounds and zoom level correctly so the displayed map
Browse files Browse the repository at this point in the history
area shows all the included POIs.
  • Loading branch information
pneff committed Jun 10, 2010
1 parent c650fb9 commit dc6752b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions 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()) {
Expand Down Expand Up @@ -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(){
Expand Down

0 comments on commit dc6752b

Please sign in to comment.