@trismegisto/maps 3.4.0 → 4.0.0
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/LICENSE +56 -56
- package/MIGRATION.md +831 -0
- package/NOTICE +29 -62
- package/README.md +19 -5
- package/dist/src/core/basemap.d.ts +5 -5
- package/dist/src/core/basemap.js +1 -1
- package/dist/src/core/basemap.js.map +1 -1
- package/dist/src/core/cluster-groups.d.ts +3 -3
- package/dist/src/core/cluster-groups.js.map +1 -1
- package/dist/src/core/engine.d.ts +22 -18
- package/dist/src/core/engine.js +36 -32
- package/dist/src/core/engine.js.map +1 -1
- package/dist/src/core/geo.d.ts +17 -17
- package/dist/src/core/geo.js +12 -12
- package/dist/src/core/geo.js.map +1 -1
- package/dist/src/core/geojson.d.ts +5 -5
- package/dist/src/core/geojson.js +7 -7
- package/dist/src/core/geojson.js.map +1 -1
- package/dist/src/core/interactions.d.ts +13 -36
- package/dist/src/core/interactions.js +64 -249
- package/dist/src/core/interactions.js.map +1 -1
- package/dist/src/core/map-layers.d.ts +13 -13
- package/dist/src/core/map-layers.js +7 -7
- package/dist/src/core/map-layers.js.map +1 -1
- package/dist/src/core/projection.d.ts +8 -8
- package/dist/src/core/projection.js +7 -7
- package/dist/src/core/projection.js.map +1 -1
- package/dist/src/core/route-view.d.ts +4 -4
- package/dist/src/core/route-view.js +5 -5
- package/dist/src/core/route-view.js.map +1 -1
- package/dist/src/core/route.d.ts +8 -8
- package/dist/src/core/route.js +11 -11
- package/dist/src/core/route.js.map +1 -1
- package/dist/src/core/shapes.d.ts +6 -6
- package/dist/src/core/shapes.js +5 -5
- package/dist/src/core/shapes.js.map +1 -1
- package/dist/src/core/tiles.d.ts +25 -17
- package/dist/src/core/tiles.js +32 -31
- package/dist/src/core/tiles.js.map +1 -1
- package/dist/src/core/vector.d.ts +5 -5
- package/dist/src/core/vector.js +3 -3
- package/dist/src/core/vector.js.map +1 -1
- package/dist/src/core/view.d.ts +12 -12
- package/dist/src/core/view.js +27 -27
- package/dist/src/core/view.js.map +1 -1
- package/package.json +44 -43
package/dist/src/core/geo.d.ts
CHANGED
|
@@ -2,48 +2,48 @@
|
|
|
2
2
|
* Tipos e utilitários geográficos e de geometria plana, sem framework.
|
|
3
3
|
*
|
|
4
4
|
* Coordenadas geográficas são sempre `{ lat, lng }` em graus (WGS 84). Pontos de tela são `{ x, y }` em
|
|
5
|
-
* pixels CSS. As entradas públicas também aceitam a tupla `[lat, lng]` (`
|
|
6
|
-
* `
|
|
5
|
+
* pixels CSS. As entradas públicas também aceitam a tupla `[lat, lng]` (`GeoPointInput`), normalizada por
|
|
6
|
+
* `toGeoPoint` — GeoJSON é a única exceção (lá a ordem é `[lng, lat]`, como manda a especificação).
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface GeoPoint {
|
|
9
9
|
readonly lat: number;
|
|
10
10
|
readonly lng: number;
|
|
11
11
|
}
|
|
12
12
|
/** `{ lat, lng }` ou `[lat, lng]`. */
|
|
13
|
-
export type
|
|
13
|
+
export type GeoPointInput = GeoPoint | readonly [number, number];
|
|
14
14
|
export interface Point {
|
|
15
15
|
readonly x: number;
|
|
16
16
|
readonly y: number;
|
|
17
17
|
}
|
|
18
18
|
/** Retângulo geográfico: canto sudoeste e canto nordeste. */
|
|
19
|
-
export interface
|
|
19
|
+
export interface GeoBox {
|
|
20
20
|
readonly south: number;
|
|
21
21
|
readonly west: number;
|
|
22
22
|
readonly north: number;
|
|
23
23
|
readonly east: number;
|
|
24
24
|
}
|
|
25
|
-
/** `
|
|
26
|
-
export type
|
|
25
|
+
/** `GeoBox` ou par de cantos opostos `[[lat, lng], [lat, lng]]` em qualquer ordem. */
|
|
26
|
+
export type GeoBoxInput = GeoBox | readonly [GeoPointInput, GeoPointInput];
|
|
27
27
|
/** Retângulo em pixels: `min` é o canto superior esquerdo, `max` o inferior direito. */
|
|
28
|
-
export interface
|
|
28
|
+
export interface PixelBox {
|
|
29
29
|
readonly min: Point;
|
|
30
30
|
readonly max: Point;
|
|
31
31
|
}
|
|
32
32
|
export declare function point(x: number, y: number): Point;
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
33
|
+
export declare function geoPoint(lat: number, lng: number): GeoPoint;
|
|
34
|
+
export declare function toGeoPoint(value: GeoPointInput): GeoPoint;
|
|
35
|
+
export declare function isGeoBox(value: unknown): value is GeoBox;
|
|
36
|
+
export declare function toGeoBox(value: GeoBoxInput): GeoBox;
|
|
37
37
|
/** Menor retângulo que contém todos os pontos. `null` sem pontos. */
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function
|
|
40
|
-
export declare function
|
|
38
|
+
export declare function boxOf(points: Iterable<GeoPoint>): GeoBox | null;
|
|
39
|
+
export declare function boxCenter(bounds: GeoBox): GeoPoint;
|
|
40
|
+
export declare function boxContains(bounds: GeoBox, p: GeoPoint): boolean;
|
|
41
41
|
export declare function addPoints(a: Point, b: Point): Point;
|
|
42
42
|
export declare function subtractPoints(a: Point, b: Point): Point;
|
|
43
43
|
export declare function scalePoint(a: Point, k: number): Point;
|
|
44
44
|
export declare function roundPoint(a: Point): Point;
|
|
45
|
-
export declare function
|
|
45
|
+
export declare function sameGeoPoint(a: GeoPoint, b: GeoPoint, epsilon?: number): boolean;
|
|
46
46
|
/** Distância em metros pela fórmula de haversine (esfera de raio médio). */
|
|
47
|
-
export declare function distanceMeters(a:
|
|
47
|
+
export declare function distanceMeters(a: GeoPoint, b: GeoPoint): number;
|
|
48
48
|
/** Leva a longitude para o intervalo [-180, 180). */
|
|
49
49
|
export declare function wrapLng(lng: number): number;
|
package/dist/src/core/geo.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Tipos e utilitários geográficos e de geometria plana, sem framework.
|
|
3
3
|
*
|
|
4
4
|
* Coordenadas geográficas são sempre `{ lat, lng }` em graus (WGS 84). Pontos de tela são `{ x, y }` em
|
|
5
|
-
* pixels CSS. As entradas públicas também aceitam a tupla `[lat, lng]` (`
|
|
6
|
-
* `
|
|
5
|
+
* pixels CSS. As entradas públicas também aceitam a tupla `[lat, lng]` (`GeoPointInput`), normalizada por
|
|
6
|
+
* `toGeoPoint` — GeoJSON é a única exceção (lá a ordem é `[lng, lat]`, como manda a especificação).
|
|
7
7
|
*/
|
|
8
8
|
export function point(x, y) {
|
|
9
9
|
return { x, y };
|
|
10
10
|
}
|
|
11
|
-
export function
|
|
11
|
+
export function geoPoint(lat, lng) {
|
|
12
12
|
return { lat, lng };
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function toGeoPoint(value) {
|
|
15
15
|
if (isTuple(value))
|
|
16
16
|
return { lat: Number(value[0]), lng: Number(value[1]) };
|
|
17
17
|
return { lat: Number(value.lat), lng: Number(value.lng) };
|
|
@@ -19,7 +19,7 @@ export function toLatLng(value) {
|
|
|
19
19
|
function isTuple(value) {
|
|
20
20
|
return Array.isArray(value);
|
|
21
21
|
}
|
|
22
|
-
export function
|
|
22
|
+
export function isGeoBox(value) {
|
|
23
23
|
return (!!value &&
|
|
24
24
|
typeof value === 'object' &&
|
|
25
25
|
!Array.isArray(value) &&
|
|
@@ -28,10 +28,10 @@ export function isLatLngBounds(value) {
|
|
|
28
28
|
'north' in value &&
|
|
29
29
|
'east' in value);
|
|
30
30
|
}
|
|
31
|
-
export function
|
|
32
|
-
if (
|
|
31
|
+
export function toGeoBox(value) {
|
|
32
|
+
if (isGeoBox(value))
|
|
33
33
|
return value;
|
|
34
|
-
const [a, b] = value.map(
|
|
34
|
+
const [a, b] = value.map(toGeoPoint);
|
|
35
35
|
return {
|
|
36
36
|
south: Math.min(a.lat, b.lat),
|
|
37
37
|
west: Math.min(a.lng, b.lng),
|
|
@@ -40,7 +40,7 @@ export function toLatLngBounds(value) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
/** Menor retângulo que contém todos os pontos. `null` sem pontos. */
|
|
43
|
-
export function
|
|
43
|
+
export function boxOf(points) {
|
|
44
44
|
let south = Infinity;
|
|
45
45
|
let west = Infinity;
|
|
46
46
|
let north = -Infinity;
|
|
@@ -55,10 +55,10 @@ export function boundsOf(points) {
|
|
|
55
55
|
}
|
|
56
56
|
return south === Infinity ? null : { south, west, north, east };
|
|
57
57
|
}
|
|
58
|
-
export function
|
|
58
|
+
export function boxCenter(bounds) {
|
|
59
59
|
return { lat: (bounds.south + bounds.north) / 2, lng: (bounds.west + bounds.east) / 2 };
|
|
60
60
|
}
|
|
61
|
-
export function
|
|
61
|
+
export function boxContains(bounds, p) {
|
|
62
62
|
return p.lat >= bounds.south && p.lat <= bounds.north && p.lng >= bounds.west && p.lng <= bounds.east;
|
|
63
63
|
}
|
|
64
64
|
export function addPoints(a, b) {
|
|
@@ -73,7 +73,7 @@ export function scalePoint(a, k) {
|
|
|
73
73
|
export function roundPoint(a) {
|
|
74
74
|
return { x: Math.round(a.x), y: Math.round(a.y) };
|
|
75
75
|
}
|
|
76
|
-
export function
|
|
76
|
+
export function sameGeoPoint(a, b, epsilon = 1e-9) {
|
|
77
77
|
return Math.abs(a.lat - b.lat) <= epsilon && Math.abs(a.lng - b.lng) <= epsilon;
|
|
78
78
|
}
|
|
79
79
|
/** Distância em metros pela fórmula de haversine (esfera de raio médio). */
|
package/dist/src/core/geo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo.js","sourceRoot":"","sources":["../../../src/core/geo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH,MAAM,UAAU,KAAK,CAAC,CAAS,EAAE,CAAS;IACxC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"geo.js","sourceRoot":"","sources":["../../../src/core/geo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH,MAAM,UAAU,KAAK,CAAC,CAAS,EAAE,CAAS;IACxC,OAAO,EAAE,CAAC,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AAG,GAAG,CAAC;IAC1D,OAAO,OAAO,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AACrD,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, Feature e
|
|
4
4
|
* FeatureCollection. Coordenadas GeoJSON são `[lng, lat]`; aqui viram `{ lat, lng }`.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { GeoPoint, GeoBox } from './geo';
|
|
7
7
|
export type GeoJsonPosition = readonly number[];
|
|
8
8
|
export interface GeoJsonPoint {
|
|
9
9
|
readonly type: 'Point';
|
|
@@ -51,18 +51,18 @@ export type GeoShape = {
|
|
|
51
51
|
readonly kind: 'point';
|
|
52
52
|
readonly feature: GeoJsonFeature;
|
|
53
53
|
readonly featureIndex: number;
|
|
54
|
-
readonly position:
|
|
54
|
+
readonly position: GeoPoint;
|
|
55
55
|
} | {
|
|
56
56
|
readonly kind: 'line' | 'area';
|
|
57
57
|
readonly feature: GeoJsonFeature;
|
|
58
58
|
readonly featureIndex: number;
|
|
59
59
|
/** Linhas (kind `line`) ou anéis — externo e furos — de um polígono (kind `area`). */
|
|
60
|
-
readonly rings: readonly (readonly
|
|
60
|
+
readonly rings: readonly (readonly GeoPoint[])[];
|
|
61
61
|
};
|
|
62
|
-
export declare function
|
|
62
|
+
export declare function positionToGeo(position: GeoJsonPosition): GeoPoint;
|
|
63
63
|
/** Lista de features do objeto: geometria solta vira uma feature sem propriedades. */
|
|
64
64
|
export declare function geoJsonFeatures(data: GeoJsonObject | null | undefined): GeoJsonFeature[];
|
|
65
65
|
/** Converte o GeoJSON em formas. Geometria desconhecida ou malformada é ignorada (não quebra o mapa). */
|
|
66
66
|
export declare function geoJsonShapes(data: GeoJsonObject | null | undefined): GeoShape[];
|
|
67
67
|
/** Retângulo que contém todas as formas. `null` se não há coordenadas. */
|
|
68
|
-
export declare function
|
|
68
|
+
export declare function geoJsonBox(data: GeoJsonObject | null | undefined): GeoBox | null;
|
package/dist/src/core/geojson.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, Feature e
|
|
4
4
|
* FeatureCollection. Coordenadas GeoJSON são `[lng, lat]`; aqui viram `{ lat, lng }`.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
export function
|
|
6
|
+
import { boxOf } from './geo';
|
|
7
|
+
export function positionToGeo(position) {
|
|
8
8
|
return { lat: Number(position[1]), lng: Number(position[0]) };
|
|
9
9
|
}
|
|
10
10
|
/** Lista de features do objeto: geometria solta vira uma feature sem propriedades. */
|
|
@@ -30,16 +30,16 @@ export function geoJsonShapes(data) {
|
|
|
30
30
|
return shapes;
|
|
31
31
|
}
|
|
32
32
|
function collect(geometry, feature, featureIndex, out) {
|
|
33
|
-
const ring = (coords) => (Array.isArray(coords) ? coords.filter(isPosition).map(
|
|
33
|
+
const ring = (coords) => (Array.isArray(coords) ? coords.filter(isPosition).map(positionToGeo) : []);
|
|
34
34
|
switch (geometry.type) {
|
|
35
35
|
case 'Point':
|
|
36
36
|
if (isPosition(geometry.coordinates))
|
|
37
|
-
out.push({ kind: 'point', feature, featureIndex, position:
|
|
37
|
+
out.push({ kind: 'point', feature, featureIndex, position: positionToGeo(geometry.coordinates) });
|
|
38
38
|
break;
|
|
39
39
|
case 'MultiPoint':
|
|
40
40
|
for (const p of geometry.coordinates ?? []) {
|
|
41
41
|
if (isPosition(p))
|
|
42
|
-
out.push({ kind: 'point', feature, featureIndex, position:
|
|
42
|
+
out.push({ kind: 'point', feature, featureIndex, position: positionToGeo(p) });
|
|
43
43
|
}
|
|
44
44
|
break;
|
|
45
45
|
case 'LineString':
|
|
@@ -66,7 +66,7 @@ function isPosition(value) {
|
|
|
66
66
|
return Array.isArray(value) && value.length >= 2 && Number.isFinite(value[0]) && Number.isFinite(value[1]);
|
|
67
67
|
}
|
|
68
68
|
/** Retângulo que contém todas as formas. `null` se não há coordenadas. */
|
|
69
|
-
export function
|
|
69
|
+
export function geoJsonBox(data) {
|
|
70
70
|
const points = [];
|
|
71
71
|
for (const shape of geoJsonShapes(data)) {
|
|
72
72
|
if (shape.kind === 'point')
|
|
@@ -75,6 +75,6 @@ export function geoJsonBounds(data) {
|
|
|
75
75
|
for (const ring of shape.rings)
|
|
76
76
|
points.push(...ring);
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return boxOf(points);
|
|
79
79
|
}
|
|
80
80
|
//# sourceMappingURL=geojson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../../../src/core/geojson.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"geojson.js","sourceRoot":"","sources":["../../../src/core/geojson.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAoB,KAAK,EAAE,MAAM,OAAO,CAAC;AAqEhD,MAAM,UAAU,aAAa,CAAC,QAAyB;IACrD,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,IAAsC;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,mBAAmB;YACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAChE,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,CAAC,CAAC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C,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7G,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,IAAsC;IAC/D,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;;YACnD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gestos do mapa sobre `MapEngine`, por pointer events (mouse, caneta e toque com o mesmo código):
|
|
3
|
-
* arrastar com inércia, pinça, roda do mouse/trackpad, duplo clique e teclado.
|
|
4
|
-
*
|
|
5
|
-
* Elementos com `data-hm-map-nodrag` (controles, popups) não iniciam arrasto nem zoom por duplo clique.
|
|
6
|
-
*/
|
|
7
1
|
import { Point } from './geo';
|
|
8
2
|
import { MapEngine } from './engine';
|
|
9
3
|
export interface InteractionOptions {
|
|
10
|
-
readonly
|
|
4
|
+
readonly drag: boolean;
|
|
11
5
|
readonly inertia: boolean;
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
6
|
+
readonly wheelZoom: boolean;
|
|
7
|
+
readonly doubleTapZoom: boolean;
|
|
8
|
+
readonly pinchZoom: boolean;
|
|
15
9
|
readonly keyboard: boolean;
|
|
16
10
|
/** Pixels por toque de seta. */
|
|
17
|
-
readonly
|
|
11
|
+
readonly keyStep: number;
|
|
18
12
|
/** Quanto de rolagem (px) equivale a um nível de zoom. */
|
|
19
|
-
readonly
|
|
13
|
+
readonly wheelStep: number;
|
|
20
14
|
}
|
|
21
15
|
export declare const DEFAULT_INTERACTIONS: InteractionOptions;
|
|
22
16
|
export type KeyboardAction = {
|
|
@@ -31,6 +25,11 @@ export type KeyboardAction = {
|
|
|
31
25
|
* (3 níveis com Shift). Outra tecla: `null`.
|
|
32
26
|
*/
|
|
33
27
|
export declare function keyboardAction(event: Pick<KeyboardEvent, 'key' | 'shiftKey' | 'altKey' | 'ctrlKey' | 'metaKey'>, panDelta?: number): KeyboardAction | null;
|
|
28
|
+
/**
|
|
29
|
+
* Os gestos de ponteiro (arrasto com inércia, pinça, roda, duplo clique) são o controlador sem framework
|
|
30
|
+
* `ViewportGestures` do primitives, ligado ao `MapEngine` por um adaptador: o zoom do mapa anda em níveis inteiros
|
|
31
|
+
* (a roda sobe um nível por degrau e a pinça arredonda no fim). O teclado continua aqui (é do mapa).
|
|
32
|
+
*/
|
|
34
33
|
export declare class MapInteractions {
|
|
35
34
|
private readonly el;
|
|
36
35
|
private readonly engine;
|
|
@@ -38,39 +37,17 @@ export declare class MapInteractions {
|
|
|
38
37
|
/** Chamado quando uma tecla de mapa foi tratada (o app pode anunciar o novo estado). */
|
|
39
38
|
private readonly onKeyboard?;
|
|
40
39
|
private options;
|
|
41
|
-
private readonly
|
|
42
|
-
private dragStart;
|
|
43
|
-
private dragLast;
|
|
44
|
-
private dragging;
|
|
45
|
-
private samples;
|
|
46
|
-
private pinch;
|
|
47
|
-
private suppressClick;
|
|
48
|
-
private wheelAcc;
|
|
49
|
-
private wheelLastZoom;
|
|
50
|
-
private wheelResetTimer;
|
|
51
|
-
private animation;
|
|
40
|
+
private readonly gestures;
|
|
52
41
|
private readonly cleanup;
|
|
53
42
|
constructor(el: HTMLElement, engine: MapEngine, options?: Partial<InteractionOptions>, reducedMotion?: () => boolean,
|
|
54
43
|
/** Chamado quando uma tecla de mapa foi tratada (o app pode anunciar o novo estado). */
|
|
55
44
|
onKeyboard?: ((action: KeyboardAction) => void) | undefined);
|
|
45
|
+
private gestureOptions;
|
|
56
46
|
setOptions(options: Partial<InteractionOptions>): void;
|
|
57
47
|
/** Interrompe a inércia em andamento. */
|
|
58
48
|
stop(): void;
|
|
59
49
|
destroy(): void;
|
|
60
50
|
/** Executa a ação de teclado (exposto para controles e testes). */
|
|
61
51
|
applyKeyboard(action: KeyboardAction): void;
|
|
62
|
-
private on;
|
|
63
|
-
private local;
|
|
64
|
-
private blocked;
|
|
65
|
-
private pointerDown;
|
|
66
|
-
private pointerMove;
|
|
67
|
-
private pointerUp;
|
|
68
|
-
private endPinch;
|
|
69
|
-
private endDrag;
|
|
70
|
-
private animatePan;
|
|
71
|
-
private wheel;
|
|
72
|
-
private dblclick;
|
|
73
52
|
private keydown;
|
|
74
|
-
private capture;
|
|
75
|
-
private release;
|
|
76
53
|
}
|