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
19 changes: 12 additions & 7 deletions components/src/maplibre/Map/Map.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,28 @@
>
<ScaleControl />
<AttributionControl />
<NavigationControl />
</Map>
<div class="placeholder">Placeholder</div>
</DesignTokens>
</div>
</Story>
<Story asChild name="initialBounds">
<div class="container">
<DesignTokens theme="light">
<Map showDebug style={SWRDataLabLight()} initialBounds={[5.87, 47.1, 15.04, 55.1]}>
<ScaleControl />
<AttributionControl />
</Map>
</DesignTokens>
</div>
</Story>

<Story asChild name="Alternate Style">
<div class="container dark">
<div class="container">
<DesignTokens theme="dark">
<Map style={alternateStyle}>
<Map style={alternateStyle} initialBounds={[5.87, 47.27, 15.04, 55.06]}>
<ScaleControl />
<AttributionControl />
<NavigationControl showCompass visualizePitch />
<GeocoderControl languages="de" service="maptiler" key="V32kPHZjMa0Mkn6YvSzA" />
</Map>
</DesignTokens>
Expand All @@ -186,9 +194,6 @@
width: 100%;
height: 600px;
}
.dark {
color: rgb(230, 230, 230);
}
.placeholder {
height: 500px;
background: var(--gray-light-5);
Expand Down
12 changes: 11 additions & 1 deletion components/src/maplibre/Map/Map.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import maplibre, {
type LngLatBoundsLike,
type MapLibreEvent,
type ProjectionSpecification,
type StyleSpecification
Expand All @@ -12,6 +13,11 @@

interface MapProps {
style?: StyleSpecification | string;
/**
* The initial bounds of the map. If specified, it overrides initialLocation.
*/
initialBounds?: LngLatBoundsLike;
maxBounds?: LngLatBoundsLike;
initialLocation?: Location;
allowRotation?: boolean;
allowZoom?: boolean;
Expand Down Expand Up @@ -55,6 +61,8 @@
allowZoom = true,
showDebug = false,
cursor,
initialBounds,
maxBounds,
initialLocation: receivedInitialLocation,
// Future: This should become bindable.readonly when that becomes
// available, see: https://github.com/sveltejs/svelte/issues/7712
Expand Down Expand Up @@ -88,8 +96,10 @@
minZoom,
maxZoom,
bearing,
attributionControl: false, // Added via component
attributionControl: false,
center: [initialLocation.lng, initialLocation.lat],
bounds: initialBounds || null,
maxBounds: maxBounds || null,
zoom: initialLocation.zoom,
pitch: initialLocation.pitch,
cooperativeGestures,
Expand Down