UNPKG

protomaps-leaflet

Version:

Vector tile rendering and labeling for [Leaflet](https://github.com/Leaflet/Leaflet).

71 lines (70 loc) 1.97 kB
import Point from "@mapbox/point-geometry"; import { PMTiles } from "pmtiles"; export declare type JsonValue = boolean | number | string | null | JsonArray | JsonObject; export interface JsonObject { [key: string]: JsonValue; } export interface JsonArray extends Array<JsonValue> { } export declare enum GeomType { Point = 1, Line = 2, Polygon = 3 } export interface Bbox { minX: number; minY: number; maxX: number; maxY: number; } export interface Feature { readonly props: JsonObject; readonly bbox: Bbox; readonly geomType: GeomType; readonly geom: Point[][]; readonly numVertices: number; } export interface Zxy { readonly z: number; readonly x: number; readonly y: number; } export declare function toIndex(c: Zxy): string; export interface TileSource { get(c: Zxy, tileSize: number): Promise<Map<string, Feature[]>>; } interface ZoomAbort { z: number; controller: AbortController; } export declare class PmtilesSource implements TileSource { p: PMTiles; zoomaborts: ZoomAbort[]; shouldCancelZooms: boolean; constructor(url: string | PMTiles, shouldCancelZooms: boolean); get(c: Zxy, tileSize: number): Promise<Map<string, Feature[]>>; } export declare class ZxySource implements TileSource { url: string; zoomaborts: ZoomAbort[]; shouldCancelZooms: boolean; constructor(url: string, shouldCancelZooms: boolean); get(c: Zxy, tileSize: number): Promise<Map<string, Feature[]>>; } interface CacheEntry { used: number; data: Map<string, Feature[]>; } interface PromiseOptions { resolve: (result: Map<string, Feature[]>) => void; reject: (e: Error) => void; } export declare class TileCache { source: TileSource; cache: Map<string, CacheEntry>; inflight: Map<string, PromiseOptions[]>; tileSize: number; constructor(source: TileSource, tileSize: number); get(c: Zxy): Promise<Map<string, Feature[]>>; } export {};