UNPKG

leaflet-vector-offline

Version:

Plugin for Leaflet.js that supports offline vector map tiles.

109 lines (108 loc) 4.04 kB
declare const L: any; import { KeyedHtmlCanvasElement, Status, VectorLayerOptions } from "./types"; import { Bounds, Coords, DoneCallback } from "leaflet"; import { TileInfo } from "leaflet.offline"; import * as protomapsLeaflet from "protomaps-leaflet"; export declare class VectorOfflineLayer extends L.TileLayer { backgroundColor: string | undefined; debug: string | undefined; labelers: protomapsLeaflet.Labelers; labelRules: protomapsLeaflet.LabelRule[]; lang: string | undefined; lastRequestedZ: number | undefined; paintRules: protomapsLeaflet.PaintRule[]; scratch: CanvasRenderingContext2D; sourcePriority: "online" | "offline" | "both"; tasks: Promise<Status>[] | undefined; tileDelay: number; tileSize: number; views: Map<string, protomapsLeaflet.View>; _url: string; constructor(url: string, options: VectorLayerOptions); /** * Clear the layout of the labels. This is useful when the map is panned or * zoomed, and the labels need to be re-laid out. */ clearLayout(): void; /** * Create a tile element for the given coordinates and callback when it's * ready. * * @param coords Coordinates of the tile * @param done Callback function * * @returns HTMLCanvasElement of the vector tile. */ createTile(coords: Coords, done: DoneCallback): KeyedHtmlCanvasElement; /** * Get the tile url for the given bounds and zoom level. * * @param bounds Tile bounds. * @param zoom Zoom level. * * @returns Array of TileInfo objects. */ getTileUrls(bounds: Bounds, zoom: number): TileInfo[]; /** * Render the tile for the given coordinates using vector data. * * @param coords The coordinates of the tile. * @param element The HTMLCanvasElement of the tile. * @param key The key of the tile to render. This is dependent on the source * of the tile data. I.e., if the tile data is from the offline source or the * online source. * @param url The URL of the tile data. * @param done callback function to be called when the tile is rendered. */ renderTile(coords: Coords, element: KeyedHtmlCanvasElement, key: string, url: string, done?: () => void): Promise<void>; /** * Rerender all the tiles. */ rerenderTiles(): void; /** * Rerender the tile with the given key. * * @param key The key of the tile to rerender. */ rerenderTile(key: string): void; /** * Query the features at the given point. * * A primitive way to check the features at a certain point. It does not * support hover states, cursor changes, or changing the style of the selected * feature, so is only appropriate for debuggging or very basic use cases. * Those features are outside of the scope of this library: for fully * pickable, interactive features, use MapLibre GL JS instead. * * @param lng longitude of the point to query * @param lat latitude of the point to query * @param brushSize brush size to query the features * @returns Map of source name to the features at the given point. */ queryTileFeaturesDebug(lng: number, lat: number, brushSize?: number): Map<string, protomapsLeaflet.PickedFeature[]>; /** * Remove the tile with the given key. * * @param key key of the tile to remove. */ _removeTile(key: string): void; /** * Get the subdomain for the given point. * * @param coords The coordinates of the tile to get the subdomain. * * @returns The subdomain for the given point. */ private _getStorageKey; private _validateKey; } /** * Create a new VectorOfflineLayer object. * * @param url The URL of the vector tile. * @param options The options for the vector map. * * @returns A new VectorOfflineLayer object. */ export declare function vectorOfflineLayer(url: string, options: VectorLayerOptions): VectorOfflineLayer; export {};