<script lang="ts">
import { Map, MapControlContainer, MapZoomControl } from '$lib/components/ui/map/index.js';
</script>
<Map class="size-full" viewport={{ center: [2.3522, 48.8566], zoom: 11, bearing: 0, pitch: 0 }}>
<MapControlContainer position="top-right">
<MapZoomControl />
</MapControlContainer>
</Map>
The zoom control is a vertical pair of buttons. Each press zooms by step levels, one by default. A button turns disabled when the map reaches its minimum or maximum zoom, so keyboard and screen reader users know they hit the limit.
Usage
Place the control inside a Control Container. The container pins it to a corner of the map.
<script lang="ts">
import { Map, MapControlContainer, MapZoomControl } from '$lib/components/ui/map/index.js';
</script>
<Map class="h-96">
<MapControlContainer position="top-right">
<MapZoomControl />
</MapControlContainer>
</Map>Step size
Set step to zoom further per press. Fractions work too.
<MapZoomControl step={0.5} />Reduced motion
The zoom eases over a short animation. When the user prefers reduced motion, the map jumps to the new zoom instead.
API Reference
MapZoomControl
Props
| Name | Type | Description |
|---|---|---|
step | number | Zoom levels to move per click. Defaults to 1. |
Other attributes go to the underlying <div>.