A custom layer source implementation for displaying weather data tiles. This class integrates with Leaflet and the WxTiles API to fetch, display, and manage tiles representing weather data such as temperature, wind speed, or other meteorological variables.

Example

async function initializeWxSource() {
try {
const wxapi = new WxAPI({ dataServerURL: 'http://dataserver.com' });
const datasetName = 'gfs.global';
const variable = 'air.temperature.at-2m';

// Create a dataset manager
const wxDatasetManager = await wxapi.createDatasetManager(datasetName);

// Create a layer source
const wxsource = wxdatasetManager.createSourceLayer(
{ variable },
{ attribution: 'WxTiles' },
);

console.log('WxTileSource initialized:', wxSource);
} catch (error) {
console.error('Error initializing WxTileSource:', error);
}
}

initializeWxSource();

Alternatively, use createSourceLayer to simplify the creation process.

Hierarchy

Constructors

Methods

  • Iterates over all tiles and applies a callback function.

    Returns

    An array of results from the callback function.

    Type Parameters

    • T

    Parameters

    • func: ((wxtile: WxTile) => T)

      The callback function to execute for each tile.

        • (wxtile: WxTile): T
        • Parameters

          • wxtile: WxTile

          Returns T

    • name: string

      A name for logging purposes.

    Returns T[]

  • Reloads the visible tiles on the map. This method is typically used during animations or time-based updates.

    Parameters

    • Optional requestInit: WxRequestInit

      Request options such as signals for aborting requests.

    Returns Promise<void>

  • Retrieves the coordinates of tiles currently visible on the map.

    Returns

    An array of tile coordinates.

    Returns XYZ[]

  • Creates a new tile element and loads its data.

    Returns

    The created canvas element representing the tile.

    Parameters

    • coords: Coords

      The coordinates of the tile to load.

    • done: DoneCallback

      A callback function to signal completion.

    Returns HTMLElement

  • Retrieves information about a specific point on the map.

    Returns

    Information about the tile at the specified point, or undefined if unavailable.

    Parameters

    • lnglat: WxLngLat

      The longitude and latitude of the point.

    • anymap: any

      The map instance. This is kept generic to allow flexibility.

    Returns undefined | WxTileInfo

  • Cleans up the layer when it is removed from a map.

    Returns

    The current WxTileSource instance.

    Parameters

    • map: Map

      The map instance.

    Returns WxTileSource

  • Redraws the tiles currently visible on the map. This ensures that updated raster data or animations are displayed.

    Returns void

Generated using TypeDoc