-
Notifications
You must be signed in to change notification settings - Fork 62
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
Break up LegendControl
#782
Comments
Adding a legend to OpenTrailMap has become a priority for us. I'd be interested in helping to generalize the Americana legend if it looks like it would work for us. Could someone point me in the right direction? |
The control is primarily implemented in https://github.com/osm-americana/openstreetmap-americana/blob/f9a8682ea7f24e4ec604b8a2199c17f0fec0832d/src/js/legend_control.js and configured in https://github.com/osm-americana/openstreetmap-americana/blob/f9a8682ea7f24e4ec604b8a2199c17f0fec0832d/src/js/legend_config.js. The legend rows are styled in this stylesheet: openstreetmap-americana/src/index.html Lines 37 to 90 in f9a8682
and structured according to this template: openstreetmap-americana/src/index.html Lines 119 to 161 in f9a8682
I took a pure HTML+CSS+JS approach so that it would have as few external dependencies as possible, so that any future plugin would be more versatile. |
The legend feature is currently implemented as a monolithic
LegendControl
class responsible for generating its entire contents. This includes two separate code paths, one for statically configured sections and another for the more dynamic “Route markers” section: #773 (comment). legend_control.js is terribly difficult to follow due to its length. We should make it more modular and break it up into multiple classes.The only reason this class wound up being monolithic in #632, other than laziness on my part, is that various parts of it require interacting with the
Map
object for feature querying and style introspection. It seemed risky performance-wise to keep redundant references to it from multiple objects with potentially different lifetimes. But I’m open to ideas about how to better structure this code. It would be pretty silly to keep it all as one class if we manage to factor it out as a plugin down the line.The text was updated successfully, but these errors were encountered: