forked from MapComplete/MapComplete
Fix: ordering of baselayers
This commit is contained in:
parent
1ec76b66b5
commit
8379a894d0
1 changed files with 11 additions and 4 deletions
|
@ -376,16 +376,23 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
|
||||||
map.addSource(background.id, MapLibreAdaptor.prepareWmsSource(background))
|
map.addSource(background.id, MapLibreAdaptor.prepareWmsSource(background))
|
||||||
|
|
||||||
map.resize()
|
map.resize()
|
||||||
|
|
||||||
|
let addLayerBeforeId = "aeroway_fill"// this is the first non-landuse item in the stylesheet, we add the raster layer before the roads but above the landuse
|
||||||
|
if(background.category === "osmbasedmap" || background.category === "map"){
|
||||||
|
// The background layer is already an OSM-based map or another map, so we don't want anything from the baselayer
|
||||||
|
let layers = map.getStyle().layers
|
||||||
|
// THe last index of the maptiler layers
|
||||||
|
let lastIndex = layers.findIndex(layer => layer.id === "housenumber")
|
||||||
|
addLayerBeforeId = layers[lastIndex + 1]?.id ?? "housenumber"
|
||||||
|
}
|
||||||
|
|
||||||
map.addLayer(
|
map.addLayer(
|
||||||
{
|
{
|
||||||
id: background.id,
|
id: background.id,
|
||||||
type: "raster",
|
type: "raster",
|
||||||
source: background.id,
|
source: background.id,
|
||||||
paint: {},
|
paint: {},
|
||||||
},
|
},addLayerBeforeId
|
||||||
background.category === "osmbasedmap" || background.category === "map"
|
|
||||||
? undefined
|
|
||||||
: "aeroway_fill"
|
|
||||||
)
|
)
|
||||||
await this.awaitStyleIsLoaded()
|
await this.awaitStyleIsLoaded()
|
||||||
this.removeCurrentLayer(map)
|
this.removeCurrentLayer(map)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue