[OpenLayers-Users] data extent for wms layer?

Charles Galpin cgalpin at lhsw.com
Wed Nov 9 15:04:44 EST 2011


Thanks Andreas

This would be exactly what i was looking for until I realized I am using geoserver's sql view feature so each time I make a call for the layer the actual bounding box will vary based on input. Thanks a lot for the suggestion though.

I think i'll have to generate this from a custom service. A vector layer is just too expensive for this particular use.

charles

On Nov 9, 2011, at 10:57 AM, Andreas Hocevar wrote:

> Hi,
> 
> the best way to do this is to issue a GetCapabilities request, parse the response with OpenLayers.Format.WMSCapabilities, and look for the layer's bbox or llbbox in the capabilities object. An untested snippet to show you what I mean:
> 
> var myLayerName = "my_layer";
> var obj = new OpenLayers.Format.WMSCapabilities().read(response.responseText);
> var capability = obj.capability;
> for (var i=0, len=capability.layers.length; i<len; i++) {
>    var layerObj = capability.layers[i];
>    if (layerObj.name === myLayerName) {
>        map.zoomToExtent(OpenLayers.Bounds.fromArray(layerObj.llbbox));
>        break;
>    }
> }
> 
> Andreas.
> 
> On Nov 9, 2011, at 15:54 , Charles Galpin wrote:
> 
>> I'm drawing a blank on the best way to do this.  I have a wms layer (for performance)  that I'd like to zoom to the data extent for, but it looks like this is not available for a wms layer like you can for a vector layer.  
>> 
>> Is there a fast call I can make to get the extent only and then use this to zoom?  I am using geoserver on the server side.  Any suggestions would be appreciated.
>> 
>> Thanks,
>> charles
>> 
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 
> 
> 
> -- 
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
> 



More information about the Users mailing list