From 9039cc497d8bec76dc1cd3d92f8c73e8111d59f6 Mon Sep 17 00:00:00 2001 From: Olivier Terral Date: Tue, 19 Nov 2024 10:23:38 +0100 Subject: [PATCH] fix: fix switch style --- doc/yarn.lock | 2 +- src/ol/layers/MaplibreLayer.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/yarn.lock b/doc/yarn.lock index 76c571cf..16b5a0a5 100644 --- a/doc/yarn.lock +++ b/doc/yarn.lock @@ -4518,7 +4518,7 @@ mkdirp@^0.5.1: minimist "^1.2.6" mobility-toolbox-js@./../build: - version "3.0.0-beta.35" + version "3.0.0-beta.36" dependencies: "@geoblocks/ol-maplibre-layer" "^1.0.1" "@turf/helpers" "7.1.0" diff --git a/src/ol/layers/MaplibreLayer.ts b/src/ol/layers/MaplibreLayer.ts index b4efbddf..dde6e5ff 100644 --- a/src/ol/layers/MaplibreLayer.ts +++ b/src/ol/layers/MaplibreLayer.ts @@ -118,6 +118,10 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) { ); } super(newOptions); + + // We save the options to be able to clone the layer. + // and to see if the style is defined by the maplibreOptions given by the user. + this.set('options', options); } /** @@ -181,9 +185,9 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) { return this.url; } - // If the style is defined by the maplibreOptions, we use it directly - if (this.get('mapLibreOptions')?.style) { - return this.get('mapLibreOptions').style; + // If the user has defined the style by the maplibreOptions, we use it directly. + if (this.get('options')?.mapLibreOptions?.style) { + return this.get('options').mapLibreOptions.style; } /// Otherwise build the complete style url.