Skip to content

@windy/map

Already initialized instance of Leaflet map and other map related functions and stuff

Instance of Leaflet map is available as map in this module.

Windy.com uses Leaflet version 1.4.0 that is well documented here and contains plenty of plugins that you can use.

Table of contents

Variables

Functions

Variables

hasMask

hasMask: boolean = false


layerOrder

Const layerOrder: Object

Use this object to lookup proper order IDs for different layers. Higher order ID layers always draw on top of lower order ID layers.

Type declaration

NameTypeDescription
AIRSPACESnumberAirspaces map overlay.
BASE_MAPnumberUsed for the raster base map (the mostly transparent one with borders and outlines of water bodies). Draws above the weather layers and land/sea mask.
HURRICANESnumberHurricane overlay.
ISOLINESnumberIsolines overlay. Display on top of both hurricanes and airspaces, since neither contains any text (at least not in their canvases), but isolines do have text. Note that hurricane markers/popups will display above all MapLibre layers, including this one.
LANDMASK_SEAMASKnumberLand/sea mask, to mask out some parts of the main weather map.
LANDSEA_MASK_COLOREDnumberUsed for the colored land-sea layer. Bottom of the stack.
MAINnumberMain bucket for weather layers. Draws above the colored land/sea mask, but below everything else.
PARTICLESnumberParticles overlay.
PARTICLES_HIGH_ZOOMnumberBucket where particles are moved if the map is zoomed in enough to show outdoor map instead of the grey base map.
RADARnumberBucket for rendering radar layer.
SATELLITEnumberBucket for rendering satellite layer.
WEBGL_POISnumberWebGL POIs overlay (e.g. fire-spots).

map

Const map: any

Already initialized instance of LeafletGL Map

Example

js
import { map } from '@windy/map';

map.on('zoomend', () => {
   console.log('Map was zoomed');
});

markers

Const markers: Record<string, DivIcon>

Already initialized reusable set of minimalistic Leaflet markers

icon Pulsating icon

pulsatingIcon Pulsating icon forever

myLocationIcon Blue icon of user's location

Example

js
import { map, markers } from '@windy/map';

const myPulsatingMarker = marker([ 50, 14 ], {
    icon: markers.pulsatingIcon
  }).addTo( map );

Functions

isGlobeActive

isGlobeActive(): boolean

Just handy shortcut to detect that globe is active

Returns

boolean


setTileLayerLoader

setTileLayerLoader(id, loaderActive): void

Requests the presence of a large loader, or removes such request. Each loader request is tied to some id - any unique identifier of a component that requested it. A loader is displayed for as long as any component requests one.

Calling the function with setTileLayerLoader(id, true) when the loader was already requested before has no effect, and calling it with setTileLayerLoader(id, false) when the loader was already removed also has no effect.

Example: both "tileLayer" and "cityLabels" might be requesting the presence of a loader, but "cityLabels" are done loading before "tileLayer" and remove their request, but the loader is still visible until "tileLayer" also removes its loader request.

Parameters

NameTypeDescription
idstringThe string identifier of the calling component.
loaderActivebooleanWhether a loader is requested or not.

Returns

void

Example

ts
const loaderId = "tileLayer";
// Start of loading - we request a loader:
setTileLayerLoader(loaderId, true);
// Actually load something
await loadSomething();
// Remove our loader request:
setTileLayerLoader(loaderId, false);

toggleLandMask

toggleLandMask(enableMask): void

Parameters

NameType
enableMaskboolean

Returns

void


toggleLandSeaMaskColored

toggleLandSeaMaskColored(enableMask): void

Parameters

NameType
enableMaskboolean

Returns

void


toggleSeaMask

toggleSeaMask(enableMask): void

Parameters

NameType
enableMaskboolean

Returns

void


whenMapInitialized

whenMapInitialized(callback): void

Parameters

NameType
callbackLoadCallback

Returns

void