Add a GeoJSON line
Replicates the MapLibre example Add a GeoJSON line. Where the original hand-builds a Feature<LineString> inside addSource, the route: sugar takes just the coordinates.
The complete document
Section titled “The complete document”# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/add-a-geojson-line/# The `route:` sugar stands in for the hand-built Feature<LineString>.type: mapid: add-a-geojson-lineconfig: center: [-122.486052, 37.830348] zoom: 14 mapStyle: "https://demotiles.maplibre.org/style.json"layers: - id: route type: line source: type: geojson route: name: Lombard Street coordinates: - [-122.483696, 37.833818] - [-122.483482, 37.833174] - [-122.483396, 37.8327] - [-122.483568, 37.832056] - [-122.48404, 37.831141] - [-122.48404, 37.830497] - [-122.483482, 37.82992] - [-122.483568, 37.829548] - [-122.48507, 37.829446] - [-122.4861, 37.828802] - [-122.486958, 37.82931] - [-122.487001, 37.830802] - [-122.487516, 37.831683] - [-122.488031, 37.832158] - [-122.488889, 37.832971] - [-122.489876, 37.832632] - [-122.490434, 37.832937] - [-122.49125, 37.832429] - [-122.491636, 37.832564] - [-122.492237, 37.833378] - [-122.493782, 37.833683] layout: line-join: round line-cap: round paint: line-color: "#888888" line-width: 8What to notice
Section titled “What to notice”route:expands to aFeature<LineString>at parse time — the emittedstyle.jsoncarries canonical GeoJSON, so nothing downstream knows sugar was involved.layoutandpaintkeys are the MapLibre style-spec names, verbatim; no translation table to learn.