[OpenLayers-Users] Layer.addFeatures displays Point but can't
get saved, why? [SOLVED]
Simon Appelt
flansch at gmx.de
Fri Feb 18 17:34:05 EST 2011
Thanks to Diego, for support.
Step 4 Code which is working for me looks like this:
function Centroid(feature){
var point = feature.geometry.getCentroid();
var features = [new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(point.x, point.y))];
features[0].state = OpenLayers.State.INSERT;
wfs_punkte.addFeatures(features);
savePoint.save(features);
}
Thanks and gn8 ;)
Simon
Am 18.02.2011 19:42, schrieb Simon Appelt:
> Dear List,
>
> i've a problem with my wfs point Layer which cannot be saved, because
> the POST-Event empty . First of all here ist what i've done so far:
>
> 1. Created a saveStrategy:
> var savePoint = new OpenLayers.Strategy.Save();
>
> 2. Created my wfs point layer:
> var wfs_punkte = new OpenLayers.Layer.Vector("test",{styleMap:
> layerStyle,
> strategies: [ new OpenLayers.Strategy.Fixed(),savePoint],
> protocol: new OpenLayers.Protocol.WFS({
> version: "1.1.0",
> srsName: "EPSG:900913",
> url: "http://localhost/geoserver/wfs",
> featureNS : "http://www.maptags.de",
> featurePrefix: "ma",
> featureType: "ma_punkte",
> geometryName: "the_geom",
> schema:
> "http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=ma:ma_punkte"
> })
> });
>
> 3. Created a polygon draw function:
> var drawControl = new OpenLayers.Control.DrawFeature(wfs_flaechen,
> OpenLayers.Handler.Polygon,
> {
> handlerOptions: {multi: true},
> featureAdded: Centroid
> });
> mapk.addControl(drawControl);
>
> 4. The Centroid function which gets called:
> function Centroid(feature){
> var cent = feature.geometry.getCentroid();
> var point = new OpenLayers.Geometry.Point(cent.x, cent.y);
> wfs_punkte.addFeatures([new OpenLayers.Feature.Vector(point)]);
> savePoint.save();
> }
>
> The Point is displayed correct at my map and FireBug reports me a
> POST-Event, but its empty no Point geometry added to the XML:
> <wfs:transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
> version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
> http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></wfs:transaction>
>
> Any Ideas? Thanks a lot!
> Simon
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
More information about the Users
mailing list