-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
User Story
As a plugin developer, I can retrieve the original style URL used to initialize the map, so that I can fetch the original basemap style and identify which layers came from the basemap vs. layers added dynamically.
Rationale
Why is this feature needed?
When a map is initialized with a style URL, that URL is not accessible later. The map.getStyle() method returns the current style object which includes all layers - both from the original basemap and any layers added dynamically via map.addLayer(). There's no way to distinguish between them.
Example use cases
- Layer control plugins that want to group basemap layers as a single "Basemap" entry while listing user-added layers individually
- Style management tools that need to know what basemap is being used
- Map state serialization that needs to store the original style URL separately from dynamic modifications
Current workaround
Currently, developers must either:
- Ask users to manually provide the style URL as a separate option
- Track the style URL themselves before passing it to the Map constructor
- Have no way to identify original basemap layers
Impact
Without this feature, plugin developers cannot reliably identify which layers came from the original basemap style. This forces either:
- Manual configuration by end users (poor developer experience)
- Complex workarounds that require intercepting map initialization
- Inability to provide features that distinguish basemap from user layers
Proposed API
// Get the style URL (returns undefined if style was provided as object)
const styleUrl = map.getStyleUrl();
// After setStyle() with a URL, it would update accordingly
map.setStyle('https://example.com/style.json');
map.getStyleUrl(); // 'https://example.com/style.json'
// If style was set as an object, returns undefined
map.setStyle({ version: 8, sources: {}, layers: [] });
map.getStyleUrl(); // undefinedReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels