Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.
  • I'm new in OpenLayers.
  • I have simple application, which use a picture as map,
  • on this picture users can add, move, or delte point, and then save.

  • I have implemented adding, moving, deleting functionalities, only except save.

  • codes are in below :

codes here

  • anyone who knows how to save change on server side? save to database, file?
share|improve this question
    
Repeated question? "How do I edit info feature attributes in geoserver with openlayer" (goo.gl/7GVbz) –  dariapra Nov 22 '12 at 11:29
add comment

2 Answers 2

I found a cool sample that illustrates the handling. Take a look at this (the source code :-D) http://edgemaster.dev.openstreetmap.org/oldemo/10.htm

Your vector layer needs a server part two handle the persistence. The save strategy only triggers the write back.

/* from the sample source */
var scribble = new OpenLayers.Layer.Vector("Scribble", {
    protocol: new OpenLayers.Protocol.HTTP({
        url: "featureserver/featureserver.cgi/scribble",
        format: new OpenLayers.Format.GeoJSON()
    }),
    strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Save({auto: true})],
    projection: wgs
});
map.addLayer(scribble);
share|improve this answer
    
hi, thank your replay firstly. I've tried whole day on this, current the source as in below: jsfiddle.net/7Mr7d/42 I can load data use protocol now, but still didn't try out how to save data, save function is triggered, but how to do next, any suggestion on this? –  lune Nov 23 '12 at 9:09
    
I know it can be implemented by sending a ajax request, but want to learn how to use openlayers –  lune Nov 23 '12 at 9:24
    
after adding saveStrategy to pointLayer, now the commit function can be triggered when clicking save button, source : jsfiddle.net/7Mr7d/43 how to send request in commit function using openlayers way? –  lune Nov 23 '12 at 9:51
    
I'm not sure if I'm right but imo if you add the right URL to your vector layer it automatic writes the data back. But you need a related server part. For instance a wfs server or a script that handles the request server side. The post from rashad give you some sample components for that –  OkieOth Nov 23 '12 at 10:25
add comment

What you are looking for is a WFS-T service. OpenLayers does support WFS, WFS-T and is based on ajax request because of javascript ion of OL. The steps are as follows:

Setup the following:

  1. PostgreSQL / PostGIS.
  2. WFS server - (Geoserver,MapServer,tinyOWS).
  3. WFS Client ofcourse, openlayers

tinyOWS is small and easy A full tutorial from start can be found here

share|improve this answer
    
actually I can place ajax codes in commit function to save data without WFS-T, just want to learn the way openlayers does –  lune Nov 23 '12 at 10:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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