If you are going to be creating valid GeoJSON from geoDjango then just use the 
OpenLayers.Format.GeoJSON format reader. If you are just getting JSON with some 
non-GeoJSON mix of attributes and geo properties, then you will need to write a 
function to parse the output of OpenLayers.Format.JSON into OpenLayers.Feature 
objects. The best practice in that case would be to actually sub-class the 
OpenLayers.Format.JSON parser into your custom parser, but you could also just 
do that function in your application logic.

To handle requests to the server, I would recommend using a 
GeoExt.data.FeatureStore with a GeoExt.data.ProtocolProxy created from an 
OpenLayers.Layer.Vector with an HTTP protocol. Here is an example:

var vectorLyr = new OpenLayers.Layer.Vector('layer',{
protocol: new OpenLayers.Protocol.HTTP({
                  url: 'http://myserver.com/geo',
                  format: new OpenLayers.Format.GeoJSON()
              })
});

var featStore = new GeoExt.data.FeatureStore({
fields:['foo',{name:'bar',type:'int'}],
proxy:new GeoExt.data.ProtocolProxy({protocol:vectorLyr.protocol})
});

now you can hook the feature store up to a grid or other data view, etc... 
You can use normal Ext.data.Store load methods and options to update the store 
or you can go the other way and use an OpenLayers.Strategy within the vector 
layer to have it reload itself at appropriate times.

Matt Priour


From: Andrew Parker 
Sent: Thursday, February 03, 2011 7:56 AM
To: [email protected] 
Subject: [Users] Best way to enter feature properties using a json server 
backend?


Hello Mike:

I am planning to do the same thing as you, however, you are a month 
ahead of me.  My initial plan is to use geodjango to obtain attribute 
data from a postGIS database and feed it back to GeoEXT/OpenLayers via JSON.

I do not yet know how to do this but I thought this may give you some 
ideas how to proceed.  Perhaps we can work together to figure this out?

-- 
Andrew Parker
Source3 Computing, LLC



_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to