Adds a marker per row with the team's logo as its icon. A row whose team has no logo keeps leaflet's default marker, so no point is dropped silently.
Usage
addSdvLogoMarkers(
map,
lng,
lat,
team,
league,
size = 32,
season = NULL,
variant = "default",
id_system = "auto",
strict = FALSE,
data = leaflet::getMapData(map),
...
)Arguments
- map
A leaflet map.
- lng, lat
Longitudes and latitudes: vectors, or formulas read from
data.- team
Team identifiers: a vector, or a formula read from
data.- league
A league key from
sdv_leagues(). Required: one abbreviation means different teams in different leagues.- size
Icon width and height, in pixels.
- season
NULLfor today's logo, or a season (or one per row): a vector, or a formula read fromdata.- variant
"default","dark", or a named variant fromsdv_marks()("scoreboard","grayscale","cap_on_light", ...). A team without it gets its closest mark of the same polarity; a name no mark in the archive has is an error listing the league's variants.- id_system
"auto"(try every id system in priority order) or one id system:"team_id","espn","espn_abbr","nhl","nflverse","mlbstats","nba_api","hockeytech","ncaa","pff","cricinfo","cfbd","bref","sportsipy","fangraphs","sdvplotr","name", or"nhl_id"(NHL stats API ids, which overlap ESPN's, so"auto"never reads a number as one).- strict
If
TRUE, a value that does not resolve is an error; otherwise it becomesNAwith one warning per call.- data
The data formulas read; defaults to the map's.
- ...
Passed to
leaflet::addMarkers()(label,popup,layerId,group, ...); a vector one per row is split with the rows.
Examples
# \donttest{
if (requireNamespace("leaflet", quietly = TRUE)) {
d <- data.frame(team = c("KC", "BUF"), lon = c(-94.48, -78.79), lat = c(39.05, 42.77))
leaflet::leaflet(d) |>
leaflet::addTiles() |>
addSdvLogoMarkers(~lon, ~lat, ~team, league = "nfl", label = ~team)
}
# }
