[OpenLayers-Users] Zoom to feature after mapload
Marco Scheuble
mail at marco-scheuble.de
Wed Jan 27 04:18:39 EST 2010
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 look at:
http://trac.openlayers.org/wiki/Addins/ZoomToFeatures
hope this helped.
cheers, Marco
Am 27.01.2010 09:21, schrieb 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 to get the bounds for this feature based on the
> attribute? Then the zoom would be easy to implement.
>
> Regards,
> Herman
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100127/34e4da8d/attachment.html
More information about the Users
mailing list