[OpenLayers-Users] Control.GetFeature

Andreas Hocevar ahocevar at opengeo.org
Mon Nov 30 04:14:35 EST 2009


Hi,

why are you forcing your format to JSON? And are you sure that your 
geometryName is "GEOM", not "the_geom"? Try to omit the readFormat and 
formatOptions properties.

Regards,
Andreas.

stash wrote:
>
> Ivan Grcic-2 wrote:
>   
>> OpenLayers.Protocol.WFS.fromWMSLayer is just convinient method for
>> creating OpenLayers.Protocol.WFS from allready defined WMS layer. So
>> you can just define protocol as:
>>
>> protocol: OpenLayers.Protocol.WFS({
>>             readFormat: new OpenLayers.Format.GeoJSON(),
>>             formatOptions: {
>>                 outputFormat: "JSON"
>>             },
>>             url: "http://localhost:8080/geoserver/wfs"
>>             featureType: "ftName",
>>             featurePrefix: 'prefix',
>>             featureNS: "http://ns",
>>             geometryName: 'geometry',
>>             maxFeatures: 100
>> })
>>
>>
>>     
>
> Hello,
> thanks for your post. I tried this but it doesn't work. Here is my code.
>
>
> var control = new OpenLayers.Control.GetFeature({
> protocol: OpenLayers.Protocol.WFS({
>             readFormat: new OpenLayers.Format.GeoJSON(),
>             formatOptions: {
>                 outputFormat: "JSON"
>             },
>             url: "http://localhost:8080/geoserver/wfs",
>             featureType: "MY_LAYER",
>             featurePrefix: 'topp',
>             featureNS: "http://www.openplans.org/topp",
>             geometryName: 'GEOM',
>             maxFeatures: 100,
>            defaultFilter: my_filter
>    })
>    });
>    
> control.events.register("featureselected", this, function(e) {
>     select.addFeatures([e.feature]);
> });
>
> map.addControl(control);
> control.activate();
>
> When I launch my app I get an error that feature.lenght is null or doesn't
> exist?
>
> Do I have to implement a map.events.register as I did it with my
> getfeatureinfo or is there something else wrong.
>
> Thanks for your help
>
> Regards
> stash
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list