[OpenLayers-Users] zoom to layer?

Nicholas Bergson-Shilcock nicholasbs at openplans.org
Tue Apr 21 15:46:55 EDT 2009


Excerpts from Tim Michelsen's message of Tue Apr 21 15:38:12 -0400 2009:
> Hello,
> does Openlayers have a feature like
> zoom to layer?
> 
> Like in many desktop GIS where you can use this to get automatically to 
> an adequate extend and zoom level.

Do you mean "zoom to best fit the data on a layer"? For that, I use the
getDataExtent() function. E.g., if I want to show the data on myLayer:

map.zoomToExtent(myLayer.getDataExtent());

See http://dev.openlayers.org/docs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.getDataExtent

-Nick

> 
> Regards,
> Timmie
> 



More information about the Users mailing list