adding zooming to maxDataExtent

This commit is contained in:
sanj 2010-09-18 23:58:58 +05:30
parent 8a1a2c834a
commit 30edb01ffc

View File

@ -1,5 +1,4 @@
var currentlySelectedFeature, jsonLayer, mapControl;
var map, currentlySelectedFeature, jsonLayer, mapControl, zoomControl;
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
@ -60,8 +59,11 @@ $(function() {
map.setCenter(center, 12);
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});