-
Notifications
You must be signed in to change notification settings - Fork 958
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
Rewrite map layer #670
Comments
We could also use this Uber library, using WebGL: Thanks @martindaniel4 for pointing that out! |
If you're after performance drawing GeoJSON, I've also seen Mapbox's WebGL renderer do pretty well www.mapbox.com/mapbox-gl-js/api/ - you can easily get it to do things like "here's a URL for a geojson file with shapes of 90k buildings, please draw it" e.g. https://maarouf.me/athena-buildings/ Actually I think in the current version the animated exchange arrows use most of the CPU... |
We should probably do some serious investigating but the memory usage definitely comes from loading all the polygons in (SVG) memory.. |
I believe mapbox-gl-js is the solution to build high performant vector maps. Also, Mapbox provide all the tooling to build a map, for example they provide Mapbox studio which allow you to completely design the map. The nice thing is that all the rendering of the vector tiles happen on web workers on the client so it doesn't block the UI. I actually wrote a wrapper on top of mapbox-gl-js for a better integration in a React application and built monumap with it. The only downside of using Mapbox for an OSS project is the limitation of 50 000 views / months for a free plan. An alternative solution for not having to pay would be to install a vector tiles server with OSM data and use Tangram as a client library to display the vector tiles. |
@alex3165 what about deck.gl? |
I don't know if you can use deck.gl as a standalone library I thought it was meant to be used with react-map-gl which is based on mapbox-gl-js. If you could use it independently it seems like deck.gl already provide a set of layers which might not fit your need but again I don't know enough about deck.gl to state on this point. I believe there is a way to display a simple vector map as the one used for electricitymap in webgl but I don't think you can go with libraries like mapbox-gl-js or tangram without vector tiles server and I am not yet sure how you can achieve it. Although I don't think there is much overhead of creating your own vector tiles server with solutions like tileserver-gl. Looking at the readme it seems that they have a dockerfile you can probably just deploy on a box somewhere and you can consume the vector tiles for free with mapbox-gl-js or tangram. I am not sure how you can use mapbox studio to customise your map in this case. |
After further thinking you might be able to use mapbox-gl-js without server and just pass a static geojson of the frontiers, need to be proved, I will check this when I have some time. |
Thanks man! I will dig into that.
…On Thu, Sep 21, 2017 at 11:20 AM, Alexandre ***@***.***> wrote:
After further thinking you might be able to use mapbox-gl-js without
server and just pass a static geojson of the frontiers, need to be proved,
I will check this when I have some time.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<electricitymaps/electricitymaps#670 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABlEKNe_KjnOtQRNqYYtKWnmRlLLOhtxks5skipbgaJpZM4OxS46>
.
|
I think deck-gl is the way to go |
Look like you can go with just mapbox-gl without server http://jsfiddle.net/gxfpbeme/ cf @Wykks |
Cool! Do we need an access token then? if we only use the client library? |
No, access token is only needed if you use their map service |
@alex3165 wrote a prototype here: Next steps as I see it:
@superlopuh I know you had the geoJSON files exported, can you send them here if you still have them? |
Is this in line with being able to customize geometries (even if grossly simplified - straight lines vs intricate borders along rivers) at some time in the future? For example - NY is going to need 3 geometries, while with NE-ISO we can take 6 states (NH, CT, RI, MA, ME & VT) and turn them into 1 common geometry. PJM will go from ~12 full/partial state geometries to 3 geometries covering the same ~12 state territory. |
@HansHyde yes |
@corradio - great! I'll keep moving forward on getting NorAm (mainly US states) in order. |
From the tests I have done on my old iPad:
The good news is that it doesn't change the code too much. I'll make sure to fit the wind/solar layers and test this thoroughly, but in principle it should help quite a bit. Kudos to @alex3165 for pushing me in the good direction by giving me a working mapbox-gl example. |
Updates:
|
@corradio you can use html markers for the arrows: https://www.mapbox.com/help/custom-markers-gl-js/ |
@alex3165 that's a very good idea - didn't know they provided such an API. Another thing, for further reference: |
Just tried it. When the map is dragged, the markers are lagging behind on slow machines. It's actually much worse performance than setting a transform on a div. Seems like performance scales linearly with the number of markers. |
Using the regular layer with animated GIFs, it seems that replacing with static PNGs removes 70% of the jitter. Seems like animating GIFs is heavy :( |
A good trick I'm doing and that seems to solve the problem is to hide the arrows while dragging 👍 |
Allright, he's a summary of today's work with potential solutions:
|
PR submitted here #958. |
This should speed up performances considerably.
A good strategy seems to use a big canvas (world), and then only draw parts of the canvas which correspond to the active screen. One could pre-draw the (invisible) surroundings to ensure smooth transition. Of course, we should remember what has been drawn in order not to redraw things.
We need a fast algorithm in order to detect mouseovers and clicks. https://github.com/d3/d3/blob/master/API.md#quadtrees-d3-quadtree could be used.
This would improve the drawing speed, but would not reduce the need to transfer, and load in memory, all geojson polygons.
We could generate tiles as GMaps does, but that would probably make mouse hit tests complicated, as we need the coordinates of zones. Moreover, it would complicate the interactivity use cases (change color of hovered zone etc..)
The text was updated successfully, but these errors were encountered: