[OpenLayers-Users] Zoom to feature after mapload

2010-01-27 Thread Herman Badenhorst
Hi group. I need to implement the functionality where the map automatically zoom's to a feature after the map is loaded. Thus, my url will look something like this: http://host/MapViewer.php?SelectedUnit=123 The request parameter is the value of the 'unit' attribute in my layer. Is there a way

Re: [OpenLayers-Users] Zoom to feature after mapload

2010-01-27 Thread Marco Scheuble
Hi Herman, maybe you're looking for s.th. like this: get the bounds of a feature: var bounds = features[i].geometry.getBounds(); calculate zoom and zoom to the feature:: var desiredZoom = map.getZoomForExtent(bounds); map.setCenter(bounds.getCenterLonLat(), desiredZoom); for more information