[OpenLayers-Users] Zoom on GML extent

Andreas Hocevar ahocevar at opengeo.org
Mon Jan 18 08:05:55 EST 2010


christophe triquet wrote:
> Hi,
>
> I'm adding a GML file in my map with the object OpenLayers.Layer.GML. 
> I'm trying to zoom to this layer extent at map's loading. I can do 
> this if I know de bounding box coordinates with a postgis query.
>
> Is it possible the get the gml extent to be able to automaticaly zoom 
> on it at loading ?

var vectorLayer = ...;
vectorLayer.events.on({
    "loadend": function() {
        map.zoomToExtent(vectorLayer.getDataExtent());
    }
});


Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.





More information about the Users mailing list