[OpenLayers-Users] Zoom to a layer?

Tim Schaub noreply at geocartic.com
Thu Nov 30 15:19:52 EST 2006


> Typically this means "get the bounding box of the layer, and 
> then zoom to that extent"

Assuming the map variable contains your map:

map.zoomToExtent(map.layers[0].maxExtent);

will zoom to the max extent of the first layer.  Of course this assumes that
you've already set the max extent of the layer, and I think the question is
really about retrieving that extent.  OpenLayers doesn't have any way of
knowing what the extent of your layers are if you don't set them manually.
You'd have to set up something to retrieve the layer extent from the source
(if WMS and MapServer - this is advertised in the capabilities request).

If the WMS is on the same domain that is serving your application, this
would be pretty easy to do.  If the WMS is on a different domain, then you'd
need to set up a proxy server to get the extent.  If you're not talking
about a WMS layer, then more detail would help.

Tim


> 
> Erik Uzureau wrote:
> > Can you be a little more explicit?
> > I dont quite understand "zoom to a layer"
> > -Erik
> > 
> > On 11/30/06, Thomas Zuberbuehler <tzuberbuehler at datacomm.ch> wrote:
> >> Hi
> >>
> >> If there are a method in openlayers to zoom to a layer? Or has 
> >> somebody an idea how I can do that?
> >>
> >> Otherwise I can query the bbox from PostGIS, but I am 
> searching for a 
> >> method without this sql query.
> >>
> >> Thank you.
> >>
> >> Regards,
> >> Thomas
> >>
> >> --
> >> Thomas Zuberbuehler
> >> http://www.zubi.li
> >>
> >>
> >> --
> >> Thomas Zuberbuehler
> >> http://www.zubi.li
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> > 
> 
> --
> David Percy
> Geospatial Data Manager
> Geology Department
> Portland State University
> http://gisgeek.pdx.edu
> 503-725-3373
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 




More information about the Users mailing list