Markers
Overview
The <x-map-marker> component displays interactive markers on the map. Markers support custom colors, labels, tooltips, popups, dragging, and fully custom HTML content.
Basic Marker
Labels & Tooltips
Add text labels near the marker and hover tooltips using sub-components:
Rich Label & Tooltip Content
Omit the text prop on <x-marker-label> or <x-marker-tooltip> and put any HTML in the slot instead:
Mon to Sat, 10:00 to 17:00
Marker Popup
Add a click-to-open popup to a marker with custom HTML content. By default the popup has no fixed anchor: MapLibre places it on the side with the most room, 16px above the marker. Pass anchor (e.g. "bottom") to pin it to one side:
Our HQ
Visit us anytime!
Custom Marker Content
Replace the default marker pin with completely custom HTML using <x-marker-content>:
Multiple Markers
Add as many markers as you need, each with their own props. Use :opacity to fade a marker (the green one below is at 0.5):
Reactive Markers
Markers inside <x-map> update reactively from Livewire state. When a property changes, markers are added, moved, updated or removed without re-creating the map, so you do not need a wire:ignore wrapper. Give each marker rendered in a loop a stable wire:key:
class StoreMap extends Component { public array $stores = [ ['id' => 1, 'name' => 'Soho', 'lat' => 51.513, 'lng' => -0.136], ['id' => 2, 'name' => 'Camden', 'lat' => 51.539, 'lng' => -0.142], ]; public function addStore(float $lat, float $lng): void { $this->stores[] = ['id' => uniqid(), 'name' => 'New store', 'lat' => $lat, 'lng' => $lng]; } }
<x-map :center="[-0.14, 51.52]" :zoom="12"> @foreach ($stores as $store) <x-map-marker wire:key="store-{{ $store['id'] }}" :lat="$store['lat']" :lng="$store['lng']" > <x-marker-label :text="$store['name']" /> </x-map-marker> @endforeach </x-map>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| :lat | float | required | Latitude |
| :lng | float | required | Longitude |
| id | ?string | null | Unique identifier for events |
| :draggable | bool | false | Enable user to drag the marker |
| color | string | '#1A56DB' | Color for the default marker pin |
| anchor | string | 'bottom' | Options: center, top, bottom, etc. |
| :offset | array | [0, 0] | Pixel offset [x, y] |
| :rotation | float | 0 | Clockwise rotation in degrees |
| rotation-alignment | string | 'auto' | 'map', 'viewport', or 'auto' |
| pitch-alignment | string | 'auto' | 'map', 'viewport', or 'auto' |
| :opacity | ?float | null | Marker opacity from 0 to 1 (null keeps it fully opaque) |
| class | string | '' | CSS class for the marker container |
Sub-Components
<x-marker-content>
Renders custom HTML as the marker icon. Place any HTML in the slot.
| Prop | Description |
|---|---|
| class | CSS class for the wrapper element |
<x-marker-label>
Adds a floating label to the marker. Use text for plain text, or omit it and use the slot for rich content.
| Prop | Description |
|---|---|
| text | Plain label text (Default: null, uses the slot) |
| position | Options: top, bottom, left, right (Default: bottom) |
| class | Additional CSS classes |
<x-marker-tooltip>
Adds a hover-triggered tooltip. Use text for plain text, or omit it and use the slot for rich content.
| Prop | Description |
|---|---|
| text | Plain tooltip text (Default: null, uses the slot) |
| anchor | Tooltip connection point, e.g. top, bottom, left (Default: null, MapLibre picks the side with the most room) |
| :offset | Pixel offset as a number or [x, y] (Default: null, 16px above the marker) |
| class | CSS class for the tooltip wrapper |
<x-marker-popup>
Adds a click-to-open popup containing arbitrary HTML.
| Prop | Description |
|---|---|
| max-width | CSS max-width (Default: '300px') |
| :close-button | Toggle the little 'x' (Default: true) |
| :close-on-click-map | Close if map is clicked (Default: true) |
| :close-on-move | Close if map camera moves (Default: false) |
| anchor | Popup connection point, e.g. top, bottom, left (Default: null, auto: MapLibre picks the side with the most room) |
| :offset | Pixel offset as a number or [x, y] (Default: null, 16px above the marker) |
| class | CSS base class for the popup container |