-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
In need for a native control for map symbols (map legend) #5203
Comments
Thanks for taking the time to open this issue. Also, if there is a plugin that does most of what you need I would recommend trying to add the missing functionality there or fork it if they are not responsive. |
I think you're asking for a generic legend control? In my experience, due to MapLibre's huge amount of configurability, it will be next to impossible to create something that would be generically useful. Maybe I'm wrong, and something could be created to cover some use cases? For one of the projects I am working on that utilizes MapLibre, I have created a layers control that also serves as a legend, but that legend is built dynamically at runtime using values from well-known vector tile layers. |
Hello @HarelM , sorry for not being clear, but basically Implementing natively something similar to the legend on the left side of the image. |
Exactly that. Well, probably it would be VERY challenging, maybe would be better to be around as a plugin rather than natively. But I perceive it as a fundamental resource. It seems to be implemented in OpenLayers (I also asked them guys in person haha) |
I think what it boils down to is the LOE required to build such a thing in a generic way is very high, whereas the time to throw a very simple "hard-coded" legend is very, very low, so nobody has taken the time to do it. Probably many would use such a thing if it existed though! I would have been happy to have had something to start from instead of basically beginning from scratch. What I ended up creating watches for tiles to load, queries layers for features as they are loaded, and provides legend symbols with counts for items as they come into view. What I wrote is an Angular component though, and it makes heavy use of RxJS, so unfortunately it's not something I would be able to contribute back to MapLibre. |
Yes, as I stated, noticing is always the first step. It might be as challenging as it is important, I'm not really into renderers, but if the renderer can render everything in a style schema, wouldn't it be able to replicate it once in small legend symbols (then maybe transformed into svg)? I can imagine this design: Every layer creates a collapsed entry that can be expanded (with a small arrow), default on the middle left side of the screen. |
Funny you mentioned SVG, as that is exactly what I did! It's not as simple as "replicating it once," for a few different reasons.
|
I started to implement a legend where you define a location and a legend item title, for every entry I created a small non injective map to show the place using the current style. |
Wow, thanks a lot for the technical explanation! |
Well, seems like plugins can in the end be the best way. Even tough I believe that one day proper map legends could be a highlight for MapLibre! |
User Story
Hello, fellow MapLibre Community members. First of all, I'm a user and deep admirer of the library!
I was on the organization committee of the latest FOSS4G (last week!), and I met many folks from the MapLibre community, including @nyurik . At his presentation, I asked about the current status of this very request, and then here I am, opening this issue!
Noticing is always the first step!
After a quick search, I found no similar ones. Apologies if I missed some.
Rationale
Why is this feature needed?
Well, in the end, maplibre is all about digital cartography, which is still... well... Cartography! For me, a Cartographer, map symbols are a fundamental element of a map, something that many users are looking for to fully comprehend the values represented by the colors, and so on.
What are some example use cases?
well, any digital map... let's show mine:
https://kauevestena.github.io/opensidewalkmap_beta/map.html
On the right side, there's the layer control panel, but on the left side, there's a proper legend that I made by "hand" (link on next topic). Notice that the first is more about layers and the second is much more about values.
Can it be done today? Is there a workaround?
There's a plugin (that I'm also using) that is ok for layer toggling/untoggling (https://github.com/watergis/mapbox-gl-legend) and kinda fits the whole purpose if there's just a single style per layer.
I did it "manually" with matplotlib, you guys can check interactively, but the implementation is here (in python): https://github.com/kauevestena/oswm_codebase/blob/main/webmap/standalone_legend.py. In my use case, different layers share a the same final styles (not necessarily the same dictionary, but same colors/appearance for the end user)
Well, I'm not a big developer, but I believe that the class could be called MapLegendControl or MapSymbolsControl or without "map".
Impact
Becoming a more complete framework for digital cartography!
The text was updated successfully, but these errors were encountered: