[OpenLayers-Dev] Able to delete/ move feature and save it
without problems, but upon refreshing the data,
it is the same as before the delete/ move.
Christopher Schmidt
crschmidt at metacarta.com
Sun Mar 8 12:35:12 EDT 2009
On Sun, Mar 08, 2009 at 04:57:49PM +0200, Sunder Raj Abbai Naidoo wrote:
> Good Day Everyone
>
> I am busy working on a project that requires a feature to be added, moved and deleted. The "add feature" functionality works i.e. able to add a feature, save it and upon refresh the feature is displayed. The "move feature" functionality is able to move a feature and save without any bugs, but upon refreshing the data the feature is in the old location. The "delete feature" functionality is able to delete a feature and save without any bugs, but upon refreshing the data the feature is displayed. Below is the coding that I am using. Your help is appreciated.
OpenLayers 2.7's WFS-T support does not support modification or deletes.
This missing functionality will be fixed in your current code sometime
before the 2.8 release (#1787), but it is recommended to use the WFS
protocol for all access of this sort, which is already in trunk.
http://openlayers.org/dev/examples/wfs-protocol-transactions.html
> Definition of WFS
> var cities = new OpenLayers.Layer.WFS(
> "Cities",
> "http://10.128.78.27:8080/geoserver/wfs",
> {typename: topp:tasmania_cities'},
> {featureNS: http://www.openplans.org/topp',
> extractAttributes: true});
> cities.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
> OpenLayers.Feature.Vector.style["default"]);
>
> Defination of Add, Edit, Del, Save.
>
> function deleteFeature(geometry)
> {
> this.state = OpenLayers.State.DELETE;
> this.layer.removeFeatures(geometry);
> this.renderIntent = "select";
> }
>
> var drawPoint = new OpenLayers.Control.DrawFeature(
> cities, OpenLayers.Handler.Point,
> {displayClass: 'olControlAddFeaturePoint'});
> drawPoint.featureAdded = function(feature) {
> feature.layer.eraseFeatures([feature]);
> // cast to point
> feature.geometry = new OpenLayers.Geometry.MultiPoint(feature.geometry);
> feature.style.strokeColor = "#0000ff";
> feature.state = OpenLayers.State.INSERT;
> feature.layer.drawFeature(feature);
> }
>
> var edit = new OpenLayers.Control.ModifyFeature(cities,
> {title: "Modify Feature",
> displayClass: "olControlModifyFeature"});
>
> var save = new OpenLayers.Control.Button(
> {title: "Save Changes",
> trigger: OpenLayers.Function.bind(cities.commit, cities),
> displayClass: "olControlSaveFeatures"});
>
> var del = new OpenLayers.Control.SelectFeature(cities,
> {title: "Delete Feature",
> onSelect: deleteFeature,
> displayClass: "olControlDeleteFeature"});
>
>
> Kind Regards,
>
> Sunder Raj Abbai Naidoo
> Specialist: Analyst Programmer
> IT Consulting; Solution Delivery
> +27 (0)12 470 1584 (Office)
> +27 (0)12 470 1456 (Fax)
> +27 (0)83 461 3397 (Mobile)
>
>
>
> .
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
--
Christopher Schmidt
MetaCarta
More information about the Dev
mailing list