-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Reconsider popup / overlay API #2727
Comments
I'd prefer an API pattern that doesn't necessitate adding a method to
|
Yes, if we are going to release this as a plugin, the method should not be var overlay = addOverlay(map, {
element: document.createElement(...),
coordinate: [lng, lat]
}); If this is going to be in GL JS core, is |
Both |
This does make overlay addition more similar to layer and source addition, but adding a layer or source returns It also makes the API much more similar to the mobile equivalents cc @1ec5 On the bright side, I could see this enabling something like So, not opposed, but not convinced that this change fundamentally improves the API. |
Having map.addOverlay({
id: 'mapbox',
element: document.createElement(...),
coordinate: [lng, lat]
});
map.removeOverlay('mapbox') |
The overlay / popup API is more complicated than necessary. Reducing the API surface (hiding the Why refactor it now? Because over the next year we're working towards a v1 API that we're comfortable supporting "forever." Whenever there's an opportunity to substantially improve or simplify a v0 API, we should take it. |
We shouldn't remove the concept of a detached popup; it is useful and key to a number of examples. I suspect the same will be true of overlay. |
Do you have any particular example in mind? Here's a mockup of |
Yes, I strongly prefer the existing API to that proposal. That proposal:
I don't think making classes like |
I have to agree with @jfirebaugh here. As someone who maintained Leaflet for 5 years, I strongly prefer the pattern of the existing API. |
The native SDKs (particularly the I’m ambivalent about combining the overlay and popup interfaces together. Leaving the two separate would enable some markerless use cases that are quite rare on iOS, though I think you could also satisfy these use cases by supporting some sort of “empty” marker that still has a popup. Whatever the case, my inclination would be to keep the overlay/popup interfaces separate from |
Thanks for the feedback everyone! I feel fortunate to have so much experience to draw upon 🙇. Threads of ThoughtThere are a few threads of thought emerging here: Atomic / Stateless Popups 👍There is consensus (including by me) that popups should allow non-atomic mutations and not pretend to be stateless. Leaflet-Compatible Popups 👍There is benefit to making GL JS popups a moral equivalent of Map-Popup Coupling 💭
GL JS UI elements fall into two categories:
What is I don't foresee a need to create additional plugins for UI elements that appear "within" the map. If we want to simplify Detached Popups 💭
I don't see detached popups as necessary for any of our examples. Most of them would be more straightforward and robust if they didn't use detached popups. Detached popups been the root of bugs in the past and will likely be the root of more bugs in the future. #2395 #1811 #1477 Fewer concepts make GL JS easier to learn. Fewer imperative APIs make GL JS easier to use. Next Steps... will be considered after the WWDC party 😄 |
Closing this in favor of incremental improvements |
Before we ship #2725 in a release, we have an opportunity to reconsider our API design.
I would love to see an API for popups and overlays that is:
Here's a strawdog proposal:
cc @mourner @jfirebaugh @tmcw @mollymerp
The text was updated successfully, but these errors were encountered: