All the layers in my application are EPSG:31466. However, if I retrieve the capabilites:
var wms = new OpenLayers.Format.WMSCapabilities();
OpenLayers.Request.GET({
url: myUrl,
success: function(e){
var response = wms.read(e.responseText);
var layerObj = response.capability.layers[0];
console.log(layerObj.llbbox);
}
}
The BoundingBox' Coordinates are given in a totally different format.
In EPSG:31466 I would expect them to be similar to new OpenLayers.Bounds(363060,5770362,363496,5771118)
, but in fact they are like this: [-23.015284514192917, 48.276782941782315, -22.953739137948624, 48.29765968309495]
.
Looks like a different format, but why and how do I change this?
console.log(layerObj.llbbox);
var my_extent=new OpenLayers.Bounds(layerObj.llbbox).transform(new OpenLayers.Projection("EPSG:4326"),map.displayProjection);
console.log(my_extent);
Console Output:
[-23.015284514192917, 48.276782941782315, -22.953739137948624, 48.29765968309495]
Object { left=-23.015284514193, bottom=48.276782941782, right=-22.953739137949, more...}
Best Answer
It's EPSG 4326. llbox means latlon-boundingbox. Every layer has to be published in 4326 but can often be requested in different crs's, so you get the llbbox always in 4326. just reproject them with
for example
If transforming fails one reason can also be that you have not included proj4.js for this projection.
Reprojecting should work if proj4.js is included. see console.log in this example:
http://dev.openlayers.org/examples/using-proj4js.html
You can get the BBOX of your Layer also with
instead of