Skip to main content

Function: routeLines()

routeLines(rows, o): RouteLines

Defined in: packages/sdvplot/src/maplibre.ts:317

Team-coloured travel legs as a GeoJSON source and a MapLibre line layer: one straight line per row from (x, y) to (xend, yend) in longitude and latitude, in the team's colour (line-color: ["get", "color"]). Each team keeps one colour, from the shared team palette; with background the colours read on the basemap (dark mode) and stay distinct. A team that does not resolve takes fallback. A coordinate may be a number or a numeric string, as for logoSymbols; a row with a missing, non-numeric or infinite one is left out with one warning. The feature id is the row's index. The same rows feed ./deckgl's passArcLayer for arcs instead.

Parameters​

rows​

readonly Row[]

o​

RouteLineOptions

Returns​

RouteLines

Example​

import { loadLeague } from "@sportsdataverse/sdvplot";
import { routeLines } from "@sportsdataverse/sdvplot/maplibre";

await loadLeague("nfl");
// Kansas City to Buffalo, airport to airport (nflverse nfldata airports.csv): week 11 of 2024
const leg = { team: "KC", lon: -94.714, lat: 39.297, lon_end: -78.732, lat_end: 42.94 };
const routes = routeLines([leg], { x: "lon", y: "lat", xend: "lon_end", yend: "lat_end", team: "team", league: "nfl" });
// in the browser: map.addSource(routes.id, routes.source); map.addLayer(routes.layer)
routes.source.data.features[0]?.properties.color;