[OpenLayers-Users] Control.GetFeature
Ivan Grcic
igrcic at gmail.com
Mon Nov 30 08:04:54 EST 2009
Hi,
On Mon, Nov 30, 2009 at 10:14 AM, Andreas Hocevar <ahocevar at opengeo.org> wrote:
> 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.
>
Well using JSON is much more lightweight then using GML, that is,
transfered size in data is several times smaller.
Where was a little error, it shoud say:
readFormat: new OpenLayers.Format.GeoJSON(),
outputFormat: "JSON",
That should work,
cheers
> 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.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Ivan Grcic
More information about the Users
mailing list