3

I need to populate a ExtJS datagrid with a OpenLayers features. The official example http://geoext.github.io/geoext2/examples/grid/feature-grid.html doesn't help me, because the data is loaded from a JSON file, but I need the features parsed from a WFS layer.

Could anyone help me with a source code example (jsfiddle)?

3
  • Why no JSON? You can do nicely WFS requests and use JSON as output format.
    – g07kore
    Jul 14 '15 at 15:37
  • can you post your code
    – neogeomat
    Apr 28 '18 at 7:07
  • WFS data is stored as json object by openlayers so the example is still useful. post your code then we can help.
    – neogeomat
    Apr 28 '18 at 7:08
1

First of all I think you should load your wfs as a vector layer:

            var layer = new OpenLayers.Layer.Vector("WFS", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url:  "http://demo.opengeo.org/geoserver/wfs",
                    featureType: "tasmania_roads",
                    featureNS: "http://www.openplans.org/topp"
                })
            });

Then you'll have all attribute information available via layer.features[index].attributes for each feature. This way you can easily build an object to pass to the feature grid (ie, reproduce the example json) and customize which attributes you want to load in the feature store.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.