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
28 changes: 28 additions & 0 deletions components/src/maplibre/Map/Map.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@
</DesignTokens>
</div>
</Story>
<Story asChild name="Cooperative Gestures">
<div class="container">
<DesignTokens>
<div class="placeholder">Placeholder</div>
<Map
cooperativeGestures
style={SWRDataLabLight()}
showDebug
initialLocation={{ lat: 51.3, lng: 10.2, zoom: 5 }}
>
<ScaleControl />
<AttributionControl />
<NavigationControl />
</Map>
<div class="placeholder">Placeholder</div>
</DesignTokens>
</div>
</Story>

<Story asChild name="Alternate Style">
<div class="container dark">
Expand All @@ -171,4 +189,14 @@
.dark {
color: rgb(230, 230, 230);
}
.placeholder {
height: 500px;
background: var(--gray-light-5);
margin: 1em;
display: flex;
justify-content: center;
align-items: center;
font-family: var(--swr-sans);
color: var(--gray-base);
}
</style>
42 changes: 42 additions & 0 deletions components/src/maplibre/Map/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { createMapContext, MapContext } from '../context.svelte.js';
import { type Location } from '../types';
import FallbackStyle from './FallbackStyle';
import { de } from './locale.ts';

interface MapProps {
style?: StyleSpecification | string;
Expand All @@ -25,6 +26,10 @@
showDebug?: boolean;
options?: any;
mapContext?: MapContext;
/**
* "Use Ctrl + scroll to zoom"
*/
cooperativeGestures?: boolean;
onmovestart?: (e: MapLibreEvent) => null;
onmoveend?: (e: MapLibreEvent) => null;
children?: Snippet;
Expand All @@ -49,6 +54,7 @@
// Future: This should become bindable.readonly when that becomes
// available, see: https://github.com/sveltejs/svelte/issues/7712
mapContext = $bindable(),
cooperativeGestures = false,
onmoveend,
onmovestart
}: MapProps = $props();
Expand Down Expand Up @@ -81,6 +87,8 @@
center: [initialLocation.lng, initialLocation.lat],
zoom: initialLocation.zoom,
pitch: initialLocation.pitch,
cooperativeGestures,
locale: de,
...options
});

Expand Down Expand Up @@ -352,5 +360,39 @@
.maplibregl-marker path {
fill: var(--violet-dark-5);
}
.maplibregl-cooperative-gesture-screen {
align-items: center;
font-family: var(--swr-sans);
background: rgba(10, 10, 10, 0.4);
text-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
color: #fff;
font-size: var(--fs-base);
font-weight: 400;
display: flex;
inset: 0;
justify-content: center;
line-height: 1.2;
opacity: 0;
padding: 1rem;
pointer-events: none;
position: absolute;
transition: opacity 1s ease 1s;
z-index: 9999;
}
.maplibregl-cooperative-gesture-screen.maplibregl-show {
opacity: 1;
transition: opacity 100ms;
}
.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message {
display: none;
}
@media (hover: none), (pointer: coarse) {
.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message {
display: none;
}
.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message {
display: block;
}
}
}
</style>
29 changes: 29 additions & 0 deletions components/src/maplibre/Map/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const de = {
'AttributionControl.ToggleAttribution': 'Datenquellen zeigen',
'AttributionControl.MapFeedback': 'Feedback',
'FullscreenControl.Enter': 'Vollbild aktivieren',
'FullscreenControl.Exit': 'Vollbild verlassen',
'GeolocateControl.FindMyLocation': 'Meine Position finden',
'GeolocateControl.LocationNotAvailable': 'Position nicht verfügbar',
'LogoControl.Title': 'MapLibre logo',
'Map.Title': 'Karte',
'Marker.Title': 'Markierung',
'NavigationControl.ResetBearing': 'Nach Norden ausrichten',
'NavigationControl.ZoomIn': 'Hereinzoomen',
'NavigationControl.ZoomOut': 'Herauszoomen',
'Popup.Close': 'Popup schließen',
'ScaleControl.Feet': 'ft',
'ScaleControl.Meters': 'm',
'ScaleControl.Kilometers': 'km',
'ScaleControl.Miles': 'mi',
'ScaleControl.NauticalMiles': 'nm',
'GlobeControl.Enable': 'Globus aktivieren',
'GlobeControl.Disable': 'Globus deaktivieren',
'TerrainControl.Enable': 'Terrain aktivieren',
'TerrainControl.Disable': 'Terrain deaktivieren',
'CooperativeGesturesHandler.WindowsHelpText': 'Strg + Maus, um die Karte zu bewegen',
'CooperativeGesturesHandler.MacHelpText': '⌘ + Maus, um die Karte zu bewegen',
'CooperativeGesturesHandler.MobileHelpText': 'Nutze zwei Finger, um die Karte zu bewegen'
};

export { de };
Loading