I have a service with about thousand points. I wish to enable the user to edit the attributes of the features.

Since there are so many points, I don't want to display them as a vector layer (using WFS Protocol) on the map. I am using a WMS layer to display it on the map.

Using a WMSGetFeatureInfo control, I am getting the attributes of a selected point and showing them in a form to the user.

How can I now save the edited attributes to the database? Is there some other way of achieving it?

  • Are you just looking for WFS-T (transactional)? Something like gistutor.com/openlayers/22-advanced-openlayers-tutorials/…
    – BradHards
    Oct 12 '12 at 6:11
  • @BradHards I am not sure that your link helps. I do know how to use a WFS-T layer; I don't want to use it in my map, because my layer has 1000's of points. If I add that layer to my map, the map becomes heavy because all the points are loaded into memory. Oct 12 '12 at 6:51

One possible workaround could be to pull only the selected point as a feature in an additional layer. For instance, after the user selected a point in the WMS throuhgh the WMSGetFeatureInfo control, add a WFS-T layer that only contains the selected point, and remove it again after editing it. Then you only need o display one point at a time in a vector layer.

You can instantiate the map with a Vector layer, which has a filter, like this:

//selected consumers being shown as Vector (WFS) layer
saveStrategy = new OpenLayers.Strategy.Save({auto:false});
saveStrategy.events.register('success', saveStrategy, onDataSuccesfullySaved);
saveStrategy.events.register('fail', saveStrategy, onDataSaveFail);

QueryFilter=new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.EQUAL_TO,
        property: "customerid",
        value: "-1"

wfslayer = new OpenLayers.Layer.Vector("WFS", 
            strategies: [new OpenLayers.Strategy.BBOX(),  saveStrategy],
            protocol: new OpenLayers.Protocol.WFS({
                      url:  "http://localhost:8080/geoserver/Test/wfs",
                      featureType: "consumers",
                      featureNS: "http://www.example.com/Test",
                      srsName: "EPSG:4326",
                      version: "1.1.0",

Include the following function to update the filter:

//function to set the wmslayer with the new filter
function SetFilter(id)
        //now Force refesh the vector layer
        wfslayer.refresh({force: true}); 

You can change the subset, by calling the SetFilter function, with particular customerid, like this:

SetFilter(26570); or 


If your data is stored in a database (such as PostGIS), you could also consider writing a PHP script that updates the feature attribute table based on the feature ID you get from the WMSGetFeatureInfo request.

  • I followed your first suggestion. I'll edit your answer to contain the code. Oct 15 '12 at 8:23

I don't know how to code it from scratch but OpenGeo Suite's GeoExplorer supports that.

GeoExplorer is a browser-based interface for composing and publishing web-mapping applications.

Using the latest version of GeoExplorer you can also style your GeoServer layers and edit the data-sources underneath them.

enter image description here

Just point GeoExplorer to your WMS server, log-in and then start editing.

enter image description here

I hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.