Repository navigation
Document that map:ready fires before the base map style loads - #610
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Provider-specific timing, viewport readiness, and payload behavior need accurate documentation.
3 open issues
What changed in this PR
Clarifies map readiness timing for #72 without changing runtime behavior.
Changes:
- Distinguishes map creation from base-style readiness.
- Documents the existing
map:loadedevent. - Adds style-readiness guidance for plugins.
| File | Description |
|---|---|
src/config/events.js |
Updates readiness event comments. |
docs/api/context.md |
Explains isMapReady and the provider readiness check. |
docs/api.md |
Expands readiness documentation and adds map:loaded. |
Review effort: Balanced
|
|
I've addressed all three in the latest commit. map:ready now only says the map uses the safe zone as its initial padding, since OpenLayers fits bounds after map:ready fires. "Base map style" is now "base map", which fits OpenLayers and ESRI. The map:loaded payload now notes that ESRI passes the current map state. Making ESRI's payload match the other providers would change runtime behaviour, so that should be a separate ticket. |




Resolves #72
The race in #72 no longer crashes. MapLibre v6 (#562) made
getSourcesafe to call before the style exists. The single draw plugin (#422) also polls for its sources instead of reading them onmap:ready.We're keeping
map:readywhere it is, straight after the map is created, rather than moving it into theloadcallback. Padding sync, re-measuring the layout once plugins render, plugin UI and markers all wait onisMapReady, and none of them need the style. Moving it would hold the interface back until the style had loaded, and if the style failed to load, that UI would never appear.This PR documents the timing instead:
map:ready/MAP_READY: fires once the map instance exists. The base map style may still be loading.map:loadedentry: fires once the initial style has loaded. Already emitted by all providers but not documented until now.mapState.isMapReady: plugins should checkmapProvider.isBaseMapReady()before adding sources or layers.