diff --git a/components/src/maplibre/MapStyle/SWRDataLabLight.ts b/components/src/maplibre/MapStyle/SWRDataLabLight.ts
index 45b206df..91541c9e 100644
--- a/components/src/maplibre/MapStyle/SWRDataLabLight.ts
+++ b/components/src/maplibre/MapStyle/SWRDataLabLight.ts
@@ -50,7 +50,6 @@ const tokens = {
const { landuse } = makeLanduse(tokens);
const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
-const { admin } = makeAdmin(tokens);
const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
@@ -67,6 +66,8 @@ const style: styleFunction = (opts) => {
...opts
} as StyleOptions;
+ const { admin } = makeAdmin(tokens, options?.admin);
+
return {
version: 8,
name: 'swr-datalab-light',
diff --git a/components/src/maplibre/MapStyle/components/Admin.ts b/components/src/maplibre/MapStyle/components/Admin.ts
index 5e0de2a2..e1ec05d1 100644
--- a/components/src/maplibre/MapStyle/components/Admin.ts
+++ b/components/src/maplibre/MapStyle/components/Admin.ts
@@ -1,6 +1,6 @@
import { type Layer } from '../../types';
-export default function makeAdmin(tokens): any {
+export default function makeAdmin(tokens, options): any {
const admin: Layer[] = [
{
id: 'boundary-country:case',
@@ -134,18 +134,32 @@ export default function makeAdmin(tokens): any {
}
}
}
- ].map((el) => {
- return {
- source: 'versatiles-osm',
- 'source-layer': 'boundaries',
- type: 'line',
- ...el,
- layout: {
- 'line-cap': 'round',
- 'line-join': 'round'
+ ]
+ .filter((el) => {
+ if (!options || options.show === true) {
+ return true;
+ } else if (options.show === false) {
+ return false;
+ } else {
+ return (
+ (el.id.includes('country') && options.show.includes(2)) ||
+ (el.id.includes('state') && options.show.includes(4))
+ );
}
- } as Layer;
- });
+ return false;
+ })
+ .map((el) => {
+ return {
+ source: 'versatiles-osm',
+ 'source-layer': 'boundaries',
+ type: 'line',
+ ...el,
+ layout: {
+ 'line-cap': 'round',
+ 'line-join': 'round'
+ }
+ } as Layer;
+ });
return { admin };
}
diff --git a/components/src/maplibre/MapStyle/defaultOptions.ts b/components/src/maplibre/MapStyle/defaultOptions.ts
index 57ae17b7..77800ca5 100644
--- a/components/src/maplibre/MapStyle/defaultOptions.ts
+++ b/components/src/maplibre/MapStyle/defaultOptions.ts
@@ -7,6 +7,9 @@ const opts: StyleOptions = {
},
roads: {
showLabels: true
+ },
+ admin: {
+ show: true
}
};
diff --git a/components/src/maplibre/MapStyle/types.ts b/components/src/maplibre/MapStyle/types.ts
index 3b610049..c8251dab 100644
--- a/components/src/maplibre/MapStyle/types.ts
+++ b/components/src/maplibre/MapStyle/types.ts
@@ -1,9 +1,16 @@
+enum AdminLevel {
+ COUNTRY = 2,
+ BUNDESLAND = 4
+}
interface StyleOptions {
enableBuildingExtrusions?: boolean;
enableHillshade?: boolean;
places?: {
showLabels?: boolean;
};
+ admin?: {
+ show?: boolean | AdminLevel[];
+ };
roads?: {
showLabels?: boolean;
};