[OpenLayers-Users] Highlight features in WMS Layer

Smaran Harihar smaran.harihar at gmail.com
Wed Oct 10 10:07:08 PDT 2012


Hi Phil,

I did add the SLDSelect function but I was able to draw the polygon but
nothing happens after that. This is my code,

control: new OpenLayers.Control.SLDSelect(
OpenLayers.Handler.Polygon, {
    displayClass: 'olControlSLDSelectPolygon',
    layers: features,
    eventListeners: {
        "selected": function (evt) {
            //features.removeFeatures();
            var pfilter = new OpenLayers.Filter.Spatial({
                type: OpenLayers.Filter.Spatial.INTERSECTS,
                value: evt.feature.geometry
            });
            var propNames = [];
            //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();
            } else {
                alert("Please select a Map Layer");
                features.removeAllFeatures();
            }
        }
    }
})

Just to make sure of one thing. When you added mylayer in layers, it was
you vector field right? The feature layer that I have added to the layers
is also my vector layer.

You can check the functioning here<http://128.196.142.12/geo/test/test1.html>.
Select the pima pine layer in the tree and Click on the draw poly tool in
the toolbar. Then draw you defined polygon on any of the blue stars. The
firebug is also not returning any errors.

Thanks,
Smaran

On Tue, Oct 9, 2012 at 1:20 PM, Phil Scadden <p.scadden at gns.cri.nz> wrote:

>
>
> Actually that is where I am confused. I am already using
> the OpenLayers.Handler.Polygon for the draw feature and I am not sure how
> or where to include the OpenLayers.Control.SLDSelect as it also needs the OpenLayers.Handler.Polygon,
> according to the example.
>
> You use SLDSelect instead of drawfeature.
>
> My code for using the SLD + WFS looks something like:
>
> sldCtrl = new OpenLayers.Control.SLDSelect(OpenLayers.Handler.Polygon,
>                                  {
>                                         displayClass:
> 'olControlSLDSelectPolygon',
>                                         layers:mylayer
>                                  });
>                 sldCtrl.events.register("selected", this, function(e){
>                       // application specific code to clean up popups etc,
> and populate propNames, plus fixup SRS in filter if needed goes here.
>                      // propNames ONLY contains desired attributes and
> does not include SHAPE
>                          wfsProtocol.read({  // wfsProtocol previous create
>                             filter: e.filters[0],
>                             propertyNames: propNames,
>                             callback: processSpatialQuery,
>                             scope: strategy
>                          });
>
>
> 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.
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>


-- 
Thanks & Regards
Smaran Harihar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121010/6d3701da/attachment-0001.html>


More information about the Users mailing list