ts-maps 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-map/control/FullscreenControl.d.ts +39 -0
- package/dist/core-map/control/GeocoderControl.d.ts +61 -0
- package/dist/core-map/control/LocateControl.d.ts +5 -2
- package/dist/core-map/control/NavigationControl.d.ts +39 -0
- package/dist/core-map/control/index.d.ts +6 -0
- package/dist/core-map/game/TerritoryLog.d.ts +66 -0
- package/dist/core-map/game/TerritoryStore.d.ts +59 -0
- package/dist/core-map/game/index.d.ts +11 -0
- package/dist/core-map/game/loop.d.ts +61 -0
- package/dist/core-map/geo/area.d.ts +52 -0
- package/dist/core-map/geo/index.d.ts +30 -0
- package/dist/core-map/geo/index.js +826 -1
- package/dist/core-map/geo/polygonClip.d.ts +75 -0
- package/dist/core-map/geo/validate.d.ts +54 -0
- package/dist/core-map/index.d.ts +7 -2
- package/dist/core-map/layer/GeoJSONTileSource.d.ts +50 -0
- package/dist/core-map/layer/RunTrailLayer.d.ts +35 -0
- package/dist/core-map/layer/TerritoryLayer.d.ts +62 -0
- package/dist/core-map/layer/index.d.ts +6 -0
- package/dist/core-map/layer/tile/RasterDEMLayer.d.ts +4 -0
- package/dist/core-map/layer/tile/VectorTileMapLayer.d.ts +59 -11
- package/dist/core-map/layer/tile/urlTemplate.d.ts +1 -2
- package/dist/core-map/map/Map.d.ts +32 -1
- package/dist/core-map/mvt/DecodedTile.d.ts +20 -0
- package/dist/core-map/mvt/FlatTile.d.ts +25 -0
- package/dist/core-map/mvt/VectorTileFeature.d.ts +8 -0
- package/dist/core-map/style-spec/expressions/formatted.d.ts +36 -0
- package/dist/core-map/style-spec/expressions/operators/binding.d.ts +1 -0
- package/dist/core-map/style-spec/expressions/operators/geometry.d.ts +19 -0
- package/dist/core-map/style-spec/expressions/types.d.ts +3 -0
- package/dist/core-map/style-spec/index.js +459 -42
- package/dist/core-map/style-spec/schema.d.ts +43 -3
- package/dist/core-map/style-spec/types.d.ts +47 -7
- package/dist/core-map/styles/basemap.d.ts +41 -0
- package/dist/core-map/styles/index.d.ts +5 -0
- package/dist/core-map/styles/palette.d.ts +31 -0
- package/dist/core-map/symbols/CollisionIndex.d.ts +22 -5
- package/dist/core-map/symbols/GlyphAtlas.d.ts +6 -1
- package/dist/core-map/symbols/GlyphProvider.d.ts +21 -0
- package/dist/core-map/symbols/GlyphRenderer.d.ts +48 -0
- package/dist/core-map/symbols/IconAtlas.d.ts +10 -1
- package/dist/core-map/symbols/SymbolOverlay.d.ts +47 -0
- package/dist/core-map/symbols/index.d.ts +4 -0
- package/dist/core-map/symbols/index.js +1071 -67
- package/dist/core-map/symbols/loadGlyphs.d.ts +53 -0
- package/dist/core-map/symbols/loadSprite.d.ts +57 -0
- package/dist/core-map/symbols/placement.d.ts +67 -0
- package/dist/core-map/symbols/sdf.d.ts +37 -0
- package/dist/core-map/symbols/sections.d.ts +32 -0
- package/dist/core-map/workers/WorkerPool.d.ts +40 -0
- package/dist/core-map/workers/decodeMvtFlat.d.ts +52 -0
- package/dist/index.js +11548 -5996
- package/package.json +1 -1
- package/src/core-map/ts-maps.css +392 -99
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Everything covered by either. */
|
|
2
|
+
export declare function union(subject: MultiPolygon, clip: MultiPolygon): MultiPolygon;
|
|
3
|
+
/** Only what both cover. */
|
|
4
|
+
export declare function intersection(subject: MultiPolygon, clip: MultiPolygon): MultiPolygon;
|
|
5
|
+
/** What `subject` covers and `clip` does not — the shape of a territory steal. */
|
|
6
|
+
export declare function difference(subject: MultiPolygon, clip: MultiPolygon): MultiPolygon;
|
|
7
|
+
/** Covered by one but not both. */
|
|
8
|
+
export declare function xor(subject: MultiPolygon, clip: MultiPolygon): MultiPolygon;
|
|
9
|
+
/** Do these overlap at all? Cheaper than measuring the intersection. */
|
|
10
|
+
export declare function intersects(subject: MultiPolygon, clip: MultiPolygon): boolean;
|
|
11
|
+
/** Is a `[lng, lat]` position inside this multipolygon? */
|
|
12
|
+
export declare function contains(multi: MultiPolygon, point: Position): boolean;
|
|
13
|
+
declare const INTERSECTION: 0;
|
|
14
|
+
declare const UNION: 1;
|
|
15
|
+
declare const DIFFERENCE: 2;
|
|
16
|
+
declare const XOR: 3;
|
|
17
|
+
// Boolean operations on polygons: union, intersection, difference, xor.
|
|
18
|
+
//
|
|
19
|
+
// A territory game runs on these. Finishing a lap unions the new loop into
|
|
20
|
+
// whatever the player already held; running through a rival's ground subtracts
|
|
21
|
+
// it from theirs. Both operations happen constantly and on shapes that share
|
|
22
|
+
// edges — two territories that grew against each other are exactly coincident
|
|
23
|
+
// along the border between them — so the naive clippers are not an option.
|
|
24
|
+
// Greiner–Hormann, for instance, is short and readable and falls apart on the
|
|
25
|
+
// shared-edge case, which here is not an edge case but the normal one.
|
|
26
|
+
//
|
|
27
|
+
// This is the Martínez–Rueda–Feito sweep-line algorithm, which handles
|
|
28
|
+
// coincident edges, self-touching contours and holes as part of its design
|
|
29
|
+
// rather than as patches. The sweep is faithful to the paper. Assembling the
|
|
30
|
+
// output contours afterwards is done differently: rather than tracking
|
|
31
|
+
// exterior/interior depth inside the sweep, result edges are walked into rings
|
|
32
|
+
// and nesting is worked out by containment at the end. That is a slower step
|
|
33
|
+
// and a far easier one to reason about — and being able to reason about it
|
|
34
|
+
// matters when it decides who owns what.
|
|
35
|
+
export type Position = number[];
|
|
36
|
+
export type Ring = Position[];
|
|
37
|
+
export type Polygon = Ring[];
|
|
38
|
+
export type MultiPolygon = Polygon[];
|
|
39
|
+
declare type Operation = typeof INTERSECTION | typeof UNION | typeof DIFFERENCE | typeof XOR;
|
|
40
|
+
declare class SweepEvent {
|
|
41
|
+
point: Position;
|
|
42
|
+
left: boolean;
|
|
43
|
+
otherEvent: SweepEvent;
|
|
44
|
+
isSubject: boolean;
|
|
45
|
+
type: number;
|
|
46
|
+
inOut: boolean;
|
|
47
|
+
otherInOut: boolean;
|
|
48
|
+
inResult: boolean;
|
|
49
|
+
contourId: number;
|
|
50
|
+
constructor(point: Position, left: boolean, otherEvent: SweepEvent | null, isSubject: boolean, type?: unknown);
|
|
51
|
+
isBelow(p: Position): boolean;
|
|
52
|
+
isAbove(p: Position): boolean;
|
|
53
|
+
isVertical(): boolean;
|
|
54
|
+
}
|
|
55
|
+
/** A binary heap, so the queue can take the events division produces. */
|
|
56
|
+
declare class EventQueue {
|
|
57
|
+
get length(): number;
|
|
58
|
+
push(event: SweepEvent): void;
|
|
59
|
+
pop(): SweepEvent | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The sweep line status: segments currently crossed, ordered bottom to top.
|
|
63
|
+
*
|
|
64
|
+
* A sorted array rather than a balanced tree. Insertion is linear, which makes
|
|
65
|
+
* the sweep quadratic in the worst case — acceptable here, where the shapes are
|
|
66
|
+
* territories with hundreds of vertices rather than coastlines with millions,
|
|
67
|
+
* and worth it for a structure whose behaviour is obvious when a result looks
|
|
68
|
+
* wrong.
|
|
69
|
+
*/
|
|
70
|
+
declare class SweepStatus {
|
|
71
|
+
insert(event: SweepEvent): number;
|
|
72
|
+
remove(event: SweepEvent): void;
|
|
73
|
+
indexOf(event: SweepEvent): number;
|
|
74
|
+
at(index: number): SweepEvent | null;
|
|
75
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { MultiPolygon, Ring } from './polygonClip';
|
|
2
|
+
/**
|
|
3
|
+
* Check a ring is something that can be claimed.
|
|
4
|
+
*
|
|
5
|
+
* Throws rather than returning a flag, because every caller's correct response
|
|
6
|
+
* to unusable geometry is to stop, and a boolean invites carrying on.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateRing(ring: Ring): void;
|
|
9
|
+
/**
|
|
10
|
+
* Make a ring's longitudes continuous.
|
|
11
|
+
*
|
|
12
|
+
* A run crossing the antimeridian is recorded as longitudes that jump from
|
|
13
|
+
* 179.99 to -179.99, and every consumer of that ring — area, the clipper,
|
|
14
|
+
* anything measuring an edge — reads the jump as a segment spanning the globe.
|
|
15
|
+
* Carrying the winding forward instead produces longitudes outside the usual
|
|
16
|
+
* range but geometry that means what the runner did.
|
|
17
|
+
*
|
|
18
|
+
* A ring not near the antimeridian is returned untouched, so this costs a scan
|
|
19
|
+
* and nothing else in the overwhelmingly common case.
|
|
20
|
+
*/
|
|
21
|
+
export declare function unwrapRing(ring: Ring): Ring;
|
|
22
|
+
/**
|
|
23
|
+
* Split a self-crossing ring into the simple loops it is made of.
|
|
24
|
+
*
|
|
25
|
+
* Walking the ring and cutting it at each crossing is what separates a figure
|
|
26
|
+
* of eight into its two lobes. The crossing point is computed once and used as
|
|
27
|
+
* a vertex of both loops, which is the reason to do it this way rather than by
|
|
28
|
+
* unioning the shape with itself: the sweep would compute that point twice,
|
|
29
|
+
* from two different pairs of segments, and at GPS precision the two answers
|
|
30
|
+
* differ in the last bits — enough for a lobe to be dropped.
|
|
31
|
+
*/
|
|
32
|
+
export declare function splitSelfIntersecting(ring: Ring): Ring[];
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a ring that crosses itself into polygons that do not.
|
|
35
|
+
*
|
|
36
|
+
* A figure of eight has a signed area of nearly zero — its lobes have opposite
|
|
37
|
+
* winding and cancel — so measuring it directly says the runner enclosed
|
|
38
|
+
* nothing. Both lobes were run around, so both should count.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveSelfIntersections(ring: Ring): MultiPolygon;
|
|
41
|
+
/** Does any pair of non-adjacent segments in this ring cross? */
|
|
42
|
+
export declare function selfIntersects(ring: Ring): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Everything above, in the order a claim needs it.
|
|
45
|
+
*
|
|
46
|
+
* Validate, then unwrap, then resolve — each step assumes the previous one has
|
|
47
|
+
* run, and repairing geometry that has not been checked is how a NaN ends up
|
|
48
|
+
* inside a polygon instead of inside an error message.
|
|
49
|
+
*/
|
|
50
|
+
export declare function prepareClaim(ring: Ring): MultiPolygon;
|
|
51
|
+
/** Thrown for geometry that cannot be repaired into a claim. */
|
|
52
|
+
export declare class InvalidGeometryError extends Error {
|
|
53
|
+
constructor(message: string);
|
|
54
|
+
}
|
package/dist/core-map/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AttributionControl, Control, LayersControl, LocateControl, ScaleControl, ZoomControl } from './control/index';
|
|
1
|
+
import { AttributionControl, Control, FullscreenControl, GeocoderControl, LayersControl, LocateControl, NavigationControl, ScaleControl, ZoomControl } from './control/index';
|
|
2
2
|
import { Circle, CircleMarker, DivIcon, FeatureGroup, GeoJSON, GridLayer, HeatmapLayer, RasterDEMLayer, Icon, ImageOverlay, LayerGroup, Marker, Polygon, Polyline, Popup, Rectangle, SVGOverlay, TileLayer, Tooltip, VectorTileMapLayer, VideoOverlay, WMSTileLayer } from './layer/index';
|
|
3
3
|
import { TsMap } from './map/index';
|
|
4
4
|
import * as services from './services/index';
|
|
5
|
+
import * as styles from './styles/index';
|
|
5
6
|
export type { CircleOptions as WebGLCircleOptions, GLContextOptions, LineOptions as WebGLLineOptions, Mat4 } from './renderer/webgl/index';
|
|
6
7
|
/**
|
|
7
8
|
* ts - maps — a modern TypeScript interactive map library.
|
|
@@ -41,6 +42,9 @@ export declare const control: Factory < ConstructorParameters < typeof Control>,
|
|
|
41
42
|
attribution: Factory < ConstructorParameters < typeof AttributionControl>, AttributionControl>
|
|
42
43
|
scale: Factory < ConstructorParameters < typeof ScaleControl>, ScaleControl>
|
|
43
44
|
locate: Factory < ConstructorParameters < typeof LocateControl>, LocateControl>
|
|
45
|
+
geocoder: Factory < ConstructorParameters < typeof GeocoderControl>, GeocoderControl>
|
|
46
|
+
navigation: Factory < ConstructorParameters < typeof NavigationControl>, NavigationControl>
|
|
47
|
+
fullscreen: Factory < ConstructorParameters < typeof FullscreenControl>, FullscreenControl>
|
|
44
48
|
};
|
|
45
49
|
// Default namespace object grouping all public exports.
|
|
46
50
|
declare const tsMap: Record<string, unknown>;
|
|
@@ -50,11 +54,12 @@ export * from './control/index';
|
|
|
50
54
|
export * from './core/index';
|
|
51
55
|
export * from './dom/index';
|
|
52
56
|
export * from './geometry/index';
|
|
57
|
+
export * from './game/index';
|
|
53
58
|
export * from './geo/index';
|
|
54
59
|
export * from './layer/index';
|
|
55
60
|
export * from './map/index';
|
|
56
61
|
export * from './storage/index';
|
|
57
62
|
export { earcut, flatten, deviation } from './geometry/earcut';
|
|
58
63
|
export { WebGLTileRenderer, WebGLUnsupportedError } from './renderer/webgl/index';
|
|
59
|
-
export { services };
|
|
64
|
+
export { services, styles };
|
|
60
65
|
export default tsMap;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts a `GeoJSONClusterSource` to the same tile shape.
|
|
3
|
+
*
|
|
4
|
+
* The cluster source already answers per tile, but in GeoJSON coordinates — it
|
|
5
|
+
* was built to feed markers, not a renderer. This projects its points into
|
|
6
|
+
* tile-local extent space so clustered data can be painted by ordinary style
|
|
7
|
+
* layers, with `point_count` available to expressions exactly as in Mapbox.
|
|
8
|
+
*/
|
|
9
|
+
export declare function clusterTileSource(cluster: { getTile: (z: number, x: number, y: number) => { features: Array<{ geometry: { coordinates: [number, number] }, properties: Record<string, unknown>, id?: number }> } | null }, layerName?: string): { getTile: (z: number, x: number, y: number) => { layers: Record<string, LocalLayer> } | null };
|
|
10
|
+
export declare interface GeoJSONTileSourceOptions {
|
|
11
|
+
layerName?: string
|
|
12
|
+
buffer?: number
|
|
13
|
+
maxZoom?: number
|
|
14
|
+
}
|
|
15
|
+
declare interface IndexedFeature {
|
|
16
|
+
type: 1 | 2 | 3
|
|
17
|
+
id?: number | string
|
|
18
|
+
properties: Record<string, unknown>
|
|
19
|
+
rings: Ring[]
|
|
20
|
+
bbox: [number, number, number, number]
|
|
21
|
+
}
|
|
22
|
+
declare type Ring = Array<{ x: number, y: number }>;
|
|
23
|
+
/** A decoded-tile-shaped feature, duck-typed to `VectorTileFeature`. */
|
|
24
|
+
declare class LocalFeature {
|
|
25
|
+
type: 1 | 2 | 3;
|
|
26
|
+
id?: number | string;
|
|
27
|
+
properties: Record<string, unknown>;
|
|
28
|
+
extent: number;
|
|
29
|
+
_rings: Ring[];
|
|
30
|
+
constructor(source: IndexedFeature, rings: Ring[]);
|
|
31
|
+
loadGeometry(): Ring[];
|
|
32
|
+
bbox(): [number, number, number, number];
|
|
33
|
+
}
|
|
34
|
+
declare class LocalLayer {
|
|
35
|
+
name: string;
|
|
36
|
+
extent: number;
|
|
37
|
+
length: number;
|
|
38
|
+
_features: LocalFeature[];
|
|
39
|
+
constructor(name: string, features: LocalFeature[]);
|
|
40
|
+
feature(index: number): LocalFeature;
|
|
41
|
+
}
|
|
42
|
+
export declare class GeoJSONTileSource {
|
|
43
|
+
_features: IndexedFeature[];
|
|
44
|
+
_layerName: string;
|
|
45
|
+
_buffer: number;
|
|
46
|
+
constructor(data?: unknown, options?: GeoJSONTileSourceOptions);
|
|
47
|
+
setData(data: unknown): this;
|
|
48
|
+
get length(): number;
|
|
49
|
+
getTile(z: number, x: number, y: number): { layers: Record<string, LocalLayer> } | null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Layer } from './Layer';
|
|
2
|
+
import type { Position } from '../geo/polygonClip';
|
|
3
|
+
export declare function runTrailLayer(options?: RunTrailLayerOptions): RunTrailLayer;
|
|
4
|
+
export declare interface RunTrailLayerOptions {
|
|
5
|
+
color?: string
|
|
6
|
+
weight?: number
|
|
7
|
+
opacity?: number
|
|
8
|
+
showPotential?: boolean
|
|
9
|
+
potentialOpacity?: number
|
|
10
|
+
showHead?: boolean
|
|
11
|
+
pulse?: boolean
|
|
12
|
+
pane?: string
|
|
13
|
+
attribution?: string
|
|
14
|
+
}
|
|
15
|
+
export declare class RunTrailLayer extends Layer {
|
|
16
|
+
_canvas?: HTMLCanvasElement;
|
|
17
|
+
_ctx?: CanvasRenderingContext2D | null;
|
|
18
|
+
_track: Position[];
|
|
19
|
+
_frame?: number;
|
|
20
|
+
_ratio: number;
|
|
21
|
+
initialize(options?: RunTrailLayerOptions): void;
|
|
22
|
+
setTrack(track: Position[]): this;
|
|
23
|
+
addPoint(position: Position): this;
|
|
24
|
+
clear(): this;
|
|
25
|
+
get track(): Position[];
|
|
26
|
+
redraw(): this;
|
|
27
|
+
onAdd(_map: any): void;
|
|
28
|
+
onRemove(_map: any): void;
|
|
29
|
+
getEvents(): Record<string, any>;
|
|
30
|
+
_pixelRatio(): number;
|
|
31
|
+
_resize(): void;
|
|
32
|
+
_draw(): void;
|
|
33
|
+
_drawPotential(ctx: CanvasRenderingContext2D, points: Array<{ x: number, y: number }>, color: string, alpha: number): void;
|
|
34
|
+
_drawHead(ctx: CanvasRenderingContext2D, point: { x: number, y: number }, color: string, pulse: boolean): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Layer } from './Layer';
|
|
2
|
+
import type { CaptureResult, TerritoryStore } from '../game/TerritoryStore';
|
|
3
|
+
import type { MultiPolygon, Position } from '../geo/polygonClip';
|
|
4
|
+
export declare function territoryLayer(options?: TerritoryLayerOptions): TerritoryLayer;
|
|
5
|
+
export declare interface TerritoryStyle {
|
|
6
|
+
color?: string
|
|
7
|
+
fillOpacity?: number
|
|
8
|
+
weight?: number
|
|
9
|
+
glow?: boolean
|
|
10
|
+
hatch?: boolean
|
|
11
|
+
label?: boolean
|
|
12
|
+
}
|
|
13
|
+
export declare interface TerritoryLayerOptions {
|
|
14
|
+
store?: TerritoryStore
|
|
15
|
+
styles?: Record<string, TerritoryStyle>
|
|
16
|
+
defaultStyle?: TerritoryStyle
|
|
17
|
+
self?: string
|
|
18
|
+
captureDuration?: number
|
|
19
|
+
labelMinZoom?: number
|
|
20
|
+
units?: 'metric' | 'imperial'
|
|
21
|
+
pane?: string
|
|
22
|
+
attribution?: string
|
|
23
|
+
}
|
|
24
|
+
declare interface CaptureAnimation {
|
|
25
|
+
owner: string
|
|
26
|
+
ring: Position[]
|
|
27
|
+
start: number
|
|
28
|
+
duration: number
|
|
29
|
+
}
|
|
30
|
+
export declare class TerritoryLayer extends Layer {
|
|
31
|
+
_canvas?: HTMLCanvasElement;
|
|
32
|
+
_ctx?: CanvasRenderingContext2D | null;
|
|
33
|
+
_store?: TerritoryStore;
|
|
34
|
+
_manual: Map<string, MultiPolygon>;
|
|
35
|
+
_animations: CaptureAnimation[];
|
|
36
|
+
_frame?: number;
|
|
37
|
+
_assigned: Map<string, string>;
|
|
38
|
+
_ratio: number;
|
|
39
|
+
_onStoreChange?: () => void;
|
|
40
|
+
_onStoreCapture?: (result: CaptureResult) => void;
|
|
41
|
+
initialize(options?: TerritoryLayerOptions): void;
|
|
42
|
+
setStore(store: TerritoryStore): this;
|
|
43
|
+
setTerritory(owner: string, territory: MultiPolygon): this;
|
|
44
|
+
setOwnerStyle(owner: string, style: TerritoryStyle): this;
|
|
45
|
+
animateCapture(result: { owner: string, ring: Position[] }): this;
|
|
46
|
+
colorFor(owner: string): string;
|
|
47
|
+
redraw(): this;
|
|
48
|
+
onAdd(_map: any): void;
|
|
49
|
+
onRemove(_map: any): void;
|
|
50
|
+
getEvents(): Record<string, any>;
|
|
51
|
+
ownerAtContainerPoint(point: { x: number, y: number }): string | null;
|
|
52
|
+
_detachStore(): void;
|
|
53
|
+
_pixelRatio(): number;
|
|
54
|
+
_resize(): void;
|
|
55
|
+
_territories(): Array<[string, MultiPolygon]>;
|
|
56
|
+
_draw(): void;
|
|
57
|
+
_styleFor(owner: string): Required<TerritoryStyle>;
|
|
58
|
+
_drawTerritory(ctx: CanvasRenderingContext2D, owner: string, territory: MultiPolygon, project: (p: Position) => { x: number, y: number }): void;
|
|
59
|
+
_drawHatch(ctx: CanvasRenderingContext2D, color: string): void;
|
|
60
|
+
_drawLabels(ctx: CanvasRenderingContext2D, territory: MultiPolygon, color: string, project: (p: Position) => { x: number, y: number }): void;
|
|
61
|
+
_drawCaptures(ctx: CanvasRenderingContext2D, project: (p: Position) => { x: number, y: number }): void;
|
|
62
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export type { GeoJSONTileSourceOptions } from './GeoJSONTileSource';
|
|
1
2
|
export type { ClusterOptions, ClusterPoint } from './GeoJSONClusterSource';
|
|
2
3
|
export type { HeatmapLayerOptions, HeatmapPoint } from './HeatmapLayer';
|
|
4
|
+
export type { TerritoryLayerOptions, TerritoryStyle } from './TerritoryLayer';
|
|
5
|
+
export type { RunTrailLayerOptions } from './RunTrailLayer';
|
|
3
6
|
export { BlanketOverlay } from './BlanketOverlay';
|
|
4
7
|
export { DivOverlay } from './DivOverlay';
|
|
5
8
|
export { FeatureGroup } from './FeatureGroup';
|
|
6
9
|
export { GeoJSON } from './GeoJSON';
|
|
7
10
|
export { GeoJSONClusterSource, KDBush } from './GeoJSONClusterSource';
|
|
11
|
+
export { GeoJSONTileSource } from './GeoJSONTileSource';
|
|
8
12
|
export { HeatmapLayer } from './HeatmapLayer';
|
|
13
|
+
export { TerritoryLayer, territoryLayer } from './TerritoryLayer';
|
|
14
|
+
export { RunTrailLayer, runTrailLayer } from './RunTrailLayer';
|
|
9
15
|
export { ImageOverlay } from './ImageOverlay';
|
|
10
16
|
export { Layer } from './Layer';
|
|
11
17
|
export { LayerGroup } from './LayerGroup';
|
|
@@ -19,6 +19,10 @@ export declare interface RasterDEMLayerOptions {
|
|
|
19
19
|
tileSize?: number
|
|
20
20
|
minZoom?: number
|
|
21
21
|
maxZoom?: number
|
|
22
|
+
minNativeZoom?: number
|
|
23
|
+
maxNativeZoom?: number
|
|
24
|
+
className?: string
|
|
25
|
+
zIndex?: number
|
|
22
26
|
exaggeration?: number
|
|
23
27
|
azimuth?: number
|
|
24
28
|
altitude?: number
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
import { CollisionIndex } from '../../symbols/CollisionIndex';
|
|
1
2
|
import { GlyphAtlas } from '../../symbols/GlyphAtlas';
|
|
2
3
|
import { GridLayer } from './GridLayer';
|
|
3
4
|
import { IconAtlas } from '../../symbols/IconAtlas';
|
|
4
5
|
import { RTree } from '../../geometry/RTree';
|
|
6
|
+
import { SymbolOverlay } from '../../symbols/SymbolOverlay';
|
|
5
7
|
import { TileCache } from '../../storage/index';
|
|
6
|
-
import { VectorTile } from '../../mvt/VectorTile';
|
|
7
|
-
import { VectorTileFeature } from '../../mvt/VectorTileFeature';
|
|
8
8
|
import { WebGLTileRenderer } from '../../renderer/webgl/WebGLTileRenderer';
|
|
9
|
+
import { WorkerPool } from '../../workers/WorkerPool';
|
|
10
|
+
import type { BBox } from '../../geometry/RTree';
|
|
9
11
|
import type { CompiledExpression } from '../../style-spec/expressions/index';
|
|
12
|
+
import type { DecodedFeature, DecodedTile } from '../../mvt/DecodedTile';
|
|
13
|
+
import type { GlyphProvider } from '../../symbols/GlyphProvider';
|
|
10
14
|
import type { Point } from '../../geometry/Point';
|
|
15
|
+
/** Drop the shared pool. Tests, and teardown in long-lived hosts. */
|
|
16
|
+
export declare function shutdownDecodePool(): Promise<void>;
|
|
11
17
|
// ---------------------------------------------------------------------------
|
|
12
18
|
// Public types
|
|
13
19
|
// ---------------------------------------------------------------------------
|
|
14
20
|
export declare interface VectorTileMapLayerOptions {
|
|
15
|
-
url
|
|
21
|
+
url?: string
|
|
22
|
+
localSource?: { getTile: (z: number, x: number, y: number) => any | null }
|
|
23
|
+
zoomOffset?: number
|
|
16
24
|
subdomains?: string | string[]
|
|
17
25
|
minZoom?: number
|
|
18
26
|
maxZoom?: number
|
|
19
27
|
maxNativeZoom?: number
|
|
28
|
+
minNativeZoom?: number
|
|
29
|
+
sourceMaxZoom?: number
|
|
30
|
+
workers?: boolean | number
|
|
20
31
|
tileSize?: number
|
|
21
32
|
attribution?: string
|
|
22
33
|
pane?: string
|
|
@@ -64,6 +75,9 @@ export declare interface VectorTilePaintProperties {
|
|
|
64
75
|
'text-halo-color'?: string
|
|
65
76
|
'text-halo-width'?: number
|
|
66
77
|
'icon-opacity'?: number
|
|
78
|
+
'icon-color'?: string
|
|
79
|
+
'icon-halo-color'?: string
|
|
80
|
+
'icon-halo-width'?: number
|
|
67
81
|
}
|
|
68
82
|
export declare interface VectorTileLayoutProperties {
|
|
69
83
|
visibility?: 'visible' | 'none'
|
|
@@ -75,11 +89,21 @@ export declare interface VectorTileLayoutProperties {
|
|
|
75
89
|
'icon-image'?: string | unknown
|
|
76
90
|
'icon-size'?: number
|
|
77
91
|
'icon-rotate'?: number
|
|
78
|
-
'symbol-placement'?: 'point'
|
|
92
|
+
'symbol-placement'?: 'point' | 'line' | 'line-center'
|
|
93
|
+
'symbol-spacing'?: number
|
|
94
|
+
'symbol-sort-key'?: unknown
|
|
79
95
|
'symbol-priority'?: number
|
|
96
|
+
'text-allow-overlap'?: unknown
|
|
97
|
+
'icon-allow-overlap'?: unknown
|
|
98
|
+
'text-ignore-placement'?: unknown
|
|
99
|
+
'icon-ignore-placement'?: unknown
|
|
100
|
+
'text-anchor'?: unknown
|
|
101
|
+
'text-offset'?: unknown
|
|
102
|
+
'text-rotate'?: unknown
|
|
103
|
+
'text-max-angle'?: unknown
|
|
80
104
|
}
|
|
81
105
|
export declare interface QueryRenderedFeature {
|
|
82
|
-
feature:
|
|
106
|
+
feature: DecodedFeature
|
|
83
107
|
layer: VectorTileStyleLayer
|
|
84
108
|
tile: { x: number, y: number, z: number }
|
|
85
109
|
}
|
|
@@ -89,7 +113,7 @@ export declare interface QueryRenderedFeaturesOptions {
|
|
|
89
113
|
layers?: string[]
|
|
90
114
|
}
|
|
91
115
|
export declare interface QuerySourceFeature {
|
|
92
|
-
feature:
|
|
116
|
+
feature: DecodedFeature
|
|
93
117
|
sourceLayer: string
|
|
94
118
|
tile: { x: number, y: number, z: number }
|
|
95
119
|
}
|
|
@@ -103,19 +127,26 @@ declare interface RTreeItem {
|
|
|
103
127
|
// Internal bookkeeping: alongside each Canvas we track the decoded tile so
|
|
104
128
|
// `queryRenderedFeatures` can re-project hit-tests to tile-local coords.
|
|
105
129
|
declare interface DecodedTileEntry {
|
|
130
|
+
sourceKey?: string
|
|
131
|
+
sourcePending?: boolean
|
|
106
132
|
canvas: HTMLCanvasElement
|
|
107
|
-
tile:
|
|
133
|
+
tile: DecodedTile | null
|
|
108
134
|
coords: { x: number, y: number, z: number }
|
|
109
135
|
abort: AbortController
|
|
110
136
|
index: RTree<RTreeItem> | null
|
|
111
137
|
gl: WebGLTileRenderer | null
|
|
112
138
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
139
|
+
/** Extent coordinates to where they currently are on screen. */
|
|
140
|
+
declare type ProjectPoint = (x: number, y: number) => { x: number, y: number } | null;
|
|
116
141
|
export declare class VectorTileMapLayer extends GridLayer {
|
|
117
142
|
_styleLayers: VectorTileStyleLayer[];
|
|
118
143
|
_decodedTiles: Map<HTMLCanvasElement, DecodedTileEntry>;
|
|
144
|
+
_workersUsable: boolean;
|
|
145
|
+
_glyphs?: { source: unknown, provider: GlyphProvider };
|
|
146
|
+
_sourceCache: Map<string, { tile: DecodedTile, index: RTree<RTreeItem>, refs: number }>;
|
|
147
|
+
_sourcePending: Map<string, { promise: Promise<{ tile: DecodedTile, index: RTree<RTreeItem> }>, refs: number, abort: AbortController }>;
|
|
148
|
+
_symbolOverlay?: SymbolOverlay;
|
|
149
|
+
_symbolHandlers?: Record<string, () => void>;
|
|
119
150
|
_featureStateLookup?: (src: string, srcLayer: string, id: number | string) => Record<string, unknown>;
|
|
120
151
|
_sourceId?: string;
|
|
121
152
|
_glyphAtlas?: GlyphAtlas;
|
|
@@ -129,17 +160,34 @@ export declare class VectorTileMapLayer extends GridLayer {
|
|
|
129
160
|
setSourceId(id: string): this;
|
|
130
161
|
_repaintDecodedTiles(): void;
|
|
131
162
|
setStyleLayers(layers: VectorTileStyleLayer[]): this;
|
|
163
|
+
updateStyleLayers(layers: VectorTileStyleLayer[]): this;
|
|
132
164
|
getStyleLayer(id: string): VectorTileStyleLayer | undefined;
|
|
133
165
|
queryRenderedFeatures(opts?: QueryRenderedFeaturesOptions): QueryRenderedFeature[];
|
|
134
166
|
queryRenderedFeatures(point: Point, opts?: QueryRenderedFeaturesOptions): QueryRenderedFeature[];
|
|
135
167
|
queryRenderedFeatures(pointOrOpts?: Point | QueryRenderedFeaturesOptions, maybeOpts?: QueryRenderedFeaturesOptions): QueryRenderedFeature[];
|
|
136
168
|
querySourceFeatures(opts?: { sourceLayer?: string, filter?: unknown }): QuerySourceFeature[];
|
|
169
|
+
_pixelRatio(): number;
|
|
137
170
|
createTile(coords: Point & { z: number }, done: (err: any, tile: HTMLElement) => void): HTMLElement;
|
|
171
|
+
onAdd(map: any): void;
|
|
138
172
|
onRemove(map: any): void;
|
|
139
173
|
_removeTile(key: string): void;
|
|
140
174
|
getTileUrl(coords: Point & { z: number }): string;
|
|
175
|
+
_subTile(coords: { x: number, y: number, z: number }): { x: number, y: number, z: number, f: number, sx: number, sy: number };
|
|
141
176
|
_getZoomForUrl(z: number): number;
|
|
177
|
+
_initSymbolOverlay(): void;
|
|
178
|
+
_destroySymbolOverlay(): void;
|
|
179
|
+
_refreshSymbols(): void;
|
|
180
|
+
_projectTilePoint(coords: { x: number, y: number, z: number }, localX: number, localY: number): { x: number, y: number } | null;
|
|
181
|
+
_drawSymbols(ctx: CanvasRenderingContext2D, collision: CollisionIndex): void;
|
|
182
|
+
_drawLocalTile(source: { getTile: (z: number, x: number, y: number) => any | null }, canvas: HTMLCanvasElement, entry: DecodedTileEntry, coords: Point & { z: number }, done: (err: any, tile: HTMLElement) => void): void;
|
|
183
|
+
_glyphProvider(): GlyphProvider | undefined;
|
|
184
|
+
_abortLoading(): void;
|
|
185
|
+
_sourceKey(coords: { x: number, y: number, z: number }): string;
|
|
186
|
+
_acquireSource(key: string, url: string, entry: DecodedTileEntry): Promise<{ tile: DecodedTile, index: RTree<RTreeItem> }>;
|
|
187
|
+
_decode(bytes: Uint8Array): Promise<DecodedTile>;
|
|
188
|
+
_workerPool(): WorkerPool | null;
|
|
189
|
+
_releaseSource(entry: DecodedTileEntry): void;
|
|
142
190
|
_fetchAndDraw(url: string, canvas: HTMLCanvasElement, entry: DecodedTileEntry, coords: Point & { z: number }, done: (err: any, tile: HTMLElement) => void): Promise<void>;
|
|
143
191
|
_fetchTileBytes(url: string, entry: DecodedTileEntry): Promise<Uint8Array>;
|
|
144
|
-
_drawTile(canvas: HTMLCanvasElement, tile:
|
|
192
|
+
_drawTile(canvas: HTMLCanvasElement, tile: DecodedTile, coords: Point & { z: number }): void;
|
|
145
193
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Point } from '../../geometry/Point';
|
|
2
1
|
// Pick a subdomain for a given tile coord. Stable, so the same tile always
|
|
3
2
|
// resolves to the same subdomain — important for HTTP-cache friendliness.
|
|
4
|
-
export declare function getSubdomain(tilePoint:
|
|
3
|
+
export declare function getSubdomain(tilePoint: { x: number, y: number }, subdomains: string | string[]): string;
|
|
5
4
|
// Compose a URL from a template and a bag of variables. The template may
|
|
6
5
|
// reference any key provided in `data`; missing keys throw (so typos fail
|
|
7
6
|
// loudly rather than silently producing a broken URL).
|
|
@@ -32,6 +32,8 @@ export declare interface MapOptions {
|
|
|
32
32
|
maxPitch?: number
|
|
33
33
|
minPitch?: number
|
|
34
34
|
zoomSnap?: number
|
|
35
|
+
theme?: 'light' | 'dark' | 'auto'
|
|
36
|
+
style?: any
|
|
35
37
|
zoomDelta?: number
|
|
36
38
|
trackResize?: boolean
|
|
37
39
|
[key: string]: any
|
|
@@ -88,6 +90,21 @@ export declare class TsMap extends Evented {
|
|
|
88
90
|
_pitch: number;
|
|
89
91
|
_container: HTMLElement & { _tsmap_id?: number };
|
|
90
92
|
_containerId?: number;
|
|
93
|
+
_geoJSONSources?: Record<string, {
|
|
94
|
+
index: any
|
|
95
|
+
layer: any
|
|
96
|
+
clustered: boolean
|
|
97
|
+
/** A `heatmap` style layer over this source, fed the same data. */
|
|
98
|
+
heatmap?: any
|
|
99
|
+
/** The property a simple `["get", k]` weight reads, if that is what it is. */
|
|
100
|
+
heatmapWeightKey?: string
|
|
101
|
+
}>;
|
|
102
|
+
_styleLoadToken?: number;
|
|
103
|
+
_spriteToken?: number;
|
|
104
|
+
_glyphSource?: any;
|
|
105
|
+
_theme?: 'light' | 'dark' | 'auto';
|
|
106
|
+
_themeQuery?: MediaQueryList;
|
|
107
|
+
_themeQueryListener?: (event: MediaQueryListEvent) => void;
|
|
91
108
|
_loaded?: boolean;
|
|
92
109
|
_zoom: number;
|
|
93
110
|
_lastCenter?: LatLng | null;
|
|
@@ -288,19 +305,27 @@ export declare class TsMap extends Evented {
|
|
|
288
305
|
_tryAnimatedZoom(center: any, zoom: number, options?: any): boolean;
|
|
289
306
|
_animateZoom(center: LatLng, zoom: number, startAnim?: boolean, noUpdate?: boolean): void;
|
|
290
307
|
_onZoomTransitionEnd(): void;
|
|
291
|
-
setStyle(style: StyleSpec, opts?: { diff?: boolean, validate?: boolean }): this;
|
|
308
|
+
setStyle(style: StyleSpec | string, opts?: { diff?: boolean, validate?: boolean }): this;
|
|
309
|
+
_syncStyleBackground(): void;
|
|
310
|
+
_styleBackgroundColor(): string | undefined;
|
|
311
|
+
_initGlyphSource(): void;
|
|
312
|
+
getGlyphSource(): any;
|
|
313
|
+
isFontAvailable(textFont: string | string[] | undefined): boolean;
|
|
314
|
+
_loadSprite(): void;
|
|
292
315
|
getStyle(): StyleSpec | undefined;
|
|
293
316
|
isStyleLoaded(): boolean;
|
|
294
317
|
addSource(sourceId: string, source: SourceSpecification): this;
|
|
295
318
|
getSource(sourceId: string): SourceSpecification | undefined;
|
|
296
319
|
removeSource(sourceId: string): this;
|
|
297
320
|
_makeSourceLayer(sourceId: string, source: SourceSpecification): unknown;
|
|
321
|
+
setSourceData(sourceId: string, data: unknown): this;
|
|
298
322
|
addStyleLayer(layer: LayerSpecification, before?: string): this;
|
|
299
323
|
removeStyleLayer(id: string): this;
|
|
300
324
|
getStyleLayer(id: string): LayerSpecification | undefined;
|
|
301
325
|
setPaintProperty(layerId: string, name: string, value: unknown): this;
|
|
302
326
|
setLayoutProperty(layerId: string, name: string, value: unknown): this;
|
|
303
327
|
setFilter(layerId: string, filter: unknown): this;
|
|
328
|
+
_syncStyleLayer(layerId: string): void;
|
|
304
329
|
on(type: any, a?: any, b?: any, c?: any): this;
|
|
305
330
|
off(type?: any, a?: any, b?: any, c?: any): this;
|
|
306
331
|
once(type: any, a?: any, b?: any, c?: any): this;
|
|
@@ -325,6 +350,12 @@ export declare class TsMap extends Evented {
|
|
|
325
350
|
getTerrain(): TerrainOptions | null;
|
|
326
351
|
getTerrainSource(): TerrainSource | undefined;
|
|
327
352
|
setRenderer(name: 'canvas2d' | 'webgl' | 'svg'): this;
|
|
353
|
+
setTheme(theme: 'light' | 'dark' | 'auto'): this;
|
|
354
|
+
getTheme(): 'light' | 'dark' | 'auto';
|
|
355
|
+
_applyTheme(dark: boolean): void;
|
|
356
|
+
_detachThemeQuery(): void;
|
|
357
|
+
setProjection(projection: 'mercator' | 'globe'): this;
|
|
358
|
+
getProjection(): 'mercator' | 'globe';
|
|
328
359
|
getPreferredRenderer(): 'canvas2d' | 'webgl' | 'svg';
|
|
329
360
|
queryTerrainElevation(lngLat: LatLng | { lng: number, lat: number }): number | null;
|
|
330
361
|
toCanvas(): HTMLCanvasElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GeoJSONFeature, VectorTileProperties } from './VectorTileFeature';
|
|
2
|
+
import type { Point } from '../geometry/Point';
|
|
3
|
+
export declare interface DecodedFeature {
|
|
4
|
+
id?: number
|
|
5
|
+
type: 1 | 2 | 3
|
|
6
|
+
extent: number
|
|
7
|
+
properties: VectorTileProperties
|
|
8
|
+
loadGeometry: () => Point[][]
|
|
9
|
+
bbox: () => [number, number, number, number]
|
|
10
|
+
toGeoJSON: (x: number, y: number, z: number) => GeoJSONFeature
|
|
11
|
+
}
|
|
12
|
+
export declare interface DecodedLayer {
|
|
13
|
+
name?: string
|
|
14
|
+
extent: number
|
|
15
|
+
length: number
|
|
16
|
+
feature: (i: number) => DecodedFeature
|
|
17
|
+
}
|
|
18
|
+
export declare interface DecodedTile {
|
|
19
|
+
layers: Record<string, DecodedLayer>
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Point } from '../geometry/Point';
|
|
2
|
+
import type { FlatLayer, FlatTile as FlatTileData } from '../workers/decodeMvtFlat';
|
|
3
|
+
import type { GeoJSONFeature, VectorTileProperties } from './VectorTileFeature';
|
|
4
|
+
export declare class FlatTileFeature {
|
|
5
|
+
id?: number;
|
|
6
|
+
type: 1 | 2 | 3;
|
|
7
|
+
extent: number;
|
|
8
|
+
constructor(layer: FlatLayer, index: number);
|
|
9
|
+
get properties(): VectorTileProperties;
|
|
10
|
+
loadGeometry(): Point[][];
|
|
11
|
+
bbox(): [number, number, number, number];
|
|
12
|
+
toGeoJSON(x: number, y: number, z: number): GeoJSONFeature;
|
|
13
|
+
}
|
|
14
|
+
export declare class FlatTileLayer {
|
|
15
|
+
name: string;
|
|
16
|
+
version: number;
|
|
17
|
+
extent: number;
|
|
18
|
+
length: number;
|
|
19
|
+
constructor(data: FlatLayer);
|
|
20
|
+
feature(i: number): FlatTileFeature;
|
|
21
|
+
}
|
|
22
|
+
export declare class FlatTile {
|
|
23
|
+
layers: Record<string, FlatTileLayer>;
|
|
24
|
+
constructor(data: FlatTileData);
|
|
25
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Point } from '../geometry/Point';
|
|
2
2
|
import type { Pbf } from '../proto/Pbf';
|
|
3
|
+
/**
|
|
4
|
+
* Project tile-local rings to WGS84 and wrap them as a GeoJSON feature.
|
|
5
|
+
*
|
|
6
|
+
* Shared rather than duplicated: tiles decoded in a worker arrive as flat
|
|
7
|
+
* typed arrays and are wrapped by `FlatTile`, which has the same job to do
|
|
8
|
+
* here and must produce byte-identical output.
|
|
9
|
+
*/
|
|
10
|
+
export declare function geometryToGeoJSON(type: number, rings: Point[][], extent: number, x: number, y: number, z: number, properties: VectorTileProperties, id?: number): GeoJSONFeature;
|
|
3
11
|
// MVT GeomType enum values (tile.proto).
|
|
4
12
|
export declare const MVT_GEOM_UNKNOWN: number;
|
|
5
13
|
export declare const MVT_GEOM_POINT: number;
|