Function: addLogoImages()
addLogoImages(
map, ...sets):Promise<void>
Defined in: packages/sdvplot/src/maplibre.ts:275
Loads each logo of logoSymbols sets into the map's images, once: map.loadImage(url), then
map.addImage(id, image, { pixelRatio }), the pixel ratio making the image draw size px tall at icon size 1 (and
stay sharp on a high-density screen). An image the map already has is skipped, so calling it again adds nothing
twice. map.setStyle drops the map's images, sources and layers: on the map's style.load event, call it again
(it adds back only what the new style lacks) and re-add the source and layer. A logo that fails to load is left undrawn with one
warning. Resolves when every image is in. Call it before adding the layers that draw them.
Parameters
map
sets
...readonly LogoSymbols[]
Returns
Promise<void>
Example
import { loadLeague } from "@sportsdataverse/sdvplot";
import { addLogoImages, logoSymbols } from "@sportsdataverse/sdvplot/maplibre";
await loadLeague("nfl");
const logos = logoSymbols([{ team: "KC", lon: -94.714, lat: 39.297 }], { x: "lon", y: "lat", team: "team", league: "nfl" });
// a stand-in for a MapLibre map (in the browser: the map from `new maplibregl.Map(...)`, once it has loaded)
const added: string[] = [];
const map = {
hasImage: (id: string) => added.includes(id),
loadImage: async () => ({ data: { width: 500, height: 500 } as ImageBitmap }),
addImage(id: string) {
added.push(id);
return this;
},
};
await addLogoImages(map as never, logos);
added;