[OpenLayers-Users] Zoom to a Layer's Extent

Christopher Schmidt crschmidt at metacarta.com
Fri Sep 5 13:37:19 EDT 2008


On Fri, Sep 05, 2008 at 11:30:20AM -0600, Bill Thoen wrote:
> Never mind... I just figured out that getDataExtent() applies to 
> markers, not features like polygons and linestrings.  Does anybody know 
> if there is a function for WFS layers that returns the bounding box of 
> that layer regardless of what type of map objects it contains?

In 2.7RC1 (just released) you can use getDataExtent() for that. (We
didn't add getDataExtent for vector layers until after 2.6.)

Also, using 2.7RC1 would help us get more 2.7 testing :)

If that doesn't work for you, I recommend looking at Layer.Vector's
getDataExtent, and implementing that in your application.

-- Chris

> Bill Thoen wrote:
> > If I set a listener for loadend and the function called checks to make 
> > sure that there are features loaded, then why does 
> > myStates.getDataExtent() return null? Shouldn't this function return the 
> > bounds of the features now loaded into this layer?  Or are the bounds 
> > not updated when a WFS layer is loaded?
> >   
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list