The <x-map-route> component draws polylines on the map. It can also fetch real driving, walking, or cycling directions from an OSRM routing service, and optionally animate the route drawing.
Draw a simple line connecting a series of coordinates:
Show markers at each coordinate along the route using the :with-stops prop:
Fetch real road geometry from an OSRM server for driving, walking, or cycling directions:
Animate the route as it draws on the map:
<x-map-route :coordinates="$coords" :fetch-directions="true" directions-profile="driving" :animate="true" color="#06B6D4" />
| Prop | Type | Default | Description |
|---|---|---|---|
| :coordinates | array | required | Array of [lng, lat] pairs |
| color | string | '#1A56DB' | Line color |
| :width | int | 4 | Line width in pixels |
| :fetch-directions | bool | false | Fetch road geometry from OSRM |
| directions-profile | string | 'driving' | driving, walking, cycling |
| :animate | bool | false | Animate drawn route |
| :with-stops | bool | false | Show markers at each coordinate |