- Understand paint classes,
updatePaintTransitions
,Style#_recalculate
/StyleLayer#recalculate
- Read through
Camera
- jfirebaugh proposed adding camera state as top-level property of style; add to style spec? If yes, how about map z and lnglat constraints as well?
Goal: make map.setStyle({ layers: [ ..., { one layout property different from map's current style } ] })
as good as map.setLayoutProperty()
(modulo a pretty cheap diff)
This seems pretty immediately doable and quick (unless maybe updating unit tests requires a lot of reworking).
- Add mapbox-gl-style-spec's diff implementation as
Style#setState
. - Change
Map#setStyle
to delegate toStyle#setState
(instead of constructing a newStyle
instance). - Mod
setStyle
to accept partial state (areundefined
properties treated as meaningful falsy values?) - Add a React example to validate and demonstrate the setStyle API
Goal: Further separate concerns of state management and user-facing map-manipulation API (Map#setXxxYyy()
). Also start moving in the direction of jfirebaugh's proposal mapbox/mapbox-gl-js#1989 (comment)
Before diving in on this and possibly even before "Get it working," I should post up a more detailed proposal for the resulting architecture & API for discussion.
- Change style-mutating
Map
methods to useStyle#setState
and make the correspondingStyle
methods private.- Methods:
Map#{add,move,remove}Layer
,Map#{add,remove}Source
,Map#set{Layout,Paint}Property
,Map#setFilter
,Map#setLayerZoomRange
,Map#setLight
- This should bring
Style
's internally-public API down to{ setState: (partialState: obj) => void, update: (options: obj) => void }
, wheresetState
queues a state change andupdate
applies all queued state changes. - What happens to
Map#getLayer
?
- Methods:
- Defer the actual work of diffing/applying changes to
Style#update
, as it need only be performed once per batch.- Remove batching stuff from
addLayer
,setLayoutProperty
, etc. -- these should now just be helpers that directly/immediately mutate Style's internal state - By the way: if this only happens once per batch, I wonder whether requiring the input to
setState
to be immutable is going to add much, perf-wise; worth checking out before taking on a dependency like Immutable.js.
- Remove batching stuff from
- Pull the style-controlling API into a separate mixin rather than keeping them on
Map
- Remove 'paint classes' (How invasive is this? And is it okay to break, or should it be deprecated?)
- Consolidate camera/transform state into
Style
. This may be out of scope (need to read throughCamera
to know better)- Accept camera/transform state as top-level
setState
property (includes zoom, center, pitch, bearing, minzoom, maxzoom, lngRange, latRange) - Move
transform
-mutating stuff fromCamera
toStyle
- Refactor
Camera
methods to useStyle#setState
- tricky thing here is transitions; can Camera's multi-frame easing code be reworked to use
setState
efficiently?
- tricky thing here is transitions; can Camera's multi-frame easing code be reworked to use
- Accept camera/transform state as top-level
- Propose addition of
Source#update
to theSource
interface - Propose decoupling style-update batching from
render
(TODO: describe relevant observations from WaPo perf work)