Make WMSGetFeature control respect layer projection if it equals the map projection. r=bartvde (closes #2918)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10948 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-12-04 13:51:11 +00:00
parent 492a6d930b
commit b125e045d1
2 changed files with 44 additions and 5 deletions

View File

@@ -345,28 +345,36 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
layerNames = layerNames.concat(layers[i].params.LAYERS);
styleNames = styleNames.concat(this.getStyleNames(layers[i]));
}
var firstLayer = layers[0];
// use the firstLayer's projection if it matches the map projection -
// this assumes that all layers will be available in this projection
var projection = this.map.getProjection();
var layerProj = firstLayer.projection;
if (layerProj && layerProj.equals(this.map.getProjectionObject())) {
projection = layerProj.getCode();
}
var params = OpenLayers.Util.extend({
service: "WMS",
version: layers[0].params.VERSION,
version: firstLayer.params.VERSION,
request: "GetFeatureInfo",
layers: layerNames,
query_layers: layerNames,
styles: styleNames,
bbox: this.map.getExtent().toBBOX(null,
layers[0].reverseAxisOrder()),
firstLayer.reverseAxisOrder()),
feature_count: this.maxFeatures,
height: this.map.getSize().h,
width: this.map.getSize().w,
format: format,
info_format: this.infoFormat
}, (parseFloat(layers[0].params.VERSION) >= 1.3) ?
}, (parseFloat(firstLayer.params.VERSION) >= 1.3) ?
{
crs: this.map.getProjection(),
crs: projection,
i: clickPosition.x,
j: clickPosition.y
} :
{
srs: this.map.getProjection(),
srs: projection,
x: clickPosition.x,
y: clickPosition.y
}