-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add asynchronous loading and removing functionality #38
Add asynchronous loading and removing functionality #38
Conversation
This is prerequisite PR for openstreetmap/openstreetmap-website#5009. If this PR is not merged, openstreetmap-website PR can't be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite surprised that it's adding and removing the features that is the slow part rather than parsing the XML to get them details but I guess it's because each feature is a separate layer... Seems it's really leaflet that needs to be faster and this is a somewhat ugly workaround :-(
leaflet-osm.js
Outdated
@@ -122,7 +123,12 @@ L.OSM.DataLayer = L.FeatureGroup.extend({ | |||
} | |||
} | |||
|
|||
layer.addTo(this); | |||
if (this.options.asynchronous) { | |||
setTimeout(() => layer.addTo(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentation here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation was updated
@tomhughes Thank you for review. I'll change indentation. Idea of this PR is to make rendering asynchronous as now it is freezing app and browser. Currently leaflet takes long time for rendering and deleting SVG elements (calculations done on OSM side are quite fast and doesn't take any noticeable time). To increase speed there will be needed changes in the leaflet. Even this PR overrides some of its functionalities (eachLayer, onAdd adnd onRemove) to make it asynchronous. |
Regarding XML parsing time, we also have JSON based endpoints which were helpful in other scenarios to speed up parsing in the browser. |
ccd0f53
to
d8561c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - that looks good now.
This PR addresses "Map Data checkbox: perhaps use toggle slider instead" issue mentioned in the openstreetmap/openstreetmap-website#4931
Several changes were made to the data loading functionality:
Connected to the PR openstreetmap/openstreetmap-website#5009
Fixes openstreetmap/openstreetmap-website#4931
Videos:
Render Video
OpenStreetMap.and.28.more.pages.-.Work.-.Microsoft.Edge.2024-07-20.16-55-01.mp4
Remove Video
OpenStreetMap.and.28.more.pages.-.Work.-.Microsoft.Edge.2024-07-20.16-56-42.mp4