[Users] Automatically zooming to layer extent

Vidal, Antoni antoni.vidal at icc.cat
Thu Nov 3 07:54:09 CET 2011


Hi Wangson,

 

Try map.zoomToMaxExtent.

 

See at
http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.M
ap.zoomToMaxExtent 

 

Yours,

 

Toni.

 

De: users-bounces at geoext.org [mailto:users-bounces at geoext.org] En nom de
Peerasak Wangsom
Enviat: jueves, 03 de noviembre de 2011 7:33
Per a: users at geoext.org
Tema: [Users] Automatically zooming to layer extent

 

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111103/d90be46b/attachment-0001.htm 


More information about the Users mailing list