[OpenLayers-Users] WMSGetFeatureInfo selecting only filtered
eliments
Håvard Wahl Kongsgård
haavard.kongsgaard at gmail.com
Sun Aug 28 08:31:57 EDT 2011
Hi, when using OpenLayers.Control.WMSGetFeatureInfo instead of
map.events.register to get element. With WMSGetFeatureInfo is it
possible to restrict elements end users can selected to only filtered
elements?
The standard openlayer code in geoserver, uses map.events.register to
select only filtered elements. In the OpenLayers API it was not clear
if this was possible for WMSGetFeatureInfo?
----
Standard code in geoserver
// support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML =
"Loading... please wait...";
var params = {
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
SERVICE: "WMS",
VERSION: "1.1.1",
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
Layers: 'HUNT:eiendom_flate',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format,
styles: map.layers[0].params.STYLES,
srs: map.layers[0].params.SRS};
// merge filters
if(map.layers[0].params.CQL_FILTER != null) {
params.cql_filter = map.layers[0].params.CQL_FILTER;
}
if(map.layers[0].params.FILTER != null) {
params.filter = map.layers[0].params.FILTER;
}
if(map.layers[0].params.FEATUREID) {
params.featureid = map.layers[0].params.FEATUREID;
}
OpenLayers.loadURL("http://example.com/geoserver/wms", params, this,
setHTML, setHTML);
OpenLayers.Event.stop(e);
});
simple example select example with WMSGetFeatureInfo
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://something.com:8080/geoserver/wms',
title: 'Identify features by clicking',
layers: [tiled],
//hover:true,
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
//alert(event.text);
}
}
});
--
Håvard Wahl Kongsgård
More information about the Users
mailing list