@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
- isGlobeActive
- setTileLayerLoader
- toggleLandMask
- toggleLandSeaMaskColored
- toggleSeaMask
- whenMapInitialized
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
| Name | Type | Description |
|---|---|---|
AIRSPACES | number | Airspaces map overlay. |
BASE_MAP | number | Used 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. |
HURRICANES | number | Hurricane overlay. |
ISOLINES | number | Isolines 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_SEAMASK | number | Land/sea mask, to mask out some parts of the main weather map. |
LANDSEA_MASK_COLORED | number | Used for the colored land-sea layer. Bottom of the stack. |
MAIN | number | Main bucket for weather layers. Draws above the colored land/sea mask, but below everything else. |
PARTICLES | number | Particles overlay. |
PARTICLES_HIGH_ZOOM | number | Bucket where particles are moved if the map is zoomed in enough to show outdoor map instead of the grey base map. |
RADAR | number | Bucket for rendering radar layer. |
SATELLITE | number | Bucket for rendering satellite layer. |
WEBGL_POIS | number | WebGL POIs overlay (e.g. fire-spots). |
map
• Const map: any
Already initialized instance of LeafletGL Map
Example
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
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
| Name | Type | Description |
|---|---|---|
id | string | The string identifier of the calling component. |
loaderActive | boolean | Whether a loader is requested or not. |
Returns
void
Example
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
| Name | Type |
|---|---|
enableMask | boolean |
Returns
void
toggleLandSeaMaskColored
▸ toggleLandSeaMaskColored(enableMask): void
Parameters
| Name | Type |
|---|---|
enableMask | boolean |
Returns
void
toggleSeaMask
▸ toggleSeaMask(enableMask): void
Parameters
| Name | Type |
|---|---|
enableMask | boolean |
Returns
void
whenMapInitialized
▸ whenMapInitialized(callback): void
Parameters
| Name | Type |
|---|---|
callback | LoadCallback |
Returns
void