[OpenLayers-Users] wfs-t
chris Wild
chrismwild at gmail.com
Wed Apr 29 20:40:13 EDT 2009
Hi Chris,
Having trouble figuring out how to adapt the example from a new vector to
existing layer.
tried this
wfs = new OpenLayers.Layer.Vector("Editable Features", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
projection: new OpenLayers.Projection("EPSG:27200"),
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
srsName: "EPSG:27200",
url: "http://localhost:8080/geoserver/wfs",
typename: 'topp:ttlines',
featureNS : 'http://www.openplans.org/topp',
featureType: "restricted",
geometryName: "the_geom",
schema: "
http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted
"
})
});
But not correct, any suggestions or pointer to examples using existing
layer.
Thanks
Chris
On Thu, Apr 30, 2009 at 10:01 AM, Christopher Schmidt <
crschmidt at metacarta.com> wrote:
> On Thu, Apr 30, 2009 at 09:36:37AM +1200, chris Wild wrote:
> > Thanks for speedy reply, much appreciated.
> > That example works with a new vector layer, with trunck/2.8-rc1 will I be
> > able to edit/add existing features in a geodatabase?
>
> Yes. The "new vector layer" has a strategy and protocol which tells it
> "Go download data from this remote server" -- instead of having a
> different layer subclass, you have the ability to mix and match how, and
> when, to download and upload data. Just because it says "Layer.Vector"
> does not mean that the data is only added manually anymore. (This ain't
> your daddy's <s>Oldsmobile</s> OpenLayers.)
>
> -- Chris
>
>
>
> > On Thu, Apr 30, 2009 at 9:28 AM, Christopher Schmidt <
> > crschmidt at metacarta.com> wrote:
> >
> > > On Thu, Apr 30, 2009 at 08:46:16AM +1200, chris Wild wrote:
> > > > Hi all,
> > > > Can someone please tell me whats missing from my code to get WFS-t to
> > > commit
> > > > changes.
> > > > The demo works fine and my example works fine up to saving changes to
> > > file
> > > > when an extra line is added.The data is added from postgreSQl
> database
> > > with
> > > > PostGIS.
> > >
> > >
> > > The Layer.WFS pobably will not work to save changes to a server. Look
> at
> > > http://openlayers.org/dev/examples/wfs-protocol-transactions.html
> > > instead. (Needs trunk/2.8-rc1)
> > > > var roads = new OpenLayers.Layer.WFS(
> > > > "Track",
> > > > "/geoserver/wfs",
> > > > {typename: 'topp:ttlines'},
> > > > {
> > > > typename: 'topp:ttlines',
> > > > featureNS: 'http://www.openplans.org/topp',
> > > > extractAttributes: false
> > > > }
> > > > );
> > > > roads.style = OpenLayers.Util.applyDefaults({strokeColor:
> > > > "#ff0000"},
> > > > OpenLayers.Feature.Vector.style["default"]);
> > > >
> > > > map.addLayers([tiled, untiled, roads]);
> > > >
> > > > var panel = new OpenLayers.Control.Panel(
> > > > {displayClass: 'olControlEditingToolbar'}
> > > > );
> > > >
> > > > var drawLine = new OpenLayers.Control.DrawFeature(
> > > > roads, OpenLayers.Handler.Path,
> > > > {displayClass: 'olControlDrawFeaturePath'}
> > > > );
> > > > drawLine.featureAdded = function(feature) {
> > > > feature.layer.eraseFeatures([feature]);
> > > > // cast to multilinestring
> > > > feature.geometry = new
> > > OpenLayers.Geometry.MultiLineString(
> > > > feature.geometry
> > > > );
> > > > feature.style.strokeColor = "#ff0000";
> > > > feature.state = OpenLayers.State.INSERT;
> > > > feature.layer.drawFeature(feature);
> > > > }
> > > >
> > > > panel.addControls(
> > > > [new OpenLayers.Control.Navigation(), drawLine]
> > > > );
> > > > map.addControl(panel);
> > > > map.addControl(new OpenLayers.Control.LayerSwitcher());
> > > > map.zoomToExtent(
> > > > new OpenLayers.Bounds(2629421.7940751617,
> > > 6192776.755018141,
> > > > 2633541.55790017, 6195366.924973875)
> > > > );
> > > > }
> > > > </script>
> > > > </head>
> > > > <body onload="init()">
> > > > <h3>OpenLayers WFS-T demo: Tasmania cities and roads</h3>
> > > > <a href="#" onclick="map.layers[2].commit();return false">Save
> > > Roads</a>
> > > > <div id="map"></div>
> > > > </body>
> > > > </html>
> > > >
> > > > Many Thanks
> > > > Chris
> > >
> > > > _______________________________________________
> > > > Users mailing list
> > > > Users at openlayers.org
> > > > http://openlayers.org/mailman/listinfo/users
> > >
> > >
> > > --
> > > Christopher Schmidt
> > > MetaCarta
> > >
>
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090430/8958ba93/attachment.html
More information about the Users
mailing list