@goway.to/maps 0.0.0-stage → 0.1.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/CHANGELOG.md +24 -0
- package/LICENSE +676 -0
- package/NOTICE +25 -0
- package/README.md +59 -2
- package/app.plugin.js +19 -0
- package/dist/CameraBinding.web.d.ts +24 -0
- package/dist/CameraBinding.web.js +46 -0
- package/dist/DefaultMapMarker.d.ts +8 -0
- package/dist/DefaultMapMarker.js +30 -0
- package/dist/GeoJSONSource.d.ts +2 -0
- package/dist/GeoJSONSource.js +17 -0
- package/dist/GeoJSONSource.web.d.ts +2 -0
- package/dist/GeoJSONSource.web.js +68 -0
- package/dist/InteractionBinding.web.d.ts +7 -0
- package/dist/InteractionBinding.web.js +35 -0
- package/dist/Layer.d.ts +2 -0
- package/dist/Layer.js +21 -0
- package/dist/Layer.web.d.ts +2 -0
- package/dist/Layer.web.js +46 -0
- package/dist/LayerStyle.web.d.ts +10 -0
- package/dist/LayerStyle.web.js +45 -0
- package/dist/LightBinding.web.d.ts +5 -0
- package/dist/LightBinding.web.js +19 -0
- package/dist/MapAttribution.d.ts +27 -0
- package/dist/MapAttribution.js +149 -0
- package/dist/MapBrand.d.ts +22 -0
- package/dist/MapBrand.js +91 -0
- package/dist/MapErrorState.d.ts +9 -0
- package/dist/MapErrorState.js +58 -0
- package/dist/MapPlugin.d.ts +6 -0
- package/dist/MapPlugin.js +3 -0
- package/dist/MapPlugin.web.d.ts +2 -0
- package/dist/MapPlugin.web.js +43 -0
- package/dist/MapView.d.ts +2 -0
- package/dist/MapView.js +420 -0
- package/dist/MapView.web.d.ts +5 -0
- package/dist/MapView.web.js +413 -0
- package/dist/Marker.d.ts +13 -0
- package/dist/Marker.js +11 -0
- package/dist/Marker.web.d.ts +15 -0
- package/dist/Marker.web.js +51 -0
- package/dist/Markers.d.ts +2 -0
- package/dist/Markers.js +13 -0
- package/dist/Markers.web.d.ts +2 -0
- package/dist/Markers.web.js +13 -0
- package/dist/PluginProps.web.d.ts +7 -0
- package/dist/PluginProps.web.js +19 -0
- package/dist/RasterDEMSource.d.ts +2 -0
- package/dist/RasterDEMSource.js +7 -0
- package/dist/RasterDEMSource.web.d.ts +2 -0
- package/dist/RasterDEMSource.web.js +44 -0
- package/dist/SourceData.web.d.ts +6 -0
- package/dist/SourceData.web.js +14 -0
- package/dist/UserLocation.d.ts +2 -0
- package/dist/UserLocation.js +19 -0
- package/dist/UserLocation.web.d.ts +2 -0
- package/dist/UserLocation.web.js +21 -0
- package/dist/brand/BrandedChrome.d.ts +47 -0
- package/dist/brand/BrandedChrome.js +51 -0
- package/dist/brand/GowayLogo.d.ts +28 -0
- package/dist/brand/GowayLogo.js +50 -0
- package/dist/brand/artwork.d.ts +130 -0
- package/dist/brand/artwork.js +176 -0
- package/dist/cameraReports.web.d.ts +50 -0
- package/dist/cameraReports.web.js +117 -0
- package/dist/cameraTarget.d.ts +14 -0
- package/dist/cameraTarget.js +8 -0
- package/dist/chromeLift.d.ts +15 -0
- package/dist/chromeLift.js +15 -0
- package/dist/clusters.d.ts +57 -0
- package/dist/clusters.js +102 -0
- package/dist/commands.web.d.ts +16 -0
- package/dist/commands.web.js +158 -0
- package/dist/compactCredit.d.ts +52 -0
- package/dist/compactCredit.js +40 -0
- package/dist/creditHeight.d.ts +3 -0
- package/dist/creditHeight.js +12 -0
- package/dist/creditLabels.d.ts +30 -0
- package/dist/creditLabels.js +30 -0
- package/dist/creditRise.d.ts +28 -0
- package/dist/creditRise.js +33 -0
- package/dist/dragAxes.web.d.ts +65 -0
- package/dist/dragAxes.web.js +70 -0
- package/dist/engineContext.web.d.ts +13 -0
- package/dist/engineContext.web.js +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/index.web.d.ts +13 -0
- package/dist/index.web.js +13 -0
- package/dist/labels.d.ts +202 -0
- package/dist/labels.js +451 -0
- package/dist/loadedCamera.d.ts +64 -0
- package/dist/loadedCamera.js +56 -0
- package/dist/locationStore.d.ts +16 -0
- package/dist/locationStore.js +132 -0
- package/dist/mapRef.d.ts +4 -0
- package/dist/mapRef.js +13 -0
- package/dist/moveMarkers.d.ts +27 -0
- package/dist/moveMarkers.js +22 -0
- package/dist/nativeCameraReports.d.ts +44 -0
- package/dist/nativeCameraReports.js +73 -0
- package/dist/plugin.d.ts +63 -0
- package/dist/plugin.js +2 -0
- package/dist/queryLayers.d.ts +19 -0
- package/dist/queryLayers.js +54 -0
- package/dist/shared-exports.d.ts +17 -0
- package/dist/shared-exports.js +13 -0
- package/dist/shared.d.ts +170 -0
- package/dist/shared.js +337 -0
- package/dist/sourceContext.d.ts +2 -0
- package/dist/sourceContext.js +9 -0
- package/dist/styleUrl.d.ts +19 -0
- package/dist/styleUrl.js +22 -0
- package/dist/testing.d.ts +41 -0
- package/dist/testing.js +80 -0
- package/dist/types.d.ts +348 -0
- package/dist/types.js +1 -0
- package/dist/useMarkerSlots.d.ts +6 -0
- package/dist/useMarkerSlots.js +56 -0
- package/dist/useUserLocation.d.ts +44 -0
- package/dist/useUserLocation.js +247 -0
- package/dist/zoom.d.ts +2 -0
- package/dist/zoom.js +10 -0
- package/metro.cjs +70 -0
- package/package.json +115 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the map's data credit publishes its measured height, so a screen's
|
|
3
|
+
* bottom-right chrome can stand above it however many lines it wraps to
|
|
4
|
+
* (`creditRise.ts`). A screen that floats chrome over the bottom-right
|
|
5
|
+
* provides a shared value; `MapAttribution` writes it, the chrome reads it on
|
|
6
|
+
* the UI thread. Absent, nothing is measured and nothing moves.
|
|
7
|
+
*/
|
|
8
|
+
import { createContext, useContext } from 'react';
|
|
9
|
+
export const MapCreditHeightContext = createContext(null);
|
|
10
|
+
export function useMapCreditHeight() {
|
|
11
|
+
return useContext(MapCreditHeightContext);
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const CREDIT_LABELS: {
|
|
2
|
+
readonly show: {
|
|
3
|
+
readonly en: "Show map credits";
|
|
4
|
+
readonly ar: "إظهار مصادر الخريطة";
|
|
5
|
+
readonly bn: "মানচিত্রের কৃতিত্ব দেখান";
|
|
6
|
+
readonly ca: "Mostra els crèdits del mapa";
|
|
7
|
+
readonly de: "Kartenquellen anzeigen";
|
|
8
|
+
readonly es: "Mostrar los créditos del mapa";
|
|
9
|
+
readonly fr: "Afficher les crédits de la carte";
|
|
10
|
+
readonly hi: "मानचित्र के श्रेय दिखाएँ";
|
|
11
|
+
readonly ja: "地図のクレジットを表示";
|
|
12
|
+
readonly 'pt-BR': "Mostrar os créditos do mapa";
|
|
13
|
+
readonly ru: "Показать источники карты";
|
|
14
|
+
readonly 'zh-Hans': "显示地图来源";
|
|
15
|
+
};
|
|
16
|
+
readonly hide: {
|
|
17
|
+
readonly en: "Hide map credits";
|
|
18
|
+
readonly ar: "إخفاء مصادر الخريطة";
|
|
19
|
+
readonly bn: "মানচিত্রের কৃতিত্ব লুকান";
|
|
20
|
+
readonly ca: "Amaga els crèdits del mapa";
|
|
21
|
+
readonly de: "Kartenquellen ausblenden";
|
|
22
|
+
readonly es: "Ocultar los créditos del mapa";
|
|
23
|
+
readonly fr: "Masquer les crédits de la carte";
|
|
24
|
+
readonly hi: "मानचित्र के श्रेय छिपाएँ";
|
|
25
|
+
readonly ja: "地図のクレジットを隠す";
|
|
26
|
+
readonly 'pt-BR': "Ocultar os créditos do mapa";
|
|
27
|
+
readonly ru: "Скрыть источники карты";
|
|
28
|
+
readonly 'zh-Hans': "隐藏地图来源";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const CREDIT_LABELS = {
|
|
2
|
+
show: {
|
|
3
|
+
en: 'Show map credits',
|
|
4
|
+
ar: 'إظهار مصادر الخريطة',
|
|
5
|
+
bn: 'মানচিত্রের কৃতিত্ব দেখান',
|
|
6
|
+
ca: 'Mostra els crèdits del mapa',
|
|
7
|
+
de: 'Kartenquellen anzeigen',
|
|
8
|
+
es: 'Mostrar los créditos del mapa',
|
|
9
|
+
fr: 'Afficher les crédits de la carte',
|
|
10
|
+
hi: 'मानचित्र के श्रेय दिखाएँ',
|
|
11
|
+
ja: '地図のクレジットを表示',
|
|
12
|
+
'pt-BR': 'Mostrar os créditos do mapa',
|
|
13
|
+
ru: 'Показать источники карты',
|
|
14
|
+
'zh-Hans': '显示地图来源',
|
|
15
|
+
},
|
|
16
|
+
hide: {
|
|
17
|
+
en: 'Hide map credits',
|
|
18
|
+
ar: 'إخفاء مصادر الخريطة',
|
|
19
|
+
bn: 'মানচিত্রের কৃতিত্ব লুকান',
|
|
20
|
+
ca: 'Amaga els crèdits del mapa',
|
|
21
|
+
de: 'Kartenquellen ausblenden',
|
|
22
|
+
es: 'Ocultar los créditos del mapa',
|
|
23
|
+
fr: 'Masquer les crédits de la carte',
|
|
24
|
+
hi: 'मानचित्र के श्रेय छिपाएँ',
|
|
25
|
+
ja: '地図のクレジットを隠す',
|
|
26
|
+
'pt-BR': 'Ocultar os créditos do mapa',
|
|
27
|
+
ru: 'Скрыть источники карты',
|
|
28
|
+
'zh-Hans': '隐藏地图来源',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much room the map's data credit takes at the bottom-right, and how far
|
|
3
|
+
* the chrome an app floats above it must rise when the credit is taller than
|
|
4
|
+
* one line.
|
|
5
|
+
*
|
|
6
|
+
* The chrome is laid out {@link MAP_CREDIT_CLEARANCE} above the bottom edge:
|
|
7
|
+
* room for the credit FOLDED, or spelled out on one line. Spelled out on a
|
|
8
|
+
* phone it wraps — the sources, the official building data while it is drawn,
|
|
9
|
+
* and any disclosure it carries — so the credit measures itself
|
|
10
|
+
* (`MapAttribution`, through `creditHeight.ts`) and the chrome rises by
|
|
11
|
+
* {@link creditRise} of that height: the two never overlap, whatever the
|
|
12
|
+
* credit says. Folded, the rise is zero and nothing moves.
|
|
13
|
+
*
|
|
14
|
+
* A worklet, so the UI thread runs exactly what `test/creditRise.test.ts`
|
|
15
|
+
* checks.
|
|
16
|
+
*/
|
|
17
|
+
/** Between the credit and the edge below it. */
|
|
18
|
+
export declare const CREDIT_GAP = 4;
|
|
19
|
+
/** Between the top of the credit and the chrome above it. */
|
|
20
|
+
export declare const CREDIT_BREATHING = 8;
|
|
21
|
+
/**
|
|
22
|
+
* How much of the bottom-right the credit occupies above the bottom edge: its
|
|
23
|
+
* gap, one caption line on its plate, and room to breathe. Bottom-right chrome
|
|
24
|
+
* a screen floats there starts above it, plus {@link creditRise}.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MAP_CREDIT_CLEARANCE = 36;
|
|
27
|
+
/** px the chrome above the credit rises for a credit plate this tall. */
|
|
28
|
+
export declare function creditRise(plateHeight: number): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much room the map's data credit takes at the bottom-right, and how far
|
|
3
|
+
* the chrome an app floats above it must rise when the credit is taller than
|
|
4
|
+
* one line.
|
|
5
|
+
*
|
|
6
|
+
* The chrome is laid out {@link MAP_CREDIT_CLEARANCE} above the bottom edge:
|
|
7
|
+
* room for the credit FOLDED, or spelled out on one line. Spelled out on a
|
|
8
|
+
* phone it wraps — the sources, the official building data while it is drawn,
|
|
9
|
+
* and any disclosure it carries — so the credit measures itself
|
|
10
|
+
* (`MapAttribution`, through `creditHeight.ts`) and the chrome rises by
|
|
11
|
+
* {@link creditRise} of that height: the two never overlap, whatever the
|
|
12
|
+
* credit says. Folded, the rise is zero and nothing moves.
|
|
13
|
+
*
|
|
14
|
+
* A worklet, so the UI thread runs exactly what `test/creditRise.test.ts`
|
|
15
|
+
* checks.
|
|
16
|
+
*/
|
|
17
|
+
/** Between the credit and the edge below it. */
|
|
18
|
+
export const CREDIT_GAP = 4;
|
|
19
|
+
/** Between the top of the credit and the chrome above it. */
|
|
20
|
+
export const CREDIT_BREATHING = 8;
|
|
21
|
+
/**
|
|
22
|
+
* How much of the bottom-right the credit occupies above the bottom edge: its
|
|
23
|
+
* gap, one caption line on its plate, and room to breathe. Bottom-right chrome
|
|
24
|
+
* a screen floats there starts above it, plus {@link creditRise}.
|
|
25
|
+
*/
|
|
26
|
+
export const MAP_CREDIT_CLEARANCE = 36;
|
|
27
|
+
/** px the chrome above the credit rises for a credit plate this tall. */
|
|
28
|
+
export function creditRise(plateHeight) {
|
|
29
|
+
'worklet';
|
|
30
|
+
if (!(plateHeight > 0))
|
|
31
|
+
return 0;
|
|
32
|
+
return Math.max(0, CREDIT_GAP + plateHeight + CREDIT_BREATHING - MAP_CREDIT_CLEARANCE);
|
|
33
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotate and pitch as two independent gestures, on a renderer that ships them
|
|
3
|
+
* as one.
|
|
4
|
+
*
|
|
5
|
+
* ## The defect this exists to remove
|
|
6
|
+
*
|
|
7
|
+
* `MapInteractionOptions` has carried `rotate` and `pitch` as separate flags
|
|
8
|
+
* since the seam was written, and the native fork wires them to two separate
|
|
9
|
+
* props (`touchRotate`, `touchPitch`). MapLibre GL JS does not: on a desktop,
|
|
10
|
+
* bearing AND pitch both come out of ONE handler, `map.dragRotate` — Ctrl-drag
|
|
11
|
+
* or right-drag, horizontal for bearing, vertical for pitch. Toggling that
|
|
12
|
+
* handler on `rotate` alone therefore made `{ rotate: false, pitch: true }`
|
|
13
|
+
* mean "two-finger pitch on a touchscreen, and no way to tilt on a desktop",
|
|
14
|
+
* while the same options on native meant "pitch works". One options object,
|
|
15
|
+
* two behaviours, and nothing said so.
|
|
16
|
+
*
|
|
17
|
+
* That matters more than a rendering nicety because `MapInteractionOptions` is
|
|
18
|
+
* public in `@goway.to/maps`: an integrator reads the two flags,
|
|
19
|
+
* passes them, and gets a different map per platform.
|
|
20
|
+
*
|
|
21
|
+
* ## The contract
|
|
22
|
+
*
|
|
23
|
+
* **`rotate` and `pitch` are independent, on every platform.** Each names one
|
|
24
|
+
* camera axis the user may drive, and neither implies the other.
|
|
25
|
+
*
|
|
26
|
+
* ## How it is honoured here
|
|
27
|
+
*
|
|
28
|
+
* `DragRotateHandler` is a facade over two real handlers — `_mouseRotate` and
|
|
29
|
+
* `_mousePitch` (`src/ui/handler/shim/drag_rotate.ts`; its own `enable()` is
|
|
30
|
+
* `_mouseRotate.enable()` plus `_mousePitch.enable()` when `pitchWithRotate` is
|
|
31
|
+
* set, and `disable()` turns both off). Driving those two directly is the only
|
|
32
|
+
* way to get one axis without the other, because the public facade has no
|
|
33
|
+
* arity between "both" and "neither" and `pitchWithRotate` is a construction
|
|
34
|
+
* option that cannot be changed on a live map.
|
|
35
|
+
*
|
|
36
|
+
* They are underscore-prefixed, so this is a documented reach past the public
|
|
37
|
+
* API rather than an accident, and it degrades rather than throws if a future
|
|
38
|
+
* MapLibre stops splitting the two: the fallback enables the facade whenever
|
|
39
|
+
* EITHER axis is wanted, which keeps pitch reachable (the defect) at the cost
|
|
40
|
+
* of a bearing drag that `rotate: false` did not ask for. `setMaxPitch(0)`
|
|
41
|
+
* remains the backstop on the other side, so the fallback can never leak pitch
|
|
42
|
+
* into a map that asked for none.
|
|
43
|
+
*/
|
|
44
|
+
/** The two halves of MapLibre's desktop drag handler, as far as this file cares. */
|
|
45
|
+
interface DragAxisHandler {
|
|
46
|
+
enable(): void;
|
|
47
|
+
disable(): void;
|
|
48
|
+
}
|
|
49
|
+
/** `map.dragRotate`: the facade, and the two handlers it is a facade over. */
|
|
50
|
+
export interface DragRotateLike extends DragAxisHandler {
|
|
51
|
+
_mouseRotate?: DragAxisHandler;
|
|
52
|
+
_mousePitch?: DragAxisHandler;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Enable exactly the desktop drag axes asked for.
|
|
56
|
+
*
|
|
57
|
+
* @returns `true` when the two axes were set independently, `false` when the
|
|
58
|
+
* facade fallback was used — exposed so a test can tell the two paths
|
|
59
|
+
* apart, and so this file is honest about which one ran.
|
|
60
|
+
*/
|
|
61
|
+
export declare function applyDragAxes(dragRotate: DragRotateLike, axes: {
|
|
62
|
+
rotate: boolean;
|
|
63
|
+
pitch: boolean;
|
|
64
|
+
}): boolean;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotate and pitch as two independent gestures, on a renderer that ships them
|
|
3
|
+
* as one.
|
|
4
|
+
*
|
|
5
|
+
* ## The defect this exists to remove
|
|
6
|
+
*
|
|
7
|
+
* `MapInteractionOptions` has carried `rotate` and `pitch` as separate flags
|
|
8
|
+
* since the seam was written, and the native fork wires them to two separate
|
|
9
|
+
* props (`touchRotate`, `touchPitch`). MapLibre GL JS does not: on a desktop,
|
|
10
|
+
* bearing AND pitch both come out of ONE handler, `map.dragRotate` — Ctrl-drag
|
|
11
|
+
* or right-drag, horizontal for bearing, vertical for pitch. Toggling that
|
|
12
|
+
* handler on `rotate` alone therefore made `{ rotate: false, pitch: true }`
|
|
13
|
+
* mean "two-finger pitch on a touchscreen, and no way to tilt on a desktop",
|
|
14
|
+
* while the same options on native meant "pitch works". One options object,
|
|
15
|
+
* two behaviours, and nothing said so.
|
|
16
|
+
*
|
|
17
|
+
* That matters more than a rendering nicety because `MapInteractionOptions` is
|
|
18
|
+
* public in `@goway.to/maps`: an integrator reads the two flags,
|
|
19
|
+
* passes them, and gets a different map per platform.
|
|
20
|
+
*
|
|
21
|
+
* ## The contract
|
|
22
|
+
*
|
|
23
|
+
* **`rotate` and `pitch` are independent, on every platform.** Each names one
|
|
24
|
+
* camera axis the user may drive, and neither implies the other.
|
|
25
|
+
*
|
|
26
|
+
* ## How it is honoured here
|
|
27
|
+
*
|
|
28
|
+
* `DragRotateHandler` is a facade over two real handlers — `_mouseRotate` and
|
|
29
|
+
* `_mousePitch` (`src/ui/handler/shim/drag_rotate.ts`; its own `enable()` is
|
|
30
|
+
* `_mouseRotate.enable()` plus `_mousePitch.enable()` when `pitchWithRotate` is
|
|
31
|
+
* set, and `disable()` turns both off). Driving those two directly is the only
|
|
32
|
+
* way to get one axis without the other, because the public facade has no
|
|
33
|
+
* arity between "both" and "neither" and `pitchWithRotate` is a construction
|
|
34
|
+
* option that cannot be changed on a live map.
|
|
35
|
+
*
|
|
36
|
+
* They are underscore-prefixed, so this is a documented reach past the public
|
|
37
|
+
* API rather than an accident, and it degrades rather than throws if a future
|
|
38
|
+
* MapLibre stops splitting the two: the fallback enables the facade whenever
|
|
39
|
+
* EITHER axis is wanted, which keeps pitch reachable (the defect) at the cost
|
|
40
|
+
* of a bearing drag that `rotate: false` did not ask for. `setMaxPitch(0)`
|
|
41
|
+
* remains the backstop on the other side, so the fallback can never leak pitch
|
|
42
|
+
* into a map that asked for none.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Enable exactly the desktop drag axes asked for.
|
|
46
|
+
*
|
|
47
|
+
* @returns `true` when the two axes were set independently, `false` when the
|
|
48
|
+
* facade fallback was used — exposed so a test can tell the two paths
|
|
49
|
+
* apart, and so this file is honest about which one ran.
|
|
50
|
+
*/
|
|
51
|
+
export function applyDragAxes(dragRotate, axes) {
|
|
52
|
+
const rotateHandler = dragRotate._mouseRotate;
|
|
53
|
+
const pitchHandler = dragRotate._mousePitch;
|
|
54
|
+
if (rotateHandler && pitchHandler) {
|
|
55
|
+
// `disable()` on the facade first: it is the only call that clears an axis
|
|
56
|
+
// the constructor enabled, and the two `enable()`s below then put back
|
|
57
|
+
// exactly what was asked for.
|
|
58
|
+
dragRotate.disable();
|
|
59
|
+
if (axes.rotate)
|
|
60
|
+
rotateHandler.enable();
|
|
61
|
+
if (axes.pitch)
|
|
62
|
+
pitchHandler.enable();
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (axes.rotate || axes.pitch)
|
|
66
|
+
dragRotate.enable();
|
|
67
|
+
else
|
|
68
|
+
dragRotate.disable();
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Map as MapLibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { MapPluginHandle } from './plugin';
|
|
3
|
+
export interface WebEngine {
|
|
4
|
+
map: MapLibreMap;
|
|
5
|
+
/** The DOM elements of the markers on this map: a click on one is not a click on the map. */
|
|
6
|
+
markerElements: Set<HTMLElement>;
|
|
7
|
+
/** The plugins attached to this map, consulted for presses, the cursor and errors. */
|
|
8
|
+
plugins: Set<MapPluginHandle<unknown>>;
|
|
9
|
+
/** The element the engine draws into. */
|
|
10
|
+
container: HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
export declare const WebEngineContext: import("react").Context<WebEngine | null>;
|
|
13
|
+
export declare function useWebEngine(): WebEngine;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web engine, published to a `MapView`'s children once its style has
|
|
3
|
+
* loaded. Only the web forks read it.
|
|
4
|
+
*/
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
export const WebEngineContext = createContext(null);
|
|
7
|
+
export function useWebEngine() {
|
|
8
|
+
const engine = useContext(WebEngineContext);
|
|
9
|
+
if (!engine)
|
|
10
|
+
throw new Error('A map component must be rendered inside a <MapView>.');
|
|
11
|
+
return engine;
|
|
12
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@goway.to/maps` — GoWay's maps SDK for React Native (this entry) and the web
|
|
3
|
+
* (`index.web.ts`, chosen by the `browser` export condition). One API on both.
|
|
4
|
+
*/
|
|
5
|
+
export { MapView } from './MapView';
|
|
6
|
+
export { Markers } from './Markers';
|
|
7
|
+
export { GeoJSONSource } from './GeoJSONSource';
|
|
8
|
+
export { RasterDEMSource } from './RasterDEMSource';
|
|
9
|
+
export { Layer } from './Layer';
|
|
10
|
+
export { UserLocation } from './UserLocation';
|
|
11
|
+
export { MapPlugin } from './MapPlugin';
|
|
12
|
+
export * from './shared-exports';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@goway.to/maps` — GoWay's maps SDK for React Native (this entry) and the web
|
|
3
|
+
* (`index.web.ts`, chosen by the `browser` export condition). One API on both.
|
|
4
|
+
*/
|
|
5
|
+
export { MapView } from './MapView';
|
|
6
|
+
export { Markers } from './Markers';
|
|
7
|
+
export { GeoJSONSource } from './GeoJSONSource';
|
|
8
|
+
export { RasterDEMSource } from './RasterDEMSource';
|
|
9
|
+
export { Layer } from './Layer';
|
|
10
|
+
export { UserLocation } from './UserLocation';
|
|
11
|
+
export { MapPlugin } from './MapPlugin';
|
|
12
|
+
export * from './shared-exports';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@goway.to/maps` on the web — the same API as `index.ts`, built on
|
|
3
|
+
* `maplibre-gl`. Every web fork is named explicitly: an export condition does
|
|
4
|
+
* not apply to a relative import.
|
|
5
|
+
*/
|
|
6
|
+
export { MapView } from './MapView.web';
|
|
7
|
+
export { Markers } from './Markers.web';
|
|
8
|
+
export { GeoJSONSource } from './GeoJSONSource.web';
|
|
9
|
+
export { RasterDEMSource } from './RasterDEMSource.web';
|
|
10
|
+
export { Layer } from './Layer.web';
|
|
11
|
+
export { UserLocation } from './UserLocation.web';
|
|
12
|
+
export { MapPlugin } from './MapPlugin.web';
|
|
13
|
+
export * from './shared-exports';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@goway.to/maps` on the web — the same API as `index.ts`, built on
|
|
3
|
+
* `maplibre-gl`. Every web fork is named explicitly: an export condition does
|
|
4
|
+
* not apply to a relative import.
|
|
5
|
+
*/
|
|
6
|
+
export { MapView } from './MapView.web';
|
|
7
|
+
export { Markers } from './Markers.web';
|
|
8
|
+
export { GeoJSONSource } from './GeoJSONSource.web';
|
|
9
|
+
export { RasterDEMSource } from './RasterDEMSource.web';
|
|
10
|
+
export { Layer } from './Layer.web';
|
|
11
|
+
export { UserLocation } from './UserLocation.web';
|
|
12
|
+
export { MapPlugin } from './MapPlugin.web';
|
|
13
|
+
export * from './shared-exports';
|
package/dist/labels.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { GeoCoordinate, MapLabelFeature, MapLabelKind } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* How far around the tap the engine is asked to look, in px (web) / dp (native).
|
|
4
|
+
*
|
|
5
|
+
* The measurement above says 10 px is the minimum that reaches both a POI's dot
|
|
6
|
+
* and its label. 18 is that plus finger slop, and a generous pad costs nothing
|
|
7
|
+
* because {@link pickLabelFeature} resolves a crowded box by distance — the
|
|
8
|
+
* nearest label still wins, so widening the net changes what a sloppy tap hits
|
|
9
|
+
* and never what an accurate one hits.
|
|
10
|
+
*
|
|
11
|
+
* One number for mouse and touch on purpose. Sniffing the pointer type is
|
|
12
|
+
* unreliable (a browser-synthesised click from a touch is an ordinary
|
|
13
|
+
* `MouseEvent`), and a click 14 px from a label is a click that meant the
|
|
14
|
+
* label: a tap on genuinely empty ground was measured to return nothing at any
|
|
15
|
+
* pad, so the failure this could cause — "I clicked nothing and got something"
|
|
16
|
+
* — has nothing to be caused by.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LABEL_HIT_PAD_PX = 18;
|
|
19
|
+
/**
|
|
20
|
+
* Source-layers a tap may resolve against, in the OpenMapTiles v3 vocabulary.
|
|
21
|
+
*
|
|
22
|
+
* Read from GoWay's tile schema (`@goway.to/sdk`) rather than spelled here: a
|
|
23
|
+
* wrong source-layer name is the failure mode that logs nothing and throws
|
|
24
|
+
* nothing, and the schema is the one place those names are recorded.
|
|
25
|
+
*
|
|
26
|
+
* This is every layer GoWay's style puts a NAME on. `transportation` is absent
|
|
27
|
+
* although the style draws a symbol from it — that symbol is `road-oneway`, an
|
|
28
|
+
* arrow, and an arrow is not a label. `building` and `housenumber` are absent
|
|
29
|
+
* because a house number is an address fragment, not a thing with a name.
|
|
30
|
+
*/
|
|
31
|
+
export declare const LABEL_SOURCE_LAYERS: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* One hit, as a fork hands it over: the engine's feature with the engine
|
|
34
|
+
* removed.
|
|
35
|
+
*
|
|
36
|
+
* `properties` stays an opaque bag rather than a parsed shape because it is the
|
|
37
|
+
* TILES' vocabulary, not GoWay's — `class`, `subclass`, `rank` and the whole
|
|
38
|
+
* `name:*` family arrive exactly as OpenMapTiles wrote them, and
|
|
39
|
+
* {@link toLabelFeature} is the single place that decides which of them GoWay
|
|
40
|
+
* is willing to speak.
|
|
41
|
+
*/
|
|
42
|
+
export interface QueriedLabel {
|
|
43
|
+
/** The tiles' own feature id, where they carry one. */
|
|
44
|
+
featureId?: string | number | null;
|
|
45
|
+
/** OpenMapTiles source-layer (`poi`, `transportation_name`, …). */
|
|
46
|
+
sourceLayer: string;
|
|
47
|
+
/** The style layer that drew it. Diagnostics only. */
|
|
48
|
+
layerId?: string;
|
|
49
|
+
properties: Readonly<Record<string, unknown>>;
|
|
50
|
+
/** The feature's own point, for a Point geometry. */
|
|
51
|
+
coordinate?: GeoCoordinate | null;
|
|
52
|
+
/**
|
|
53
|
+
* The feature's vertices, for a line geometry — a street, a river.
|
|
54
|
+
*
|
|
55
|
+
* A street name has no point: it is drawn ALONG the way, and the way runs off
|
|
56
|
+
* both edges of the tile. So the anchor for a line is the nearest point on
|
|
57
|
+
* the line to the tap ({@link pickLabelFeature}), which is both a real place
|
|
58
|
+
* on the street and the closest thing there is to "where the user pointed".
|
|
59
|
+
*/
|
|
60
|
+
path?: readonly GeoCoordinate[] | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The name the basemap is DRAWING, or `null`.
|
|
64
|
+
*
|
|
65
|
+
* Exactly `coalesce(name:latin, name)` — the `text-field` expression of
|
|
66
|
+
* GoWay's styles. Not `name_en`, not `name_int`: a label that says
|
|
67
|
+
* one thing on screen and another in the sheet is a worse bug than no sheet,
|
|
68
|
+
* and the user tapped what they could read.
|
|
69
|
+
*/
|
|
70
|
+
export declare function labelNameOf(properties: Readonly<Record<string, unknown>>): string | null;
|
|
71
|
+
/**
|
|
72
|
+
* What kind of named thing this is, decided by SOURCE-LAYER rather than by
|
|
73
|
+
* guesswork over the name.
|
|
74
|
+
*
|
|
75
|
+
* Four kinds, because four is what the product acts on differently — see
|
|
76
|
+
* `MapLabelKind` in `types.ts` for what each one means and what a tap on it
|
|
77
|
+
* does.
|
|
78
|
+
*/
|
|
79
|
+
export declare function labelKindOf(sourceLayer: string): MapLabelKind | null;
|
|
80
|
+
/** Whether a source-layer can answer a tap at all. */
|
|
81
|
+
export declare function isLabelSourceLayer(sourceLayer: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* One queried hit as a GoWay label, or `null` when it is not one.
|
|
84
|
+
*
|
|
85
|
+
* `fallback` is where the user tapped. It is used when the feature has no
|
|
86
|
+
* anchor of its own — a label placed over a POLYGON, such as a park, whose name
|
|
87
|
+
* sits at the pole of inaccessibility that exists only inside MapLibre's
|
|
88
|
+
* placement and not in the tile. The tap is inside the polygon by construction,
|
|
89
|
+
* so it is a truthful point for that thing.
|
|
90
|
+
*
|
|
91
|
+
* Anything derived from a queried geometry goes through `isDrawableCoordinate`
|
|
92
|
+
* for the reason the whole seam exists — a `NaN` reaching MapLibre is a THROW
|
|
93
|
+
* out of the effect that positions things, not a misplaced pin (see
|
|
94
|
+
* `shared.ts`).
|
|
95
|
+
*/
|
|
96
|
+
export declare function toLabelFeature(candidate: QueriedLabel, fallback: GeoCoordinate, anchor?: GeoCoordinate | null): MapLabelFeature | null;
|
|
97
|
+
/**
|
|
98
|
+
* Every hit in the box, as GoWay labels, each anchored where it really is.
|
|
99
|
+
*
|
|
100
|
+
* Split from the ranking below because the two halves need different things and
|
|
101
|
+
* one platform cannot do them together. Anchoring is PURE GEOMETRY — no
|
|
102
|
+
* projection — which is what lets the native fork do it synchronously for every
|
|
103
|
+
* candidate and then pay for exactly one projection each, instead of one bridge
|
|
104
|
+
* call per vertex of every street in the box.
|
|
105
|
+
*/
|
|
106
|
+
export declare function labelCandidatesOf(candidates: readonly QueriedLabel[], tapCoordinate: GeoCoordinate): MapLabelFeature[];
|
|
107
|
+
/**
|
|
108
|
+
* The label a tap meant, out of everything inside the padded box.
|
|
109
|
+
*
|
|
110
|
+
* ## The rule, written down rather than left to the renderer's return order
|
|
111
|
+
*
|
|
112
|
+
* 1. **Nearest wins.** Distance in SCREEN PIXELS from the tap to the label's
|
|
113
|
+
* own anchor — a point for a POI or a city, and for a street or a river the
|
|
114
|
+
* nearest point on the line, which is a real place on that way rather than a
|
|
115
|
+
* vertex that may be half a tile away. Pixels, not degrees: a degree is a
|
|
116
|
+
* different distance at every latitude, and the user is pointing at pixels.
|
|
117
|
+
* 2. **A label with no anchor of its own is ranked as if it were at the edge of
|
|
118
|
+
* the pad.** A park's name is placed by MapLibre at a pole of inaccessibility
|
|
119
|
+
* that does not exist in the tile, so its only honest position is "somewhere
|
|
120
|
+
* in this box". Scoring it at zero would make it beat everything; scoring it
|
|
121
|
+
* at {@link LABEL_HIT_PAD_PX} makes it lose to anything genuinely nearer and
|
|
122
|
+
* win over nothing.
|
|
123
|
+
* 3. **Then the kind**, most specific first: a POI you can walk into, then the
|
|
124
|
+
* street it is on, then water, then the district or city containing all of
|
|
125
|
+
* them. A city label spans the screen and is never what a tap meant while
|
|
126
|
+
* something smaller is under the finger.
|
|
127
|
+
* 4. **Then the tiles' own `rank`**, OpenMapTiles' importance ordering.
|
|
128
|
+
* 5. **Then the id**, so the answer is deterministic rather than dependent on
|
|
129
|
+
* the order a renderer happened to return its layers in.
|
|
130
|
+
*/
|
|
131
|
+
export declare function pickLabelFeature(labels: readonly MapLabelFeature[], point: {
|
|
132
|
+
x: number;
|
|
133
|
+
y: number;
|
|
134
|
+
}, project: (coordinate: GeoCoordinate) => {
|
|
135
|
+
x: number;
|
|
136
|
+
y: number;
|
|
137
|
+
} | null): MapLabelFeature | null;
|
|
138
|
+
/**
|
|
139
|
+
* Where a line-drawn label should be considered to BE: the point on the way
|
|
140
|
+
* nearest the tap.
|
|
141
|
+
*
|
|
142
|
+
* Not the nearest VERTEX, which on a long straight avenue can be far from a tap
|
|
143
|
+
* that landed squarely on the street. The result is a real point on the way,
|
|
144
|
+
* which is what a pin should sit on and what "directions to this street" needs.
|
|
145
|
+
*
|
|
146
|
+
* ## Why this is flat geometry rather than a projection
|
|
147
|
+
*
|
|
148
|
+
* The search runs in a local planar frame — longitude scaled by `cos(latitude)`
|
|
149
|
+
* — instead of in screen pixels. Over one tile at label zooms the difference is
|
|
150
|
+
* immaterial, and it buys the thing that matters: no projection, so this is
|
|
151
|
+
* pure, testable, and cheap enough for the NATIVE fork, where every projection
|
|
152
|
+
* is a bridge call and projecting every vertex of every street in the box would
|
|
153
|
+
* not be affordable. Both forks therefore anchor identically.
|
|
154
|
+
*
|
|
155
|
+
* Returns `null` for anything that is not a usable line, so the caller falls
|
|
156
|
+
* back to the feature's own point and then to the tap.
|
|
157
|
+
*/
|
|
158
|
+
export declare function anchorFor(candidate: QueriedLabel, tap: GeoCoordinate): GeoCoordinate | null;
|
|
159
|
+
/**
|
|
160
|
+
* The labels currently on screen, deduplicated and capped.
|
|
161
|
+
*
|
|
162
|
+
* Both forks report their viewport's labels so the overlay can avoid stacking
|
|
163
|
+
* its own text on top of one. Two things make
|
|
164
|
+
* that safe to do on every settled frame:
|
|
165
|
+
*
|
|
166
|
+
* - **Dedup by id.** One POI is drawn by a dot layer and a label layer, and a
|
|
167
|
+
* feature that straddles a tile boundary is returned once per tile.
|
|
168
|
+
* - **A cap.** A wide, dense viewport is bounded by the collision system to
|
|
169
|
+
* tens of labels in practice (44 over central Barcelona at z16, measured),
|
|
170
|
+
* but "in practice" is not a bound, and this list crosses into React state.
|
|
171
|
+
*/
|
|
172
|
+
export declare function collectLabelFeatures(candidates: readonly QueriedLabel[], fallback: GeoCoordinate, limit?: number): readonly MapLabelFeature[];
|
|
173
|
+
/**
|
|
174
|
+
* Whether two reported label sets are the same set.
|
|
175
|
+
*
|
|
176
|
+
* The canvas re-reports on every settled frame, and a fresh array of equal
|
|
177
|
+
* labels would rebuild every marker on the map for no reason. Ids only: a
|
|
178
|
+
* label's name and class come from the same tile feature, so an id that has
|
|
179
|
+
* not changed describes a label that has not changed.
|
|
180
|
+
*/
|
|
181
|
+
export declare function sameLabelSet(a: readonly MapLabelFeature[], b: readonly MapLabelFeature[]): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* A rendered feature as either engine hands it back. maplibre-gl puts
|
|
184
|
+
* `sourceLayer` and `layer` on the feature; MapLibre Native returns plain
|
|
185
|
+
* GeoJSON, where the source-layer arrives as a property — and the two platform
|
|
186
|
+
* SDKs do not agree on its key.
|
|
187
|
+
*/
|
|
188
|
+
export interface RenderedFeatureLike {
|
|
189
|
+
id?: string | number | null;
|
|
190
|
+
sourceLayer?: unknown;
|
|
191
|
+
layer?: {
|
|
192
|
+
id?: string;
|
|
193
|
+
} | null;
|
|
194
|
+
properties?: Readonly<Record<string, unknown>> | null;
|
|
195
|
+
geometry?: GeoJSON.Geometry | null;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The engine's features, with the engine removed. A feature this cannot
|
|
199
|
+
* classify is dropped rather than guessed at: the source-layer decides whether
|
|
200
|
+
* a hit is a POI or a district, and being wrong opens the wrong sheet.
|
|
201
|
+
*/
|
|
202
|
+
export declare function queriedLabelsOf(features: readonly RenderedFeatureLike[]): QueriedLabel[];
|