ThinkGeo.com    |     Documentation    |     Premium Support

Overlay Extent is not fit using ZoomToExent(exent) by Client Side

Hi,
I am trying to set Layer Extent to the Map by Client Side, but it’s not work out.
Code:
function zoomToRoute(overlayName) {
if (wfMap != undefined) {
var overlay = olMap.getLayer(overlayName);
if (overlay != null)
wfMap.ZoomToExtent(overlay.getExtent());
}
I think problem will be Overlay Extent, can you please check and give me code for setting Layer Extent to the Map.

Thanks,
Riyaz

Hi Riyaz,

The result of the overlay.getExtent() is not equal the GetBoundingBox in server side.

If you pan the map and alert(overlay.getExtent()) you can see its value get changed always.

So if you want to zoom to target extent, please build it and call this API for example:

var extent = new OpenLayers.Bounds(30, -95, 78, -60);
Map1.ZoomToExtent(extent);

I think this topic maybe helpful.

Regards,

Ethan