[Users] FeatureStore/Layer synch?
White, Gary D. [OS-US]
GARY.D.WHITE at saic.com
Fri Nov 27 20:52:43 CET 2009
I'm a total newbie to GeoExt/OpenLayers/ExtJS and am trying to
understand the relationship (if any) between
OpenLayers.Feature.Vector.attributes and
GeoExt.data.FeatureRecord.fields.
I've added a point-drawing GeoExt.Action to the map in the
http://dev.geoext.org/trunk/geoext/examples/feature-grid.html example
with the following snippet:
action = new GeoExt.Action({
text: "draw point",
control: new OpenLayers.Control.DrawFeature(
vecLayer, OpenLayers.Handler.Point,
{
eventListeners: {
featureadded: function(evt) {
//evt.feature.attributes.long =
evt.feature.geometry.x;
//evt.feature.attributes.lat =
evt.feature.geometry.y;
}
}
}
), ...
And changed the FeatureStore & GridPanel configuration as follows:
// create feature store, binding it to the vector layer
store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
{name: 'lat', type: 'float'},
{name: 'long', type: 'float'}
],
autoLoad: false,
listeners : {
add: function(thisStore, records, index) {
for ( var i = 0; i < records.length; i++ ) {
var data = records[i].data;
data.long = data.feature.geometry.x;
data.lat = data.feature.geometry.y;
}
}
}
});
// create grid panel configured with feature store
gridPanel = new Ext.grid.GridPanel({
title: "Feature Grid",
region: "east",
store: store,
width: 400,
columns: [{
header: "Latitude",
width: 200,
dataIndex: "lat"
}, {
header: "Longitude",
width: 200,
dataIndex: "long"
}],
sm: new GeoExt.grid.FeatureSelectionModel()
});
My goal is to have the lat/long for each point feature added as fields
upon creation (along with some other data TBD later) and have these
fields synched between the appropriate GeoExt and OpenLayers
objects/properties. My first attempt (unsuccessful) was to do this in
the featureadded event listener in the OpenLayers.Control.DrawFeature
constructor (see commented lines above). I then tried doing this in the
GeoExt.data.FeatureStore add listener (also above). The lat/long coords
showed up in the grid but I didn't see where they were getting synched
back to OL.
Am I missing some fundamental understanding of what the
GeoExt.data.FeatureRecord.fields analog is in OL or possibly just
misunderstanding the synchronization aspect (or something else
entirely)?
BTW, great work guys.
Any help is greatly appreciated.
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20091127/abcab918/attachment.htm
More information about the Users
mailing list