Arcs

Docs / Arcs

Overview

The <x-map-arc> component draws curved connections between pairs of points: flight paths, shipping lanes, trade flows, or any origin → destination data. Each arc is a quadratic Bézier curve that crosses the antimeridian the short way, so a Tokyo → San Francisco arc goes over the Pacific instead of around the world.

Pass an array of arcs to the :data prop. Each item needs from and to as [lng, lat] pairs and an optional id. Any extra fields become feature properties you can use in paint expressions, tooltips and popups.

Basic Usage

Connect one hub to several destinations:

Curvature

:curvature controls how far each arc bows away from the straight line (default 0.2). Use 0 for straight lines and a negative value to bow the other way. :samples sets how many points make up each curve (default 64).

blade
<x-map-arc
    :data="$flights"
    :curvature="0.35"
    :samples="96"
    :paint="['line-color' => '#f97316', 'line-width' => 3]"
    :fit-bounds="true"
/>

Interactive Arcs

Style arcs from their data with MapLibre expressions, highlight the hovered arc with :hover-paint, and show a tooltip with the <x-slot:tooltip> slot. This example colors air and sea routes with a match expression on a globe. Hover or click an arc:

In the tooltip and popup slots, {property} placeholders are replaced with the hovered arc's properties (values are HTML-escaped). {lat} and {lng} resolve to the pointer position. A wider invisible hit layer sits under each arc, so even thin arcs are easy to hover.

Paint & layout

:paint is merged over the defaults (line-color: #4285F4, line-width: 2, line-opacity: 0.85) and accepts any MapLibre line paint property, including data-driven expressions. :layout takes line layout properties (defaults to round joins and caps). :hover-paint values are applied only to the arc under the pointer.

Livewire Events

Interactive arcs dispatch map:arc-clicked and map:arc-hovered. The payload contains the arc layer id, the original arc item from your data, the pointer lat/lng and the mapId. When the pointer leaves an arc, map:arc-hovered fires again with arc: null. Click an arc below:

No arc selected yet.

Updating arc data

Arcs react to Livewire state: change the array bound to :data and the layer updates in place on the next render. To push new data without re-rendering, dispatch map:update-arc-data-{id}:

php
$this->dispatch('map:update-arc-data-events-arcs', data: $this->flights);

Props

PropTypeDefaultDescription
:dataarray[]Arcs as ['id' => ..., 'from' => [lng, lat], 'to' => [lng, lat], ...]. Extra fields become feature properties
id?stringuuidLayer id, used in event payloads and map:update-arc-data-{id}
:curvaturefloat0.2How far arcs bow. 0 = straight, negative bows the other way
:samplesint64Points per curve
:paintarray[]MapLibre line paint, merged over the defaults. Supports expressions
:layoutarray[]MapLibre line layout
:hover-paint?arraynullPaint applied to the hovered arc
:interactivebooltrueEnable hover, tooltip, popup and click events
before-id?stringnullInsert the layer below this existing layer id
:fit-boundsboolfalseFit the map to all arcs once loaded

Slots

SlotDescription
tooltipHTML shown on hover. {property}, {lat} and {lng} placeholders are filled in
popupHTML shown in a popup on click, with the same placeholders