Ok so I made the following changes,<div><br></div><div><div>control: new OpenLayers.Control.SLDSelect(</div><div>OpenLayers.Handler.Polygon, {</div><div> displayClass: 'olControlSLDSelectPolygon',</div><div> layers: [pima, states],</div>
<div><br></div><div>Assigned the layers to the SLD. Which I did not want it to be hardcoded.</div><div><br></div><div> eventListeners: {</div><div> "selected": function (evt) {</div><div> //features.removeFeatures();</div>
<div> var pfilter = new OpenLayers.Filter.Spatial({</div><div> type: OpenLayers.Filter.Spatial.INTERSECTS,</div><div> value: evt.feature.geometry</div><div><br></div><div>I am facing a problem over here as Firebug is giving an error,</div>
<div><br></div><div><font color="#ff0000">evt.feature is undefined</font></div><div><br></div><div>How do I collect the geometry now?</div><div><br></div><div> });</div><div> var propNames = [];</div>
<div><br></div><div>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?</div>
<div><br></div><div> //var layerNode = getLayerNode(combo.value);</div><div> var layerNode = tree.getSelectionModel().getSelectedNode();</div><div> if (layerNode !== null) {</div><div> wfsProtocol = new OpenLayers.Protocol.WFS.fromWMSLayer(layerNode.layer);</div>
<div> wfsProtocol.read({</div><div> filter: pfilter,</div><div> callback: processSpatialQuery,</div><div> scope: new OpenLayers.Strategy.BBOX()</div>
<div> });</div><div> </div><div> } else {</div><div> alert("Please select a Map Layer");</div><div> </div><div> }</div><div> }</div>
<div> }</div><div>})</div><br><div class="gmail_quote">On Wed, Oct 10, 2012 at 3:38 PM, Phil Scadden <span dir="ltr"><<a href="mailto:p.scadden@gns.cri.nz" target="_blank">p.scadden@gns.cri.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
> control: new OpenLayers.Control.SLDSelect(<br>
> OpenLayers.Handler.Polygon, {<br>
> displayClass: 'olControlSLDSelectPolygon',<br>
> layers: features,<br>
<br>
</div>"features" need to be layer you are doing the select on - it should be a<br>
WMS layer since SLDSelect works on WMS layers.<br>
<div class="im"><br>
> eventListeners: {<br>
> "selected": function (evt) {<br>
> //features.removeFeatures();<br>
> var pfilter = new OpenLayers.Filter.Spatial({<br>
> type: OpenLayers.Filter.Spatial.INTERSECTS,<br>
> value: evt.feature.geometry<br>
> });<br>
<br>
> var propNames = [];<br>
</div>This isnt used yet I notice. If you call wfsProtocol.read without<br>
propertyNames specified, it will return features in GML, negating the<br>
point of using SLDSelect. You need to specify which attributes you want<br>
back.<br>
<div class="im">> //var layerNode = getLayerNode(combo.value);<br>
> var layerNode = tree.getSelectionModel().getSelectedNode();<br>
> if (layerNode !== null) {<br>
> wfsProtocol = new<br>
> OpenLayers.Protocol.WFS.fromWMSLayer(layerNode.layer);<br>
> wfsProtocol.read({<br>
> filter: pfilter,<br>
> callback: processSpatialQuery,<br>
> scope: new OpenLayers.Strategy.BBOX()<br>
> });<br>
<br>
> features.removeAllFeatures();<br>
</div>This is implies "features" is a vector drawing layer. Since SLDSelect is<br>
doing the drawing, this isnt necessary<br>
<div class="im">> } else {<br>
> alert("Please select a Map Layer");<br>
> features.removeAllFeatures();<br>
> }<br>
> }<br>
> }<br>
> })<br>
<br>
</div>I would get SLDSelect working first, then get the WFS fetch of<br>
attributes. Firebug tells you errors, but you should be checking what<br>
request it is sending to Geoserver and what the response looks like.<br>
From memory, you are using geoserver so I think you will also need to<br>
convert the polygon from map coordinates to native coordinates.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
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.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks & Regards<div>Smaran Harihar</div><br>
</div>