[Users] Automatically zooming to layer extent

Andreas Hocevar ahocevar at opengeo.org
Thu Nov 3 10:20:09 CET 2011


Hi,

in order to get the extent of a WMS layer, you need to use a WMSCapabilitiesStore to get information about the layer. http://dev.geoext.org/trunk/geoext/examples/layercontainer.html should provide you all the relevant code snippets.

Andreas.

On Nov 3, 2011, at 07:33 , Peerasak Wangsom wrote:

> Dear all,
> 
> I try to automatically zoom map to maximum extent of layer after adding layer to map.
> I tried to code like this.
> 
> var layer = OpenLayers.Layer.WMS(.......);
> 
> map.addLayer(layer);
> 
> map.zoomToExtent(layer.getDataExtent());
> 
> But it doesnt' work. I also changed like this
> 
> map.zoomToExtent(layer.getMaxExtent());
> 
> It still doesn't work. What can I do to solve this issue.
> 
> Thank you.
> wangsom
> 
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users



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



More information about the Users mailing list