Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,28 @@
</DesignTokens>
</Story>

<Story asChild name="Disable road labels (#190)">
<Story asChild name="Toggle place labels (#221)">
<DesignTokens theme="dark">
<div class="grid">
<div class="container">
<Map
showDebug
style={SWRDataLabDark({ places: { showLabels: false } })}
initialLocation={{
lng: 8.936,
lat: 49.662,
zoom: 7.814,
pitch: 0
}}
>
<AttributionControl position="bottom-left" />
</Map>
</div>
</div>
</DesignTokens>
</Story>

<Story asChild name="Toggle road labels (#190)">
<DesignTokens theme="dark">
<div class="grid">
<div class="container">
Expand Down
13 changes: 7 additions & 6 deletions components/src/maplibre/MapStyle/SWRDataLabDark.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { StyleOptions } from './types';
import type { StyleSpecification } from 'maplibre-gl';

import defaultOptions from './defaultOptions';

import makeAdmin from './components/Admin';
import makeBuildings from './components/Buildings';
import makeLanduse from './components/Landuse';
import makeTransit from './components/Transit';
import makePlaceLabels from './components/PlaceLabels';
import makeWalking from './components/Walking';
import makeRoads from './components/Roads';
import type { StyleOptions } from './types';

const tokens = {
sans_regular: ['SWR Sans Regular'],
Expand Down Expand Up @@ -56,10 +58,7 @@ interface styleFunction {

const style: styleFunction = (opts) => {
const options = {
enableBuildingExtrusions: false,
roads: {
showLabels: true
},
...defaultOptions,
...opts
} as StyleOptions;

Expand Down Expand Up @@ -133,7 +132,9 @@ const style: styleFunction = (opts) => {
...(options.enableBuildingExtrusions ? [buildingExtrusions] : []),

// 8. Point labels
...placeLabels,
...(options.places?.showLabels ? placeLabels : []),

// 9. Admin boundary labels
...boundaryLabels
]
};
Expand Down
14 changes: 8 additions & 6 deletions components/src/maplibre/MapStyle/SWRDataLabLight.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ Call `SWRDataLabLight()` to construct a style document and pass the result to th

```ts
interface StyleOptions {
enableBuildingExtrusions?: boolean;
roads?: {
showLabels?: boolean
}

enableBuildingExtrusions?: boolean;
roads?: {
showLabels?: boolean
}
places?: {
showLabels?: boolean
}
}
```

## Icons

export const customIcons = ['pin-14'];
export const customIcons = ['pin-14', 'pin-14-dark'];
export const osmicIconsCount = Object.entries(SpriteData).filter((row) => {
return !customIcons.includes(row[0]);
}).length;
Expand Down
9 changes: 6 additions & 3 deletions components/src/maplibre/MapStyle/SWRDataLabLight.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { StyleOptions } from './types';
import type { StyleSpecification } from 'maplibre-gl';

import makeAdmin from './components/Admin';
Expand All @@ -7,7 +8,7 @@ import makeTransit from './components/Transit';
import makePlaceLabels from './components/PlaceLabels';
import makeWalking from './components/Walking';
import makeRoads from './components/Roads';
import type { StyleOptions } from './types';
import defaultOptions from './defaultOptions';

const tokens = {
sans_regular: ['SWR Sans Regular'],
Expand Down Expand Up @@ -56,7 +57,7 @@ interface styleFunction {

const style: styleFunction = (opts) => {
const options = {
enableBuildingExtrusions: false,
...defaultOptions,
...opts
} as StyleOptions;

Expand Down Expand Up @@ -130,7 +131,9 @@ const style: styleFunction = (opts) => {
...(options.enableBuildingExtrusions ? [buildingExtrusions] : []),

// 8. Point labels
...placeLabels,
...(options.places?.showLabels ? placeLabels : []),

// 9. Admin boundary labels
...boundaryLabels
]
};
Expand Down
13 changes: 13 additions & 0 deletions components/src/maplibre/MapStyle/defaultOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { StyleOptions } from './types';

const opts: StyleOptions = {
enableBuildingExtrusions: false,
places: {
showLabels: true
},
roads: {
showLabels: true
}
};

export default opts;
3 changes: 3 additions & 0 deletions components/src/maplibre/MapStyle/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
interface StyleOptions {
enableBuildingExtrusions?: boolean;
places?: {
showLabels?: boolean;
};
roads?: {
showLabels?: boolean;
};
Expand Down
1 change: 1 addition & 0 deletions components/src/maplibre/Maplibre.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This example initialises a map using the SWRDataLabLight style, adds an addition

- **[VectorTileSource](?path=/docs/maplibre-source-vectortilesource--docs)**: Loads vector tile data supplied by a tileserver
- **[GeoJSONSource](?path=/docs/maplibre-source-geojsonsource--docs)**: Loads a vector data from a GeoJSON object or remote file
- **[ArrowSource](?path=/docs/maplibre-source-arrowsource--docs)**: Provides vector data for quadratic bezier arrows

### Layers

Expand Down