I have a map in which I'm trying to create the capabilities of adding new features and editing attributes of new and existing features. I have managed to make the feature editable but I want people to be able to add new points to the same GeoJSON and edit attributes but I am completely stuck. I'm new to using leaflet and GeoJSON so I'm having a hard time figuring out the issue. This is the code I have right now for editing features:

 var drawnItems = businessLayer;


 var drawControl = new L.Control.Draw({

     edit: {
         featureGroup: drawnItems

I tried using solutions find at the following link: https://stackoverflow.com/questions/32834401/edit-feature-attributes-in-leaflet

But I could not get it to work. I can post the rest of my code as well if that will help.

Anybody have any helpful links or insight that can help me resolve this issue?

  • 1
    Just to clarify, your writing to a database right? You wouldn't want them writing to a file on your Server. Right now they are drawing a shape in their browser (client) if you want them to be able to save it to your server, you need a database like MySQL or PostGIS, and you would have to write a REST/web service to insert it. PHP or Node are two easy to configure apps for the service. – Bill Chappell Mar 12 at 18:17
  • I was not. I was hoping they could write to a file on my server. This is my first time creating a Leaflet map so it sounds like I'm way off in how I should be doing this? – Jeanette Chamorro Mar 14 at 1:04
  • writing to a file is a security risk. Also imagine a few users trying to write to the same file at one time, for editing you need a database. Now you can put a GeoJSON on your server and use it in Leaflet. I do it for static data and save the database for dynamic data. – Bill Chappell Mar 14 at 1:35

Your Answer

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

Browse other questions tagged or ask your own question.