[OpenLayers-Dev] how to zoomToLayer

Eric Lemoine eric.lemoine at camptocamp.com
Wed Sep 22 11:25:26 EDT 2010


2010/9/22 toni hernández <tonidelacalle at gmail.com>:
> Hi,
> I have a vector layer with several polygons.
> Is there a way to zoom to the layer?
> Right now, I take all the features from the layer (one by one), get their
> bounds and  keep the minimum left and bottom, and the maximum right and top.
> Then I  can create a new Bounds  and move the map with zoomToExtent (new
> Bounds(...))
> Is there a better way to do this?.

map.zoomToExtent(layer.getDataExtent());


-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Dev mailing list