I'm new to Extjs4.2/OL/Geoext2 developing, and I'm confused about how it should work.
--- edit ---
I'm trying to write a small app to read GeoJSON, place read features on the map, let the user to edit them / draw new ones, and finally save them back to GeoJSON.
My current approach: OpenLayers.Layer.Vector is bound to Geoext.data.FeatureStore. Layer reads GeoJSON, and FeatureStore is populated.
And now my question - how to save the modified by user data to GeoJSON? I can save the data as JSON by FeatureStore, but I don't see an easy way to make FetureStore save GeoJSON. Should I use vector layer to save GeoJSON, or try to add some type of conversion to add geometry attributes of the features to FeatureStore, and then sync() the store?
--- edit ---
Already done this by inserting another attribute to the model:
{
name: 'geom',
convert: function(value, record) {
return record.raw.geometry.toString();
}
}
Now my FeatureStore saves GeoJSON-like output with geometry, which is ok for me.
Question: Is it the right way to do this?
Regards, Pawel
I'm not an expert, but I think GeoExt.data.FeatureStore was created to be synchronized with the layer. So, if you do a
store.sync()no update request will be sent to your remote GeoJSON data source. GeoExt.data.FeatureStore constructor starts by creating aproxy: { type: 'memory', ...and thus your original proxy will be replaced by this one. To use the GeoExt.data.FeatureStore you have to rewrite it.So, I think the best way to do this is to use a OpenLayers.Protocol.Script source, which is quite flexible, configured to use your remote GeoJSON source. Using the layer's save strategy, all updates will be sent to the remote source.
Regards!