Giter Site home page Giter Site logo

Comments (8)

Starefossen avatar Starefossen commented on August 20, 2024

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.

jacobtoye avatar jacobtoye commented on August 20, 2024

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.

Starefossen avatar Starefossen commented on August 20, 2024

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.

 avatar commented on August 20, 2024

@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.

 avatar commented on August 20, 2024

I found some useful comments which are much better arguments than what my project calls for.

from leaflet.draw.

jacobtoye avatar jacobtoye commented on August 20, 2024

@mourner are you still thinking that the Feature.toGeoJSON() should be in Leaflet.draw?

from leaflet.draw.

 avatar commented on August 20, 2024

@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.

mourner avatar mourner commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.