Laravel Mapcn
Toggle sidebar

Markers

Docs / 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:

Marker Popup

Add a click-to-open popup to a marker with custom HTML content:

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:

Props

PropTypeDefaultDescription
:latfloatrequiredLatitude
:lngfloatrequiredLongitude
id?stringnullUnique identifier for events
:draggableboolfalseEnable user to drag the marker
colorstring'#1A56DB'Color for the default marker pin
anchorstring'bottom'Options: center, top, bottom, etc.
:offsetarray[0, 0]Pixel offset [x, y]
:rotationfloat0Clockwise rotation in degrees
rotation-alignmentstring'auto''map', 'viewport', or 'auto'
pitch-alignmentstring'auto''map', 'viewport', or 'auto'
classstring''CSS class for the marker container

Sub-Components

<x-marker-content>

Renders custom HTML as the marker icon. Place any HTML in the slot.

PropDescription
classCSS class for the wrapper element

<x-marker-label>

Adds a floating text label to the marker.

PropDescription
textLabel text content
positionOptions: top, bottom, left, right (Default: bottom)
classAdditional CSS classes

<x-marker-tooltip>

Adds a hover-triggered tooltip popup.

PropDescription
textTooltip text content
anchorCorner connection point
:offsetPixel offset [x, y]
classCSS class for the tooltip wrapper

<x-marker-popup>

Adds a click-to-open popup containing arbitrary HTML.

PropDescription
max-widthCSS max-width (Default: '300px')
:close-buttonToggle the little 'x' (Default: true)
:close-on-click-mapClose if map is clicked (Default: true)
:close-on-moveClose if map camera moves (Default: false)
anchorPopup connection point (Default: bottom)
:offsetPixel offset [x, y] (Default: [0, 0])
classCSS base class for the popup container