[OpenLayers-Users] GetFeatures , features property...

Pedro Baracho pedropbaracho at gmail.com
Wed Nov 18 09:16:16 EST 2009


Just to correct my previous post,

features on OpenLayers.Control.GetFeature is a JS Object with the currently
selected features.

feature on event "featureselected" is the selected feature that triggered
the event.

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.

I think you should do this:

control = new OpenLayers.Control.GetFeature(...);
map.addControl(control);

and replace what you are calling "map.someobject" by "control.features".

Is it clear? Or did I mess up? hehe :P

Hope you understand...

Cheers,
Pedro.

On Wed, Nov 18, 2009 at 12:08 PM, Pedro Baracho <pedropbaracho at gmail.com>wrote:

> I think features is a property of the event featureselected.
>
> what you should do is:
> map.someevent.somelayer.
>>
>> events.register("featureselected", this,
>> function(e) {
>>                                                map.someobject = e.feature;
>>
>>  console.log(map.someobject);
>>                                                }
>
>
> or map.someobject.push(e.feature) in case of an array.
>
>
> On Wed, Nov 18, 2009 at 5:18 AM, Dragan Podvezanec <
> dragan.podvezanec at gmail.com> wrote:
>
>>
>> Hi all.
>>
>> If I understood documentation right, "features" property in GetFeature
>> Control should fill an object with selected features. I don't know why,
>> but
>> I get nothing:
>>
>> map.someobject = {};
>>
>> map.someevent.somelayer = new OpenLayers.Control.GetFeature({
>>                                                protocol:
>> OpenLayers.Protocol.WFS.fromWMSLayer(map.somelayer,{
>>                                                        geometryName:
>> geometry,
>>                                                        srsName:
>> "EPSG:900913"
>>                                                        }),
>>                                                        hover: false,
>>                                                        features:
>> map.someobject
>>                                                });
>>
>>
>>  map.someevent.somelayer.events.register("featureselected", this,
>> function(e) {
>>                                                console.log(e.feature);
>>
>>  console.log(map.someobject);
>>                                                });
>>
>> When I click on layer, I see in console log e.feature, and it's ok, but
>> map.someobject is an empty object. What am I doing wrong here ?
>> --
>> View this message in context:
>> http://n2.nabble.com/GetFeatures-features-property-tp4023776p4023776.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091118/939598ed/attachment.html


More information about the Users mailing list