OptionalonCalled immediately before a style change begins.
What kind of switch is happening. See StyleChangeContext.
void or a Promise that resolves when preparation is complete
OptionalonCalled after a new style has fully loaded.
What kind of switch is happening. See StyleChangeContext.
void or a Promise that resolves when reinitialization is complete
Use it to restore state, reinitialize layers or do other setup that depends on the new style being ready. It can be synchronous or asynchronous. Handlers run one after the other, by StyleChangeHandler.priority, and the promise TomTomMap.setStyle returns resolves only once the last one has finished.
OptionalpriorityWhere this handler runs relative to the others. Lower values run first, and equal values run in
registration order. The default 0 is also what the SDK's data and visibility modules use.
The SDK's style knobs land at 90 and the StylingFoundationsModule's raw layer edits at
100, so semantic styling always lands on top of whatever the modules restored.
Callbacks that respond to map style changes.
Remarks
The SDK calls them when the map style changes through TomTomMap.setStyle. Use them to clean up or reinitialize custom map features when the style switches. For example, save and restore custom layers or sources, reinitialize map modules, update UI components for the new style, or clean up resources tied to the previous style.
The lifecycle is:
onStyleAboutToChangeruns before the new style is applied.onStyleChangedruns after the new style has fully loaded.Example
See