[Users] [OpenLayers-Users] Highlight features in WMS Layer

Smaran Harihar smaran.harihar at gmail.com
Fri Oct 12 00:55:42 CEST 2012


Ok so I made the following changes,

control: new OpenLayers.Control.SLDSelect(
OpenLayers.Handler.Polygon, {
    displayClass: 'olControlSLDSelectPolygon',
    layers: [pima, states],

Assigned the layers to the SLD. Which I did not want it to be hardcoded.

    eventListeners: {
        "selected": function (evt) {
            //features.removeFeatures();
            var pfilter = new OpenLayers.Filter.Spatial({
                type: OpenLayers.Filter.Spatial.INTERSECTS,
                value: evt.feature.geometry

I am facing a problem over here as Firebug is giving an error,

evt.feature is undefined

How do I collect the geometry now?

            });
            var propNames = [];

The reason I placed a empty array was that previously I wanted to display
all the columns in the attribute table, and that is what it was doing. So
now if I want all the columns to be added do I need to add the names of all
the columns one by one?

            //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()
                });

            } else {
                alert("Please select a Map Layer");

            }
        }
    }
})

On Wed, Oct 10, 2012 at 3:38 PM, Phil Scadden <p.scadden at gns.cri.nz> wrote:

>
> > 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.
>
> _______________________________________________
> 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://www.geoext.org/pipermail/users/attachments/20121011/e97b93cd/attachment.htm 


More information about the Users mailing list