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 have my map code in openlayers JS. My input data is in a text file and I am able to render the points on the map. I have to give the user a right to create a layer by entering the data in a form. Writing a program to insert data into a text file is trivial. But I am stuck at how to include this layers code in the JS programmatically so that after giving the layers details in the form if the user reloads the page then the new layer should be visible, Any solutions??

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You haven't specified what technology you are using on your server-side (if you have a server-side application). If you are running the app on a Web server, then instead of writing to a file the user-entered data is usually stored in a user session on the Web server.

Basic workflow:

  1. User enters the data in a form.
  2. After clicking the "Submit" button, the data is processed by the Web server and stored in that user's session.
  3. The code that generates the HTML + JS for the OpenLayers map should check to see if the user has any of its own data in the session. If she has, the server code generates extra JS code which fills OpenLayers with that data.

There are other possible workflows (like using AJAX to increase interactivity), but I guess this is the easiest one.

share|improve this answer
    
But I am planning to store values in a dB and server them using geoserver WMS, then I have to manually publish new layer in geoserver and add code to the JS. Is there any automated/programmatic way to do this? –  Vikash Talanki Jun 8 '11 at 4:20
1  
Well you didn't mention anything about GeoServer and you didn't tag the question as such. I suggest you amend the question and wait for someone with GeoServer knowledge to answer you. –  Igor Brejc Jun 8 '11 at 5:58

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.