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
59 changes: 56 additions & 3 deletions components/src/maplibre/MapStyle/SWRDataLabDark.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import AttributionControl from '../AttributionControl/AttributionControl.svelte';
import GeocoderControl from '../GeocoderControl/GeocoderControl.svelte';

import { SWRDataLabDark } from './index';
import { SWRDataLabDark, SWRDataLabLight } from './index';
import locations from './storyLocations';
import NavigationControl from '../NavigationControl/NavigationControl.svelte';
import { type RoadLabelDensity } from './types';

const { Story } = defineMeta({
title: 'Maplibre/Style/SWR Data Lab Dark',
Expand Down Expand Up @@ -71,7 +72,7 @@
<div class="container">
<Map
showDebug
style={SWRDataLabDark({ roads: { showLabels: false } })}
style={SWRDataLabDark({ roads: { labels: 'none' } })}
initialLocation={{ ...locations.berlin, zoom: 15 }}
>
<AttributionControl position="bottom-left" />
Expand Down Expand Up @@ -290,7 +291,54 @@
showDebug
style={SWRDataLabDark()}
maxZoom={20}
initialLocation={{lng: 9.558006092459436, lat: 47.69445218974644, zoom: 15.664592047703644}}
initialLocation={{
lng: 9.558006092459436,
lat: 47.69445218974644,
zoom: 15.664592047703644
}}
>
<AttributionControl position="bottom-left" />
</Map>
</div>
</div>
</DesignTokens>
</Story>
<Story asChild name="feat/459: overview">
<DesignTokens theme="dark">
<div class="row">
{#each ['none', 'default', 'dense'] as s}
<div class="container">
{s}
<Map
showDebug={s === 'dense'}
maxZoom={20}
style={SWRDataLabDark({ roads: { labels: s as RoadLabelDensity } })}
initialLocation={{
lng: 8.269931078413038,
lat: 50.00421185075504,
zoom: 15.210111923487453
}}
>
<AttributionControl position="bottom-left" />
</Map>
</div>
{/each}
</div>
</DesignTokens>
</Story>
<Story asChild name="feat/459: dense">
<DesignTokens theme="dark">
<div class="row">
<div class="container">
<Map
showDebug
maxZoom={20}
style={SWRDataLabDark({ roads: { labels: 'dense' } })}
initialLocation={{
lng: 9.558469031819868,
lat: 47.700057918000056,
zoom: 14.74477639533513
}}
>
<AttributionControl position="bottom-left" />
</Map>
Expand All @@ -306,7 +354,12 @@
grid-template-rows: auto;
height: 700px;
}
.row {
display: flex;
height: 700px;
}
.container {
flex-grow: 1;
overflow: hidden;
}
</style>
20 changes: 12 additions & 8 deletions components/src/maplibre/MapStyle/SWRDataLabDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ 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 makePlaceLabels from './components/PlaceLabels';
import makeRoadLabels from './components/RoadLabels';
import makeHillshade from './components/Hillshade';

const tokens = {
import type { styleTokens } from '../types';

const tokens: styleTokens = {
sans_regular: ['swr_sans_regular'],
sans_medium: ['swr_sans_medium'],
sans_bold: ['swr_sans_bold'],
Expand All @@ -35,16 +38,16 @@ const tokens = {
street_primary_case: 'hsl(0, 11%, 7%)',
street_secondary: 'hsl(220, 3%, 20%)',
street_secondary_case: 'hsl(0, 0%, 0%)',
street_tertiary: 'hsl(0, 0%, 20%)',
street_tertiary: 'hsl(0, 0%, 15%)',
street_tertiary_case: 'hsl(0, 0%, 14%)',
label_primary: 'hsl(240, 5%, 96%)',
label_secondary: 'hsl(0, 2%, 85%)',
label_tertiary: 'hsl(0, 1%, 75%)',
label_tertiary: 'hsl(0, 1%, 60%)',
boundary_country: '#6e6f71',
boundary_country_case: '#181818',
boundary_state: 'hsl(218, 4%, 37%)',
rail: 'hsl(0, 0%, 33%)',
building: '#232325',
building: '#111',
hillshade_light: 'hsla(0, 0%, 77%, 0.15)',
hillshade_dark: 'hsla(0, 0%, 0%, 0.65)'
};
Expand All @@ -53,7 +56,7 @@ const { landuse } = makeLanduse(tokens);
const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
const { roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
const { buildingFootprints, buildingExtrusions, structureExtrusions } = makeBuildings(tokens);
const { hillshade } = makeHillshade(tokens);

Expand All @@ -68,6 +71,7 @@ const style: styleFunction = (opts) => {
} as StyleOptions;

const { admin } = makeAdmin(tokens, options?.admin);
const { roadLabels } = makeRoadLabels(tokens, options?.roads?.labels);

return {
version: 8,
Expand Down Expand Up @@ -155,8 +159,8 @@ const style: styleFunction = (opts) => {
...admin,

// 8. Labels
...(options.roads?.showLabels ? walkingLabels : []),
...(options.roads?.showLabels ? roadLabels : []),
...(options.roads?.labels !== 'none' ? walkingLabels : []),
...roadLabels,

// 9. Building extrusions
...(options.enableBuildingExtrusions ? [buildingExtrusions] : []),
Expand Down
11 changes: 7 additions & 4 deletions components/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<DesignTokens theme="light">
<div class="grid">
<div class="container">
<Map showDebug style={SWRDataLabLight({roads: {showLabels: true}})} initialLocation={locations.stugge}>
<Map showDebug style={SWRDataLabLight()} initialLocation={locations.stugge}>
<AttributionControl position="bottom-left" />
</Map>
</div>
Expand All @@ -290,8 +290,11 @@
<DesignTokens theme="light">
<div class="grid">
<div class="container">
<Map showDebug style={SWRDataLabLight({ roads: {
showLabels: true}})} initialLocation={{"lng":13.397677524739947,"lat":52.5175142188192,"zoom":14.99}}>
<Map
showDebug
style={SWRDataLabLight()}
initialLocation={{ lng: 13.397677524739947, lat: 52.5175142188192, zoom: 14.99 }}
>
<AttributionControl position="bottom-left" />
</Map>
</div>
Expand Down Expand Up @@ -330,7 +333,7 @@
<div class="container">
<Map
showDebug
style={SWRDataLabLight({ enableBuildingExtrusions: true, roads: { showLabels: false } })}
style={SWRDataLabLight({ enableBuildingExtrusions: true, roads: { labels: 'none' } })}
maxZoom={20}
initialLocation={locations.buildings}
>
Expand Down
16 changes: 10 additions & 6 deletions components/src/maplibre/MapStyle/SWRDataLabLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ import makeLanduse from './components/Landuse';
import makeTransit from './components/Transit';
import makePlaceLabels from './components/PlaceLabels';
import makeWalking from './components/Walking';
import makeRoadLabels from './components/RoadLabels';
import makeRoads from './components/Roads';
import defaultOptions from './defaultOptions';
import makeHillshade from './components/Hillshade';

import type { styleTokens } from '../types';

const water = {
stops: [
[6, 'white'],
[6.5, 'hsl(216, 50%, 92%)']
]
};

const tokens = {
const tokens: styleTokens = {
sans_regular: ['swr_sans_regular'],
sans_medium: ['swr_sans_medium'],
sans_bold: ['swr_sans_bold'],
Expand All @@ -45,8 +48,8 @@ const tokens = {
street_tertiary_case: 'hsl(0, 0%, 70%)',
label_primary: 'hsl(240, 10%, 2%)',
label_secondary: 'hsl(0, 0%, 18%)',
label_tertiary: 'hsl(60, 1%, 25%)',
building: '#f3f2f1',
label_tertiary: 'hsl(60, 1%, 35%)',
building: '#eee',
rail: '#d3d3d3',
boundary_country: '#8b8a89',
boundary_state: 'hsl(37, 10%, 75%)',
Expand All @@ -59,7 +62,7 @@ const { landuse } = makeLanduse(tokens);
const { placeLabels, boundaryLabels } = makePlaceLabels(tokens);
const { airports, transitBridges, transitSurface, transitTunnels } = makeTransit(tokens);
const { walkingLabels, walkingTunnels, walkingSurface, walkingBridges } = makeWalking(tokens);
const { roadLabels, roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
const { roadBridges, roadSurface, roadTunnels } = makeRoads(tokens);
const { buildingFootprints, buildingExtrusions, structureExtrusions } = makeBuildings(tokens);
const { hillshade } = makeHillshade(tokens);

Expand All @@ -74,6 +77,7 @@ const style: styleFunction = (opts) => {
} as StyleOptions;

const { admin } = makeAdmin(tokens, options?.admin);
const { roadLabels } = makeRoadLabels(tokens, options?.roads?.labels);

return {
version: 8,
Expand Down Expand Up @@ -161,8 +165,8 @@ const style: styleFunction = (opts) => {
...admin,

// 8. Labels
...(options.roads?.showLabels ? walkingLabels : []),
...(options.roads?.showLabels ? roadLabels : []),
...(options.roads?.labels !== 'none' ? walkingLabels : []),
...roadLabels,

// 9. Building extrusions
...(options.enableBuildingExtrusions ? [buildingExtrusions] : []),
Expand Down
4 changes: 2 additions & 2 deletions components/src/maplibre/MapStyle/components/Admin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Layer } from '../../types';
import { type Layer, type styleTokens } from '../../types';

export default function makeAdmin(tokens, options): any {
export default function makeAdmin(tokens: styleTokens, options): any {
const admin: Layer[] = [
{
id: 'boundary-country:case',
Expand Down
18 changes: 13 additions & 5 deletions components/src/maplibre/MapStyle/components/Buildings.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { type Layer } from '../../types';
import { type Layer, type styleTokens } from '../../types';

export default function makeBuildings(tokens): any {
export default function makeBuildings(tokens: styleTokens): any {
const extrusionLayer = {
source: 'basemap-de',
type: 'fill-extrusion',
minzoom: 14,
maxzoom: 20,
maxzoom: 20,
paint: {
'fill-extrusion-color': tokens.building,
'fill-extrusion-opacity': ['interpolate', ['linear'], ['zoom'], 15.5, 0, 16, 1],
'fill-extrusion-height': ['interpolate', ['linear'], ['zoom'], 15.5, 0, 16, ["to-number", ['get', 'hoehe']]]
'fill-extrusion-opacity': ['interpolate', ['linear'], ['zoom'], 14.5, 0, 15, 1],
'fill-extrusion-height': [
'interpolate',
['linear'],
['zoom'],
15.5,
0,
16,
['to-number', ['get', 'hoehe']]
]
}
};

Expand Down
4 changes: 2 additions & 2 deletions components/src/maplibre/MapStyle/components/Hillshade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Layer } from '../../types';
import { type Layer, type styleTokens } from '../../types';

export default function makeHillshade(tokens): any {
export default function makeHillshade(tokens: styleTokens): any {
const hillshade: Layer[] = [
{
id: 'hillshade-light',
Expand Down
4 changes: 2 additions & 2 deletions components/src/maplibre/MapStyle/components/Landuse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Layer } from '../../types';
import { type Layer, type styleTokens } from '../../types';

export default function makeLanduse(tokens): any {
export default function makeLanduse(tokens: styleTokens): any {
const landuse: Layer[] = [
{
id: 'background',
Expand Down
Loading
Loading