I have created a basic web map and implemented leaflet.draw functionality to it. What I would like to do is allow anyone that visits the web map to use the draw tools to add a marker (point) and when they add that marker a popup would appear allowing them to fill in per-determined fields that pertain to that point, this data would then be saved to an existing geojson file.
Is there a leaflet plugin / some other js wizardy out there that can make this happen?
Answer
You need to research this better, this question has been asked before. You have two issues, when someone visits your site the data is downloaded to your browser, any edits would be client side and not on the server. If you could write to a file and post it to the server, you would have issues of multiple people editing at once and not being in sync. Just imagine someone deleting all the data and posting the empty file back or posting a file with a virus. This concept is a bad idea.
The preferred way is to have a database on a server that you can update records, this requires the web Database and web Services or REST services to serve the data and your page to display it. You would then use an AJAX call to post your updates to the database. Popular methods would be to use PHP, NODE, Python, or others to create the services you need to communicate with your database.
Instead of a popup you could use a sidebar and have the HTML input and buttons coded to insert the data to a new record. Grab the X,Y coords from the mouse click and you have everything for your database.
This answer is very general but your question was not specific and there was no code to troubleshoot. For now this should help you focus your Google searches.
No comments:
Post a Comment