Comments (3)
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.
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.
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)
- Change the colour of the first X meters of the track HOT 1
- get_elevation_data() return empty Array HOT 2
- Empty waypoints at each end of the displayed track HOT 1
- iconSize ignored when using startIconUrl HOT 1
- Get latLng HOT 3
- Typescript error HOT 7
- Question: can I get a timestamp from mouseover on gpx track HOT 3
- Multiple gpx files: map fits only on the last GPX HOT 6
- Make gpx tracks clickable HOT 3
- Lazy loading large GPX track only when layer is enabled HOT 3
- group data and control display by years HOT 1
- GPX data seems consistently offset to the north HOT 7
- Module version of the plugin? HOT 5
- Change url and update track HOT 1
- ES Module HOT 2
- Simple example from README does not work. HOT 1
- Accessing waypoints HOT 3
- Cannot disable startIcon or endIcon HOT 1
- Cannot read properties of null (reading 'toFixed')
- Uncaught TypeError: options.icon.slice is not a function: `new L.AwesomeMarkers.icon` do not work on startIcon and endIcon HOT 4
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-gpx.