Laravel Mapcn
Toggle sidebar

Map

Docs / Map

Overview

The <x-map> component is the foundational building block for all maps. It initializes MapLibre GL JS, sets up the viewport, and provides the container for all child components like markers, popups, routes, and clusters.

Basic Usage

Tile Providers

Switch between built-in tile providers using the provider prop. You can also supply a custom MapLibre style JSON URL via the style prop.

Carto Positron (Light)

Carto Dark Matter

Theme Support

The theme prop controls how the map responds to dark mode. Set to "auto" (default) to follow your app's .dark class, or force "light" / "dark".

Props

PropTypeDefaultDescription
:centerarray[0, 0]Initial map center [lng, lat]
:zoom?intnullInitial zoom level (0–22)
:min-zoomint0Minimum zoom level
:max-zoomint22Maximum zoom level
provider?stringnullBuilt-in provider (e.g., carto-voyager, osm-raster)
style?stringnullCustom MapLibre style JSON URL (overrides provider)
themestring'auto''light', 'dark', or 'auto'
heightstring'full'CSS height (e.g., 500px, 100vh)
widthstring'100%'CSS width
:bearingfloat0Initial bearing in degrees
:pitchfloat0Initial pitch (0–60 degrees)
:interactivebooltrueEnable mouse/touch interactions
:scroll-zoombooltrueAllow mouse wheel zoom
:double-click-zoombooltrueAllow double-click zoom
:drag-panbooltrueAllow panning by drag
classstring''Additional CSS classes
light-style?stringnullStyle URL for light mode
dark-style?stringnullStyle URL for dark mode
:eventsarray[]MapLibre event names to forward