Git Product home page Git Product logo

Comments (3)

mpetazzoni avatar mpetazzoni commented on September 21, 2024

Very good points. Overloading onAdd(map) would definitely solve the issue, but in terms of "API" for L.GPX I like the fact that you can "prepare" your layer by creating it (var gpx = L.GPX(data);), and eventually use some of the methods it provides, before adding it to a map instance of your choice. It feels weird to be that parsing/loading the data is somehow tied to adding the layer to the map.

I guess another solution is to overload addTo(map) but for different reasons: when adding to the map, we could check if the data has been loaded already and fire the loaded event manually. This would cause the event to potentially be fired twice in most cases though.

from leaflet-gpx.

letmaik avatar letmaik commented on September 21, 2024

Maybe we should look at the behaviour of some existing layer classes within leaflet which also do asynchronous loading. I can think of the tile layers only at the moment, and these definitely only start loading once you add them to a map.

from leaflet-gpx.

jkufner avatar jkufner commented on September 21, 2024

Don't forget that JS is single threaded. On Load event cannot be processed until your code returns to event loop. Therefore the code is completely fine.

from leaflet-gpx.

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.