Controls
Overview
The <x-map-controls> component adds standard interactive controls to the map such as zoom buttons, compass, geolocation, fullscreen toggle, a scale bar and a 3D view toggle. For your own buttons and panels, use <x-map-control>. Nest both inside <x-map>.
Basic Usage
With Scale Bar
Enable the scale bar to show distance measurement on the map:
Positioning
Controls can be placed in any of the four map corners using the position prop:
top-left
top-right
(default)
bottom-left
bottom-right
3D View
Add :three-d="true" to get a 3D toggle button. It eases the camera to a pitch of 60° and a bearing of -20° and back to flat (tune with :three-d-pitch, :three-d-bearing and :three-d-duration), and dispatches map:3d-toggled with { enabled }. Pair it with the openfreemap-liberty provider, which has 3D building extrusions:
Custom Controls
<x-map-control> pins any Blade or Alpine markup to the map, styled as a control group (buttons are stacked with dividers and pick up the map's light/dark theme). Inside it, the $map Alpine magic returns the MapLibre instance, so buttons can call any Map method directly:
position accepts top-left (default), top-right, bottom-left, bottom-right, top and bottom (centered). Set :group="false" to drop the control-group styling and render your own panel, legend or search box. Buttons can also use wire:click to call your Livewire component.
| Prop | Type | Default | Description |
|---|---|---|---|
| position | string | 'top-left' | top-left, top-right, bottom-left, bottom-right, top, bottom |
| :group | bool | true | Style the content as a control group |
| class | string | '' | Additional CSS classes |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| :zoom | bool | true | Show zoom in/out buttons |
| :compass | bool | true | Show compass / bearing reset |
| :locate | bool | true | Show geolocation button |
| :fullscreen | bool | false | Show fullscreen toggle (overlays such as route lists and custom controls stay visible) |
| :scale | bool | false | Show map scale bar |
| scale-unit | string | 'metric' | metric, imperial or nautical |
| :three-d | bool | false | Show a 3D view toggle button |
| :three-d-pitch | int|float | 60 | Pitch used by the 3D toggle |
| :three-d-bearing | int|float | -20 | Bearing used by the 3D toggle |
| :three-d-duration | int | 1000 | 3D toggle animation duration (ms) |
| :visualize-pitch | bool | true | Tilt the compass to show the current pitch |
| :track-user | bool | true | Keep following the user's location after locating |
| position | string | 'top-right' | Position: top-right, top-left, bottom-right, bottom-left |
| class | string | '' | Additional CSS classes |