-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bindings for "bounds", "style", other props in mapbox-gl #32
Comments
IMO, I think that invoking helpers/components on templates for other purposes other than actually rendering things is an anti pattern. |
I agree that binding properties to the map feels more embery, but I'm trying to balance that with exposing the full mapbox-gl-js API. Currently, the templates read mostly like one was using the map directly, except with auto-binding to call methods when data changes. I also worry about handling these property to method mappings and then mapbox changing their API, for example unifying the camera API. Maybe a subset of properties to methods could be added, but then it's a crap shoot for people knowing when they can use a binding and when they need to fall back to map.call. The bindings feel like a feature that will be easier to add post mapbox-gl-js 1.0. As for being promise aware, I'm not sure that ember-mapbox-gl is the right place to handle that. Perhaps some ember-concurrency tasks with |
Gotcha. I'm not sure how much the "bounds" and "style" parts of their API will change or has changed, though, but as you've mentioned before, mapbox-gl-js is a little volatile right now. In my experience, pre- and post-Leaflet 1.0 did not have a tremendous impact on general map position state APIs, so I think ember-leaflet was able implement this property-method binding pattern pre-1.0 (though @miguelcobain could probably speak more to that). Point taken on confusion re: falling back to some-consumer-template.hbs:
mapbox-gl.hbs:
I could probably just do this locally in my own project though ¯_(ツ)_/¯. Agree on promise-awareness - it was just a thought. E-concurrency or promise helpers are the right path for that! Thanks! |
hmmmm. I'm also not sure how in that scenario one could pass in options and eventData to fitBounds. |
What I did on ember-leaflet was to create a sort of DSL for binding properties, much like we have for leafletProperties: [
'zoom:setZoom:zoomPanOptions', 'minZoom', 'maxZoom',
'center:panTo:zoomPanOptions',
'bounds:fitBounds:fitBoundsOptions', 'maxBounds'
] For example, Of course, leaflet breaking changes will always be tied to ember-leaflet breaking changes, but I think that is somehow expected. However, using these sort of dynamic "tricks" we can easily accommodate for simple simple api changes. |
I'm running into a use case where we manage styles entirely through
setStyle
ofmapbox-gl
Map class. This lends itself to some intense actions thatfetch
and set a style object using a reference to the map instance'ssetStyle
method. This is probably okay, but I can see an argument for a fewmapbox-gl
-level properties that managesetStyle
andfitBounds
internally. Using @miguelcobain's Ember Leaflet as an analog, you can see the mapping of properties to Leaflet's internal methods under the "bound options" section:I know that
map.call
works for these cases -{{map.call 'fitBounds' bounds}} {{map.call 'setStyle' styleObject}}
- but it seems awkward to think of calling functions (as opposed to actions) inside of templates where we should be passing actions and properties. This introduces some non-MapboxGL properties to our API, but I don't think they will collide.The "Promise aware" part of the title is a nice-to-have - to be able to pass promises down and have components resolve them would be great, but I can imagine having that in a generic API would make it impossible to handle things like failed promises and so on...I wanted to get your thoughts on this and maybe I could start a branch.
Thank you!
The text was updated successfully, but these errors were encountered: