I assume this is a simple fix, but I can’t seem to get it right. The ‘GetFeatureInfo’ request works fine with one layer, but I am unable to get it working for all layers in the map. The relevant parts of code are shown below. // For WMS layer and for GetFeatureInfo var wmsurl = “http://localhost:8080/geoserver/wms”; // setup tiled layer var Primary = new OpenLayers.Layer.WMS( “Primary Schools”, “http://localhost:8080/geoserver/wms”, {‘layers’: ‘prototype:Primary’, ‘format’:‘image/png’, ‘transparent’:‘true’}, {‘opacity’: 1.0, ‘isBaseLayer’: false, ‘visibility’: false} ); ); // Tie click event to WMS GetFeatureInfo call map.events.register(‘click’, map, function (e) { var url = wmsurl + “?REQUEST=GetFeatureInfo” + “&EXCEPTIONS=application/vnd.ogc.se_xml” + “&BBOX=” + map.getExtent().toBBOX() + “&X=” + e.xy.x + “&Y=” + e.xy.y + “&INFO_FORMAT=text/html” + “&QUERY_LAYERS=prototype:Primary” + “&LAYERS=prototype:Primary” + “&FEATURE_COUNT=33” + “&SRS=EPSG:4326” + “&STYLES=” + “&WIDTH=” + map.size.w + “&HEIGHT=” + map.size.h; window.open(url, “getfeatureinfo”, “location=0,status=0,scrollbars=1,width=600,height=150” ); }); |
|---|
This code looks fine for a single layer. When you modify it to deal
with multiple layers, make sure to update both the LAYERS and
QUERY_LAYERS fields of the WMS GetFeatureInfo request.
You might also want to look into using the WMSGetFeatureInfo control
provided by OpenLayers instead of constructing the URL yourself. An
example is available here:
http://openlayers.org/dev/examples/getfeatureinfo-control.html
Hope this helps.
--
David Winslow
OpenGeo - http://opengeo.org/
On Tue, 2009-09-08 at 10:11 +0000, fsenyah@anonymised.com wrote:
I assume this is a simple fix, but I can't seem to get it right. The
'GetFeatureInfo' request works fine with one layer, but I am unable to
get it working for all layers in the map. The relevant parts of code
are shown below.// For WMS layer and for GetFeatureInfo
var wmsurl = "http://localhost:8080/geoserver/wms";
// setup tiled layer
var Primary = new OpenLayers.Layer.WMS(
"Primary Schools",
"http://localhost:8080/geoserver/wms",
{'layers': 'prototype:Primary',
'format':'image/png', 'transparent':'true'},
{'opacity': 1.0, 'isBaseLayer': false, 'visibility': false}
););
// Tie click event to WMS GetFeatureInfo call
map.events.register('click', map, function (e) {
var url = wmsurl
+ "?REQUEST=GetFeatureInfo"
+ "&EXCEPTIONS=application/vnd.ogc.se_xml"
+ "&BBOX=" + map.getExtent().toBBOX()
+ "&X=" + e.xy.x
+ "&Y=" + e.xy.y
+ "&INFO_FORMAT=text/html"
+ "&QUERY_LAYERS=prototype:Primary"
+ "&LAYERS=prototype:Primary"
+ "&FEATURE_COUNT=33"
+ "&SRS=EPSG:4326"
+ "&STYLES="
+ "&WIDTH=" + map.size.w
+ "&HEIGHT=" + map.size.h;
window.open(url,
"getfeatureinfo",
"location=0,status=0,scrollbars=1,width=600,height=150"
);
});------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Geoserver-users mailing list Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users