WxMultilayerManager manages multiple WxTileSource and provides methods to set time and preload tiles for all sources.

Example

    // Get the API ready - should be ONE per application
const wxapi = new WxAPI({ dataServerURL, maskURL: 'none', qtreeURL: 'none' });

const wxdatasetManager = await wxapi.createDatasetManager('gfs.global');

const layerManager = new WxMultilayerManager();

const layer1 = wxdatasetManager.createSourceLayer({ variable: 'air.visibility' }, { id: 'wxsource1', opacity: 1.0 });
layerManager.addSource(layer1);
await addWxLayer(layer1);

const layer2 = wxdatasetManager.createSourceLayer({ variable: 'air.humidity.at-2m' }, { id: 'wxsource2', opacity: 0.7 });
layerManager.addSource(layer2);
await addWxLayer(layer2);

const times = layer1.getAllTimes().slice(0, 10);
await layerManager.preloadTimes(times);

let t = 0;
const nextTimeStep = async () => {
await layerManager.setTime(t++ % times.length); // await always !!
setTimeout(nextTimeStep, 0);
};

setTimeout(nextTimeStep);

Hierarchy

  • WxMultilayerManager

Constructors

Properties

_sources: Map<string, WxTileSource> = ...

Methods

  • Preloads data for a specific time across all sources.

    Returns

    A Promise that resolves when all data has been preloaded.

    Parameters

    • time: WxDate

      The time to preload data for.

    • Optional requestInit: WxRequestInit

      Optional request options to pass to the underlying fetch requests.

    Returns Promise<void>

  • Preloads the specified times for all sources.

    Returns

    A Promise that resolves when all preloading is complete.

    Parameters

    • times: WxDate[]

      The array of WxDate objects to preload.

    • Optional requestInit: WxRequestInit

      Optional request options to pass to the preloadTime method of each source.

    Returns Promise<void>

  • Preloads the specified times for all sources using alternative method with rasterizing tiles but not put on screen. May be faster but may cause some artifacts if USER drags the map during preloading.

    Returns

    A Promise that resolves when all the renders have been preloaded.

    Parameters

    • times: WxDate[]

      The array of WxDate objects representing the times to preload.

    • Optional requestInit: WxRequestInit

      Optional WxRequestInit object to configure the request.

    Returns Promise<void>

  • Sets the time for all sources in the multilayer manager.

    Returns

    A Promise that resolves when all sources have set their time and redrawn their tiles.

    Parameters

    Returns Promise<void>

Generated using TypeDoc