Just to correct my previous post,<br><br>features on OpenLayers.Control.GetFeature is a JS Object with the currently selected features.<br><br>feature on event "featureselected" is the selected feature that triggered the event.<br>
<br>The GetFeature control will set the property features with the features selected during runtime. As I understand it, you should only preset it if you want some features preselected.<br><br>I think you should do this:<br>
<br>control = new OpenLayers.Control.GetFeature(...);<br>map.addControl(control);<br><br>and replace what you are calling "map.someobject" by "control.features".<br><br>Is it clear? Or did I mess up? hehe :P<br>
<br>Hope you understand...<br><br>Cheers,<br>Pedro.<br><br><div class="gmail_quote">On Wed, Nov 18, 2009 at 12:08 PM, Pedro Baracho <span dir="ltr"><<a href="mailto:pedropbaracho@gmail.com">pedropbaracho@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I think features is a property of the event featureselected.<br><br>what you should do is:<br>
map.someevent.somelayer.<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
events.register("featureselected", this,<br>
function(e) {<br></div>
map.someobject = e.feature;<br>
console.log(map.someobject);<br>
}</blockquote><br>or map.someobject.push(e.feature) in case of an array.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Nov 18, 2009 at 5:18 AM, Dragan Podvezanec <span dir="ltr"><<a href="mailto:dragan.podvezanec@gmail.com" target="_blank">dragan.podvezanec@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi all.<br>
<br>
If I understood documentation right, "features" property in GetFeature<br>
Control should fill an object with selected features. I don't know why, but<br>
I get nothing:<br>
<br>
map.someobject = {};<br>
<br>
map.someevent.somelayer = new OpenLayers.Control.GetFeature({<br>
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(map.somelayer,{<br>
geometryName: geometry,<br>
srsName: "EPSG:900913"<br>
}),<br>
hover: false,<br>
features:<br>
map.someobject<br>
});<br>
<br>
map.someevent.somelayer.events.register("featureselected", this,<br>
function(e) {<br>
console.log(e.feature);<br>
console.log(map.someobject);<br>
});<br>
<br>
When I click on layer, I see in console log e.feature, and it's ok, but<br>
map.someobject is an empty object. What am I doing wrong here ?<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n2.nabble.com/GetFeatures-features-property-tp4023776p4023776.html" target="_blank">http://n2.nabble.com/GetFeatures-features-property-tp4023776p4023776.html</a><br>
Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>