From 30edb01ffc789671aa82dd5fa55576fd164fe99d Mon Sep 17 00:00:00 2001 From: sanj Date: Sat, 18 Sep 2010 23:58:58 +0530 Subject: [PATCH] adding zooming to maxDataExtent --- vurbanism/static/js/vurbanism.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vurbanism/static/js/vurbanism.js b/vurbanism/static/js/vurbanism.js index b28cf93..bbc9fb8 100644 --- a/vurbanism/static/js/vurbanism.js +++ b/vurbanism/static/js/vurbanism.js @@ -1,5 +1,4 @@ -var currentlySelectedFeature, jsonLayer, mapControl; - +var map, currentlySelectedFeature, jsonLayer, mapControl, zoomControl; // Simple JavaScript Templating // John Resig - http://ejohn.org/ - MIT Licensed @@ -59,9 +58,12 @@ $(function() { map.addLayers(layers); map.setCenter(center, 12); - mapControl = new OpenLayers.Control.SelectFeature(layers[1], {hover: false}); + mapControl = new OpenLayers.Control.SelectFeature(layers[1], {hover: false}); + zoomControl = new OpenLayers.Control.ZoomToMaxExtent(); map.addControl(mapControl); +// map.addControl(zoomControl); mapControl.activate(); +// zoomControl.activate(); layers[1].events.on({ 'featureselected': onFeatureSelect }); @@ -147,6 +149,9 @@ $(function() { var currFeatures = jsonLayer.features; jsonLayer.removeFeatures(currFeatures); jsonLayer.addFeatures(geojson_format.read(features)); + var maxExtent = jsonLayer.getDataExtent(); + map.zoomToExtent(maxExtent); +// console.log(maxExtent); switch(type.toLowerCase()) { case "image": var html = tmpl("tmpl_images", {'images': json.images});