[OpenLayers-Users] Highlight features in WMS Layer
Phil Scadden
p.scadden at gns.cri.nz
Wed Oct 10 15:38:09 PDT 2012
> control: new OpenLayers.Control.SLDSelect(
> OpenLayers.Handler.Polygon, {
> displayClass: 'olControlSLDSelectPolygon',
> layers: features,
"features" need to be layer you are doing the select on - it should be a
WMS layer since SLDSelect works on WMS layers.
> eventListeners: {
> "selected": function (evt) {
> //features.removeFeatures();
> var pfilter = new OpenLayers.Filter.Spatial({
> type: OpenLayers.Filter.Spatial.INTERSECTS,
> value: evt.feature.geometry
> });
> var propNames = [];
This isnt used yet I notice. If you call wfsProtocol.read without
propertyNames specified, it will return features in GML, negating the
point of using SLDSelect. You need to specify which attributes you want
back.
> //var layerNode = getLayerNode(combo.value);
> var layerNode = tree.getSelectionModel().getSelectedNode();
> if (layerNode !== null) {
> wfsProtocol = new
> OpenLayers.Protocol.WFS.fromWMSLayer(layerNode.layer);
> wfsProtocol.read({
> filter: pfilter,
> callback: processSpatialQuery,
> scope: new OpenLayers.Strategy.BBOX()
> });
> features.removeAllFeatures();
This is implies "features" is a vector drawing layer. Since SLDSelect is
doing the drawing, this isnt necessary
> } else {
> alert("Please select a Map Layer");
> features.removeAllFeatures();
> }
> }
> }
> })
I would get SLDSelect working first, then get the WFS fetch of
attributes. Firebug tells you errors, but you should be checking what
request it is sending to Geoserver and what the response looks like.
From memory, you are using geoserver so I think you will also need to
convert the polygon from map coordinates to native coordinates.
Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
More information about the Users
mailing list