Comments (8)
This will greatly improve the general ease of use of Leaflet when storing features in some kind of database after they have been edited!
from leaflet.draw.
It would be great to have the ability to save features as GeoJSON. As to where it should live, I guess the only question is: would someone want to retrieve the GeoJSON from a feature that was added to the map by other means than Leaflet.draw.
E.g. would someone ever want to load features using GeoJSON then at some stage later want to use toGeoJSON
.
@tmcw @uberbuilder @diwu1989 what are your/your users use cases? What do you think?
from leaflet.draw.
Yes, if you want to send a leaflet feature over the network to some RES API service, ultimately saving it to a database. From a developer point of view the only thing you would need then is to go over the features you want to send, call .toGeoJSON() and start sending it rather then having to do the serializing yourself.
from leaflet.draw.
@jacobtoye Well, in my app we're bringing in data from a google spreadsheet example For the purpose of this app we want to allow the end client the ability to easily manage their data and allow the source information for the map to automagically update. I'd like to have the "toGeoJSON" feature to be able to essentially "cache" a copy of the geoJSON object that I have worked so hard to build with javascript. Here is a list of reasons why you would want to do that. And why I think this should live in the core.
- Unit Testing
- Keep one good copy of the geoJSON for historical reasons (Keep a history of reports) another way to keep the data in a relatively portable format. I also cannot guarantee that the hack I'm using to get the information out of the google spreadsheets will always be around.
- Program development/bug hunting. If you have ways of massaging data after it comes out of the database (which happens on three of the pieces of data I'm using from this one). What happens if you feed it different results, how will it handle it? I cannot guarantee what the spreadsheet users will send me - and having this all in a geoJSON object which is portable is nice.
Okay, so literally as I'm writing this I am realizing that my geoJSON object isn't actually changing at all after I load the map. I can't think of any interactions which are changing my geoJSON object. The only interaction I can think of that happens would be counting how many times a particular layer gets clicked on - and this offers one way to track that, you could log it to the layers properties and then do a dump of the geoJSON object. But there are other ways to do this.
Okay, I retract my previous vote to have this placed in the core. I don't have any reason to have this in the core.
My apologies everyone. Stick it in draw :)
Am I missing something here? Are there any reasons the object changes after we draw it to the map that we would need to get back out. Any changes that happen to the object that only come from core code?
from leaflet.draw.
I found some useful comments which are much better arguments than what my project calls for.
from leaflet.draw.
@mourner are you still thinking that the Feature.toGeoJSON()
should be in Leaflet.draw?
from leaflet.draw.
@jacobtoye Here are some comments on a similar issue: 1369
I think it's safe to assume that there is enough interest in having the toGeoJSON feature in the core, that it should most likely be in the core. I've been back and forth on this same issue in my own mind and I can't find a happy medium.
This is really @mourner's call in my opinion, but I think it's time he just makes a call and let us all deal with it. If it were up to me I would put it in the core UNLESS there is some code that it would duplicate in the draw plugin at which case he would have to decide to keep the code in the draw plugin, or update the core - and update the draw plugin to work from the core implementation. I think talking about it more won't uncover any thing obvious and that it's best to just make a decision and move forward with that decision. I also don't know enough about the development of this library to really make an intelligent suggestion. I can only say what I think "feels" right. And that seams to change like the wind.
@mourner I'll support anything which way you go. π may the force be with you.
from leaflet.draw.
Yeah, looks like it should be in the core after reading all the feedback. Thanks everyone! See Leaflet/Leaflet#1462
from leaflet.draw.
Related Issues (20)
- Use the saved circle from the db and make it editable HOT 1
- Resizing in active edit mode
- Edit.Poly middle marker custom icon
- Rectangle and circle options documentation typo
- Using the Delete tool, the drawn layer cannot be deleted after the layer is overlaid
- Couldn't draw polygons/polylines using leaflet, leaflet.draw HOT 1
- TypeError: can't access property "falseFn", L.Util is undefined
- Add drawing markers to custom pane
- Cannot read properties of undefined (reading 'Poly') HOT 1
- Right click triggers `draw:drawvertex` event
- can't have delete without edit HOT 1
- Create polyline with some points non editable
- tooltips option on enableDraw() not working? HOT 1
- Programmatically set drawing mode / external toolbar
- εΎε±θ¦η HOT 2
- Impossible de modifier le cercle Leaflet
- Tool enabling disables text selection on the entire document HOT 1
- Drawing a rectangle using leaflet.draw library doesn't work (it throws error in console). HOT 1
- save/load leaflet.draw and use editing/delete buttons HOT 2
- MouseEvent.mozPressure is deprecated. MouseEvent.mozInputSource is deprecated.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.draw.