mirror of
https://github.com/maputnik/editor.git
synced 2026-02-10 14:40:01 +00:00
Keeps the repo clean, same as several other of our repos --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
27 lines
713 B
TypeScript
27 lines
713 B
TypeScript
import type {StyleSpecification, SourceSpecification} from "maplibre-gl";
|
|
|
|
export function deleteSource(mapStyle: StyleSpecification, sourceId: string) {
|
|
const remainingSources = { ...mapStyle.sources}
|
|
delete remainingSources[sourceId]
|
|
return {
|
|
...mapStyle,
|
|
sources: remainingSources
|
|
}
|
|
}
|
|
|
|
|
|
export function addSource(mapStyle: StyleSpecification, sourceId: string, source: SourceSpecification) {
|
|
return changeSource(mapStyle, sourceId, source)
|
|
}
|
|
|
|
export function changeSource(mapStyle: StyleSpecification, sourceId: string, source: SourceSpecification) {
|
|
const changedSources = {
|
|
...mapStyle.sources,
|
|
[sourceId]: source
|
|
}
|
|
return {
|
|
...mapStyle,
|
|
sources: changedSources
|
|
}
|
|
}
|