isard 1.1.0 → 1.3.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 +121 -0
- package/README.md +44 -39
- package/dist/basemap/basemaps.d.ts +1 -1
- package/dist/basemap/basemaps.js +2 -2
- package/dist/basemap/basemaps.js.map +1 -1
- package/dist/basemap/grid.d.ts +5 -5
- package/dist/basemap/grid.js +59 -65
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/mvt.d.ts +1 -1
- package/dist/basemap/mvt.js +6 -6
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap/pmtiles.d.ts +10 -10
- package/dist/basemap/pmtiles.js +39 -31
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/pmtileslayer.d.ts +33 -0
- package/dist/basemap/pmtileslayer.js +97 -0
- package/dist/basemap/pmtileslayer.js.map +1 -0
- package/dist/basemap/resample.d.ts +2 -2
- package/dist/basemap/resample.js +16 -14
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +3 -3
- package/dist/basemap/terrain.js +6 -6
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/trees.d.ts +26 -0
- package/dist/basemap/trees.js +141 -0
- package/dist/basemap/trees.js.map +1 -0
- package/dist/basemap/vectorstyle.d.ts +22 -10
- package/dist/basemap/vectorstyle.js +163 -110
- package/dist/basemap/vectorstyle.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +70 -47
- package/dist/basemap/vectortiles.js +480 -358
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.d.ts +3 -3
- package/dist/basemap/wmts.js +16 -11
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap/workerpool.d.ts +17 -0
- package/dist/basemap/workerpool.js +194 -0
- package/dist/basemap/workerpool.js.map +1 -0
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +21 -13
- package/dist/bind/layers.d.ts +13 -4
- package/dist/bind/layers.js +64 -40
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/crs.d.ts +10 -10
- package/dist/data/crs.js +38 -34
- package/dist/data/crs.js.map +1 -1
- package/dist/data/gpx.d.ts +1 -1
- package/dist/data/gpx.js +20 -20
- package/dist/data/gpx.js.map +1 -1
- package/dist/data/kml.d.ts +1 -1
- package/dist/data/kml.js +42 -39
- package/dist/data/kml.js.map +1 -1
- package/dist/data/topojson.d.ts +1 -1
- package/dist/data/topojson.js +15 -10
- package/dist/data/topojson.js.map +1 -1
- package/dist/data/xml.d.ts +5 -5
- package/dist/data/xml.js +19 -18
- package/dist/data/xml.js.map +1 -1
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +6 -6
- package/dist/engine/decoders.d.ts +2 -2
- package/dist/engine/decoders.js +28 -25
- package/dist/engine/decoders.js.map +1 -1
- package/dist/engine/loader.js +13 -14
- package/dist/engine/loader.js.map +1 -1
- package/dist/engine/requests.d.ts +1 -1
- package/dist/engine/requests.js +19 -16
- package/dist/engine/requests.js.map +1 -1
- package/dist/engine-loader.d.ts +13 -9
- package/dist/engine-loader.js +38 -28
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +26 -10
- package/dist/geoplateforme.js +45 -20
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_points_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/extrusions.d.ts +1 -1
- package/dist/layers/extrusions.js +10 -5
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +10 -10
- package/dist/layers/features.js +41 -42
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/glyphs.d.ts +3 -3
- package/dist/layers/glyphs.js +34 -40
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/icons.d.ts +8 -8
- package/dist/layers/icons.js +76 -68
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +1 -1
- package/dist/layers/layers.js +42 -29
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +2 -2
- package/dist/layers/panoramas.js +52 -41
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -3
- package/dist/layers/pointclouds.js +25 -33
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/symbols.d.ts +1 -1
- package/dist/layers/symbols.js +68 -71
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/vectors.d.ts +60 -0
- package/dist/layers/vectors.js +130 -0
- package/dist/layers/vectors.js.map +1 -0
- package/dist/map/basemap-layers.d.ts +26 -0
- package/dist/map/basemap-layers.js +61 -0
- package/dist/map/basemap-layers.js.map +1 -0
- package/dist/map/canvas.d.ts +17 -0
- package/dist/map/canvas.js +56 -0
- package/dist/map/canvas.js.map +1 -0
- package/dist/map/checks.d.ts +11 -0
- package/dist/map/checks.js +39 -0
- package/dist/map/checks.js.map +1 -0
- package/dist/map/credits.d.ts +17 -0
- package/dist/map/credits.js +34 -0
- package/dist/map/credits.js.map +1 -0
- package/dist/map/engine-settings.d.ts +15 -0
- package/dist/map/engine-settings.js +45 -0
- package/dist/map/engine-settings.js.map +1 -0
- package/dist/map/engines.d.ts +41 -0
- package/dist/map/engines.js +77 -0
- package/dist/map/engines.js.map +1 -0
- package/dist/map/events.d.ts +14 -0
- package/dist/map/events.js +46 -0
- package/dist/map/events.js.map +1 -0
- package/dist/map/frame-loop.d.ts +64 -0
- package/dist/map/frame-loop.js +145 -0
- package/dist/map/frame-loop.js.map +1 -0
- package/dist/map/hover-pick.d.ts +30 -0
- package/dist/map/hover-pick.js +56 -0
- package/dist/map/hover-pick.js.map +1 -0
- package/dist/map/layer-spec.d.ts +42 -0
- package/dist/map/layer-spec.js +34 -0
- package/dist/map/layer-spec.js.map +1 -0
- package/dist/map/layer-stack.d.ts +36 -0
- package/dist/map/layer-stack.js +101 -0
- package/dist/map/layer-stack.js.map +1 -0
- package/dist/map/overlay-host.d.ts +36 -0
- package/dist/map/overlay-host.js +101 -0
- package/dist/map/overlay-host.js.map +1 -0
- package/dist/map/panorama-host.d.ts +5 -0
- package/dist/map/panorama-host.js +32 -0
- package/dist/map/panorama-host.js.map +1 -0
- package/dist/map/raster-source.d.ts +11 -0
- package/dist/map/raster-source.js +26 -0
- package/dist/map/raster-source.js.map +1 -0
- package/dist/map/symbol-atlases.d.ts +26 -0
- package/dist/map/symbol-atlases.js +59 -0
- package/dist/map/symbol-atlases.js.map +1 -0
- package/dist/map/viewshed.d.ts +5 -0
- package/dist/map/viewshed.js +28 -0
- package/dist/map/viewshed.js.map +1 -0
- package/dist/map/workers.d.ts +46 -0
- package/dist/map/workers.js +73 -0
- package/dist/map/workers.js.map +1 -0
- package/dist/map.d.ts +54 -126
- package/dist/map.js +227 -698
- package/dist/map.js.map +1 -1
- package/dist/react/Control.d.ts +11 -0
- package/dist/react/Control.js +18 -0
- package/dist/react/Control.js.map +1 -0
- package/dist/react/CustomLayer.d.ts +11 -0
- package/dist/react/CustomLayer.js +30 -0
- package/dist/react/CustomLayer.js.map +1 -0
- package/dist/react/IsardMap.d.ts +43 -0
- package/dist/react/IsardMap.js +147 -0
- package/dist/react/IsardMap.js.map +1 -0
- package/dist/react/Layer.d.ts +42 -0
- package/dist/react/Layer.js +74 -0
- package/dist/react/Layer.js.map +1 -0
- package/dist/react/Marker.d.ts +24 -0
- package/dist/react/Marker.js +53 -0
- package/dist/react/Marker.js.map +1 -0
- package/dist/react/Panel.d.ts +11 -0
- package/dist/react/Panel.js +37 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/Popup.d.ts +18 -0
- package/dist/react/Popup.js +60 -0
- package/dist/react/Popup.js.map +1 -0
- package/dist/react/Swipe.d.ts +16 -0
- package/dist/react/Swipe.js +52 -0
- package/dist/react/Swipe.js.map +1 -0
- package/dist/react/VectorGeometry.d.ts +35 -0
- package/dist/react/VectorGeometry.js +82 -0
- package/dist/react/VectorGeometry.js.map +1 -0
- package/dist/react/Viewshed.d.ts +5 -0
- package/dist/react/Viewshed.js +28 -0
- package/dist/react/Viewshed.js.map +1 -0
- package/dist/react/context.d.ts +33 -0
- package/dist/react/context.js +20 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +16 -108
- package/dist/react/index.js +11 -397
- package/dist/react/index.js.map +1 -1
- package/dist/settings.d.ts +5 -9
- package/dist/settings.js +17 -15
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +27 -4
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +6 -4
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.d.ts +2 -2
- package/dist/ui/interaction.js +8 -7
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/minimap.d.ts +25 -0
- package/dist/ui/minimap.js +90 -0
- package/dist/ui/minimap.js.map +1 -0
- package/dist/ui/overlay.js +18 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/scale.d.ts +19 -0
- package/dist/ui/scale.js +44 -0
- package/dist/ui/scale.js.map +1 -0
- package/dist/ui/search.d.ts +25 -0
- package/dist/ui/search.js +119 -0
- package/dist/ui/search.js.map +1 -0
- package/dist/ui/style.d.ts +1 -1
- package/dist/ui/style.js +19 -2
- package/dist/ui/style.js.map +1 -1
- package/dist/util/animation.d.ts +3 -3
- package/dist/util/animation.js +6 -6
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +1 -1
- package/dist/util/color.js +14 -16
- package/dist/util/color.js.map +1 -1
- package/dist/util/geo.d.ts +6 -6
- package/dist/util/geo.js +12 -12
- package/dist/util/geo.js.map +1 -1
- package/dist/util/guards.d.ts +7 -0
- package/dist/util/guards.js +8 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/lru.js.map +1 -1
- package/dist/util/sun.d.ts +11 -0
- package/dist/util/sun.js +26 -0
- package/dist/util/sun.js.map +1 -0
- package/dist/wasm/isard.d.ts +250 -7
- package/dist/wasm/isard.js +375 -8
- package/dist/wasm/isard_core.d.ts +226 -7
- package/dist/wasm/isard_core.js +351 -8
- package/dist/wasm/isard_tess.d.ts +109 -0
- package/dist/wasm/isard_tess.js +398 -0
- package/dist/workers/basemap/geometry.d.ts +72 -0
- package/dist/workers/basemap/labels.d.ts +8 -0
- package/dist/workers/basemap/raster.d.ts +10 -0
- package/dist/workers/basemap/tiles.d.ts +65 -0
- package/dist/workers/basemap/trees.d.ts +19 -0
- package/dist/workers/basemap.worker.d.ts +126 -22
- package/dist/workers/basemap.worker.js +76 -544
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +5 -4
- package/vite.js +10 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** `<Swipe>`: the `<Layer>` in it on one side of a vertical line only, those of its `<SwipeOther>` on the other */
|
|
3
|
+
import { useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { defined, SwipeContext, useMap } from "./context.js";
|
|
5
|
+
/**
|
|
6
|
+
* The `<Layer>` in it shown on one side of a vertical line only, at `position` CSS pixels from the left; the layers in
|
|
7
|
+
* its `<SwipeOther>` on the other side only (two meshes of a place, each on its side)
|
|
8
|
+
*/
|
|
9
|
+
export const Swipe = (props) => {
|
|
10
|
+
const map = useMap();
|
|
11
|
+
const latest = useRef(props);
|
|
12
|
+
const { position, side } = props;
|
|
13
|
+
const layers = useMemo(() => new Set(), []);
|
|
14
|
+
const others = useMemo(() => new Set(), []);
|
|
15
|
+
latest.current = props;
|
|
16
|
+
const group = useMemo(() => {
|
|
17
|
+
if (!map)
|
|
18
|
+
return undefined;
|
|
19
|
+
const apply = () => map.setSwipe(swipeOptions(latest.current, layers, others));
|
|
20
|
+
const of = (set) => ({
|
|
21
|
+
set: (layer) => {
|
|
22
|
+
set.add(layer);
|
|
23
|
+
apply();
|
|
24
|
+
},
|
|
25
|
+
unset: (layer) => {
|
|
26
|
+
set.delete(layer);
|
|
27
|
+
apply();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return { ...of(layers), other: of(others) };
|
|
31
|
+
}, [map, layers, others]);
|
|
32
|
+
// The line's position and side sent to the map when they change (the layers in it come and go through the group)
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (map && (layers.size > 0 || others.size > 0))
|
|
35
|
+
map.setSwipe(swipeOptions({ position, side }, layers, others));
|
|
36
|
+
}, [map, layers, others, position, side]);
|
|
37
|
+
// The swipe taken off the map when unmounted
|
|
38
|
+
useEffect(() => () => {
|
|
39
|
+
map?.setSwipe(undefined);
|
|
40
|
+
}, [map]);
|
|
41
|
+
return _jsx(SwipeContext.Provider, { value: group, children: props.children });
|
|
42
|
+
};
|
|
43
|
+
/** The swipe of the line's props and the layers of both sides; undefined when no layer is in it */
|
|
44
|
+
const swipeOptions = ({ position, side }, layers, others) => layers.size > 0 || others.size > 0
|
|
45
|
+
? { position, layers: [...layers], other: [...others], ...defined({ side }) }
|
|
46
|
+
: undefined;
|
|
47
|
+
/** In a `<Swipe>`: the `<Layer>` in it shown on the other side of the line only */
|
|
48
|
+
export const SwipeOther = ({ children }) => {
|
|
49
|
+
const group = useContext(SwipeContext);
|
|
50
|
+
return _jsx(SwipeContext.Provider, { value: group?.other, children: children });
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Swipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swipe.js","sourceRoot":"","sources":["../../src/react/Swipe.tsx"],"names":[],"mappings":";AAAA,mHAAmH;AAEnH,OAAO,EAAkB,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AAO9E;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,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ourcesContent":["/** `<Swipe>`: the `<Layer>` in it on one side of a vertical line only, those of its `<SwipeOther>` on the other */\n\nimport { type ReactNode, useContext, useEffect, useMemo, useRef } from 'react';\nimport type { Layer as LayerHandle } from '../layers/layers.ts';\nimport type { SwipeOptions } from '../types.ts';\nimport { defined, SwipeContext, type SwipeGroup, useMap } from './context.ts';\n\nexport interface SwipeProps extends Omit<SwipeOptions, 'layers' | 'other'> {\n /** The `<Layer>` shown on one side of the line only, and a `<SwipeOther>` for the other side */\n children?: ReactNode;\n}\n\n/**\n * The `<Layer>` in it shown on one side of a vertical line only, at `position` CSS pixels from the left; the layers in\n * its `<SwipeOther>` on the other side only (two meshes of a place, each on its side)\n */\nexport const Swipe = (props: SwipeProps): ReactNode => {\n const map = useMap();\n const latest = useRef(props);\n const { position, side } = props;\n const layers = useMemo(() => new Set<LayerHandle>(), []);\n const others = useMemo(() => new Set<LayerHandle>(), []);\n\n latest.current = props;\n\n const group = useMemo<SwipeGroup | undefined>(() => {\n if (!map) return undefined;\n\n const apply = () => map.setSwipe(swipeOptions(latest.current, layers, others));\n const of = (set: Set<LayerHandle>): SwipeGroup => ({\n set: (layer) => {\n set.add(layer);\n apply();\n },\n unset: (layer) => {\n set.delete(layer);\n apply();\n },\n });\n\n return { ...of(layers), other: of(others) };\n }, [map, layers, others]);\n\n // The line's position and side sent to the map when they change (the layers in it come and go through the group)\n useEffect(() => {\n if (map && (layers.size > 0 || others.size > 0)) map.setSwipe(swipeOptions({ position, side }, layers, others));\n }, [map, layers, others, position, side]);\n // The swipe taken off the map when unmounted\n useEffect(\n () => () => {\n map?.setSwipe(undefined);\n },\n [map],\n );\n\n return <SwipeContext.Provider value={group}>{props.children}</SwipeContext.Provider>;\n};\n\n/** The swipe of the line's props and the layers of both sides; undefined when no layer is in it */\nconst swipeOptions = (\n { position, side }: { position: number; side?: SwipeProps['side'] | undefined },\n layers: Set<LayerHandle>,\n others: Set<LayerHandle>,\n): SwipeOptions | undefined =>\n layers.size > 0 || others.size > 0\n ? { position, layers: [...layers], other: [...others], ...defined({ side }) }\n : undefined;\n\n/** In a `<Swipe>`: the `<Layer>` in it shown on the other side of the line only */\nexport const SwipeOther = ({ children }: { children?: ReactNode }): ReactNode => {\n const group = useContext(SwipeContext);\n\n return <SwipeContext.Provider value={group?.other}>{children}</SwipeContext.Provider>;\n};\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the
|
|
2
|
+
* layers of the components */
|
|
3
|
+
import { type ReactNode, type Ref } from 'react';
|
|
4
|
+
import type { Style, StyleLayer } from '../basemap/vectorstyle.ts';
|
|
5
|
+
import type { VectorLayer, VectorSublayer } from '../layers/vectors.ts';
|
|
6
|
+
export interface VectorGeometryProps {
|
|
7
|
+
/** A style URL or object (default OpenFreeMap's Positron); another one makes the layer anew */
|
|
8
|
+
style?: string | Style;
|
|
9
|
+
/** The style layers drawn (default all its fills and lines); another function makes the layer anew, so keep it in a
|
|
10
|
+
* memo or at the module's level */
|
|
11
|
+
layers?: (layer: StyleLayer) => boolean;
|
|
12
|
+
/** The line layers that glow at night (default those whose id names a road); another function makes the layer anew,
|
|
13
|
+
* as `layers` */
|
|
14
|
+
streets?: (layer: StyleLayer) => boolean;
|
|
15
|
+
/** Paint properties over the style's (`setPaintProperty`), by style layer id, or by style layer drawn once the style
|
|
16
|
+
* is loaded (a function of its id, kind, source layer): compared by value, only those changed sent; one taken out
|
|
17
|
+
* keeps its last value */
|
|
18
|
+
paint?: Paint | ((layer: VectorSublayer) => Record<string, unknown> | undefined);
|
|
19
|
+
/** Shown (default true) */
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
/** Its place among the layers of the components (as `<Layer order>`) */
|
|
22
|
+
order?: number;
|
|
23
|
+
/** The layer, once created and each time it is made anew */
|
|
24
|
+
onLayer?: (layer: VectorLayer) => void;
|
|
25
|
+
ref?: Ref<VectorLayer | undefined>;
|
|
26
|
+
}
|
|
27
|
+
/** Paint properties by style layer id */
|
|
28
|
+
type Paint = Record<string, Record<string, unknown>>;
|
|
29
|
+
/**
|
|
30
|
+
* The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):
|
|
31
|
+
* sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature
|
|
32
|
+
* (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)
|
|
33
|
+
*/
|
|
34
|
+
export declare const VectorGeometry: (props: VectorGeometryProps) => ReactNode;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the
|
|
2
|
+
* layers of the components */
|
|
3
|
+
import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
|
+
import { MapContext, SwipeContext } from "./context.js";
|
|
5
|
+
/** The paint properties of `next` that differ from those of `sent`, as `[layer, name, value]` */
|
|
6
|
+
const changed = (sent, next) => Object.entries(next ?? {}).flatMap(([layer, properties]) => Object.entries(properties)
|
|
7
|
+
.filter(([name, value]) => JSON.stringify(sent?.[layer]?.[name]) !== JSON.stringify(value))
|
|
8
|
+
.map(([name, value]) => [layer, name, value]));
|
|
9
|
+
const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, layers, streets, paint, visible = true, order = 0, onLayer }, ref) {
|
|
10
|
+
const binding = useContext(MapContext);
|
|
11
|
+
const swipe = useContext(SwipeContext);
|
|
12
|
+
const latest = useRef({ order, onLayer });
|
|
13
|
+
/** The paint properties sent to the current layer */
|
|
14
|
+
const sent = useRef(undefined);
|
|
15
|
+
const [layer, setLayer] = useState();
|
|
16
|
+
latest.current = { order, onLayer };
|
|
17
|
+
useImperativeHandle(ref, () => layer, [layer]);
|
|
18
|
+
// The tiles and their geometry layer created once the map is there, in the declared order; made anew when the
|
|
19
|
+
// style, the layers kept or the streets change; the tiles (and their layer) destroyed when unmounted
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!binding)
|
|
22
|
+
return;
|
|
23
|
+
const tiles = binding.map.vectorTiles(style === undefined ? {} : { style });
|
|
24
|
+
const created = tiles.vectors({ ...(layers && { layers }), ...(streets && { streets }) });
|
|
25
|
+
binding.order.place(created, latest.current.order);
|
|
26
|
+
swipe?.set(created);
|
|
27
|
+
sent.current = undefined;
|
|
28
|
+
setLayer(created);
|
|
29
|
+
latest.current.onLayer?.(created);
|
|
30
|
+
return () => {
|
|
31
|
+
binding.order.remove(created);
|
|
32
|
+
swipe?.unset(created);
|
|
33
|
+
tiles.destroy();
|
|
34
|
+
setLayer(undefined);
|
|
35
|
+
};
|
|
36
|
+
}, [binding, swipe, style, layers, streets]);
|
|
37
|
+
// The paint properties changed since the last ones sent (all of them to a layer made anew), those of a function
|
|
38
|
+
// once the style is loaded; a later render or layer drops the wait
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!layer)
|
|
41
|
+
return;
|
|
42
|
+
const apply = (next) => {
|
|
43
|
+
changed(sent.current, next).forEach(([id, name, value]) => {
|
|
44
|
+
layer.setPaintProperty(id, name, value);
|
|
45
|
+
});
|
|
46
|
+
sent.current = next;
|
|
47
|
+
};
|
|
48
|
+
if (typeof paint !== 'function') {
|
|
49
|
+
apply(paint);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const wait = { live: true };
|
|
53
|
+
layer.ready.then(() => {
|
|
54
|
+
if (!wait.live)
|
|
55
|
+
return;
|
|
56
|
+
apply(Object.fromEntries(layer.layers.flatMap((l) => {
|
|
57
|
+
const properties = paint(l);
|
|
58
|
+
return properties ? [[l.id, properties]] : [];
|
|
59
|
+
})));
|
|
60
|
+
}, () => undefined);
|
|
61
|
+
return () => {
|
|
62
|
+
wait.live = false;
|
|
63
|
+
};
|
|
64
|
+
}, [layer, paint]);
|
|
65
|
+
// Shown or hidden
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
layer?.setVisible(visible);
|
|
68
|
+
}, [layer, visible]);
|
|
69
|
+
// A new `order`: moved to its new place among the layers of the components
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (binding && layer)
|
|
72
|
+
binding.order.place(layer, order, layer);
|
|
73
|
+
}, [binding, layer, order]);
|
|
74
|
+
return null;
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):
|
|
78
|
+
* sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature
|
|
79
|
+
* (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)
|
|
80
|
+
*/
|
|
81
|
+
export const VectorGeometry = VectorGeometryComponent;
|
|
82
|
+
//# sourceMappingURL=VectorGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorGeometry.js","sourceRoot":"","sources":["../../src/react/VectorGeometry.tsx"],"names":[],"mappings":"AAAA;8BAC8B;AAE9B,OAAO,EACL,UAAU,EAGV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA2BxD,iGAAiG;AACjG,MAAM,OAAO,GAAG,CAAC,IAAuB,EAAE,IAAuB,EAAmD,EAAE,CACpH,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,CACzD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;KACvB,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK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AE,IAAI,EAAE,CAAC;QAE5B,KAAK,CAAC,KAAK,CAAC,IAAI,CACd,GAAG,EAAE;YACH,IAAI,CAAC,IAAI,CAAC,IAAI;gBAAE,OAAO;YACvB,KAAK,CACH,MAAM,CAAC,WAAW,CAChB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACzB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE5B,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,CAAC,CAAC,CACH,CACF,CAAC;QACJ,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,kBAAkB;IAClB,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAErB,2EAA2E;IAC3E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,IAAI,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAE5B,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAoE,CAAC","sourcesContent":["/** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the\n * layers of the components */\n\nimport {\n forwardRef,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport type { Style, StyleLayer } from '../basemap/vectorstyle.ts';\nimport type { VectorLayer, VectorSublayer } from '../layers/vectors.ts';\nimport { MapContext, SwipeContext } from './context.ts';\n\nexport interface VectorGeometryProps {\n /** A style URL or object (default OpenFreeMap's Positron); another one makes the layer anew */\n style?: string | Style;\n /** The style layers drawn (default all its fills and lines); another function makes the layer anew, so keep it in a\n * memo or at the module's level */\n layers?: (layer: StyleLayer) => boolean;\n /** The line layers that glow at night (default those whose id names a road); another function makes the layer anew,\n * as `layers` */\n streets?: (layer: StyleLayer) => boolean;\n /** Paint properties over the style's (`setPaintProperty`), by style layer id, or by style layer drawn once the style\n * is loaded (a function of its id, kind, source layer): compared by value, only those changed sent; one taken out\n * keeps its last value */\n paint?: Paint | ((layer: VectorSublayer) => Record<string, unknown> | undefined);\n /** Shown (default true) */\n visible?: boolean;\n /** Its place among the layers of the components (as `<Layer order>`) */\n order?: number;\n /** The layer, once created and each time it is made anew */\n onLayer?: (layer: VectorLayer) => void;\n ref?: Ref<VectorLayer | undefined>;\n}\n\n/** Paint properties by style layer id */\ntype Paint = Record<string, Record<string, unknown>>;\n\n/** The paint properties of `next` that differ from those of `sent`, as `[layer, name, value]` */\nconst changed = (sent: Paint | undefined, next: Paint | undefined): [layer: string, name: string, value: unknown][] =>\n Object.entries(next ?? {}).flatMap(([layer, properties]) =>\n Object.entries(properties)\n .filter(([name, value]) => JSON.stringify(sent?.[layer]?.[name]) !== JSON.stringify(value))\n .map(([name, value]): [string, string, unknown] => [layer, name, value]),\n );\n\nconst VectorGeometryComponent = forwardRef<VectorLayer | undefined, Omit<VectorGeometryProps, 'ref'>>(\n function VectorGeometry({ style, layers, streets, paint, visible = true, order = 0, onLayer }, ref) {\n const binding = useContext(MapContext);\n const swipe = useContext(SwipeContext);\n const latest = useRef({ order, onLayer });\n /** The paint properties sent to the current layer */\n const sent = useRef<Paint>(undefined);\n const [layer, setLayer] = useState<VectorLayer>();\n\n latest.current = { order, onLayer };\n useImperativeHandle(ref, () => layer, [layer]);\n\n // The tiles and their geometry layer created once the map is there, in the declared order; made anew when the\n // style, the layers kept or the streets change; the tiles (and their layer) destroyed when unmounted\n useEffect(() => {\n if (!binding) return;\n\n const tiles = binding.map.vectorTiles(style === undefined ? {} : { style });\n const created = tiles.vectors({ ...(layers && { layers }), ...(streets && { streets }) });\n\n binding.order.place(created, latest.current.order);\n swipe?.set(created);\n sent.current = undefined;\n setLayer(created);\n latest.current.onLayer?.(created);\n\n return () => {\n binding.order.remove(created);\n swipe?.unset(created);\n tiles.destroy();\n setLayer(undefined);\n };\n }, [binding, swipe, style, layers, streets]);\n\n // The paint properties changed since the last ones sent (all of them to a layer made anew), those of a function\n // once the style is loaded; a later render or layer drops the wait\n useEffect(() => {\n if (!layer) return;\n\n const apply = (next: Paint | undefined) => {\n changed(sent.current, next).forEach(([id, name, value]) => {\n layer.setPaintProperty(id, name, value);\n });\n sent.current = next;\n };\n\n if (typeof paint !== 'function') {\n apply(paint);\n\n return;\n }\n\n const wait = { live: true };\n\n layer.ready.then(\n () => {\n if (!wait.live) return;\n apply(\n Object.fromEntries(\n layer.layers.flatMap((l) => {\n const properties = paint(l);\n\n return properties ? [[l.id, properties]] : [];\n }),\n ),\n );\n },\n () => undefined,\n );\n\n return () => {\n wait.live = false;\n };\n }, [layer, paint]);\n\n // Shown or hidden\n useEffect(() => {\n layer?.setVisible(visible);\n }, [layer, visible]);\n\n // A new `order`: moved to its new place among the layers of the components\n useEffect(() => {\n if (binding && layer) binding.order.place(layer, order, layer);\n }, [binding, layer, order]);\n\n return null;\n },\n);\n\n/**\n * The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):\n * sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature\n * (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)\n */\nexport const VectorGeometry = VectorGeometryComponent as (props: VectorGeometryProps) => ReactNode;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** `<Viewshed>`: an observer's viewshed, several drawn together */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { ViewshedOptions } from '../types.ts';
|
|
4
|
+
/** An observer's viewshed; several `<Viewshed>` are drawn together */
|
|
5
|
+
export declare const Viewshed: (props: ViewshedOptions) => ReactNode;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** `<Viewshed>`: an observer's viewshed, several drawn together */
|
|
2
|
+
import { useContext, useEffect, useMemo } from 'react';
|
|
3
|
+
import { MapContext } from "./context.js";
|
|
4
|
+
/** An observer's viewshed; several `<Viewshed>` are drawn together */
|
|
5
|
+
export const Viewshed = (props) => {
|
|
6
|
+
const binding = useContext(MapContext);
|
|
7
|
+
const key = useMemo(() => ({}), []);
|
|
8
|
+
// Numbers, strings and the position: compared by value
|
|
9
|
+
const options = JSON.stringify(props);
|
|
10
|
+
// Its observer taken off the map's viewsheds when unmounted
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!binding)
|
|
13
|
+
return;
|
|
14
|
+
return () => {
|
|
15
|
+
binding.viewsheds.delete(key);
|
|
16
|
+
binding.applyViewsheds();
|
|
17
|
+
};
|
|
18
|
+
}, [binding, key]);
|
|
19
|
+
// Its observer set among the map's viewsheds when its options change (compared by value)
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!binding)
|
|
22
|
+
return;
|
|
23
|
+
binding.viewsheds.set(key, JSON.parse(options));
|
|
24
|
+
binding.applyViewsheds();
|
|
25
|
+
}, [binding, key, options]);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=Viewshed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Viewshed.js","sourceRoot":"","sources":["../../src/react/Viewshed.tsx"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,OAAO,EAAkB,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAsB,EAAa,EAAE;IAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACpC,uDAAuD;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEtC,4DAA4D;IAC5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9B,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAEnB,yFAAyF;IACzF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,CAAC,CAAC;QACnE,OAAO,CAAC,cAAc,EAAE,CAAC;IAC3B,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["/** `<Viewshed>`: an observer's viewshed, several drawn together */\n\nimport { type ReactNode, useContext, useEffect, useMemo } from 'react';\nimport type { ViewshedOptions } from '../types.ts';\nimport { MapContext } from './context.ts';\n\n/** An observer's viewshed; several `<Viewshed>` are drawn together */\nexport const Viewshed = (props: ViewshedOptions): ReactNode => {\n const binding = useContext(MapContext);\n const key = useMemo(() => ({}), []);\n // Numbers, strings and the position: compared by value\n const options = JSON.stringify(props);\n\n // Its observer taken off the map's viewsheds when unmounted\n useEffect(() => {\n if (!binding) return;\n\n return () => {\n binding.viewsheds.delete(key);\n binding.applyViewsheds();\n };\n }, [binding, key]);\n\n // Its observer set among the map's viewsheds when its options change (compared by value)\n useEffect(() => {\n if (!binding) return;\n binding.viewsheds.set(key, JSON.parse(options) as ViewshedOptions);\n binding.applyViewsheds();\n }, [binding, key, options]);\n\n return null;\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker
|
|
2
|
+
* around; the hooks */
|
|
3
|
+
import type { LayerOrder } from '../bind/layers.ts';
|
|
4
|
+
import type { Layer as LayerHandle } from '../layers/layers.ts';
|
|
5
|
+
import type { GeoMap } from '../map.ts';
|
|
6
|
+
import type { LonLat, MapEvents, ViewshedOptions } from '../types.ts';
|
|
7
|
+
import type { Marker as MarkerHandle } from '../ui/overlay.ts';
|
|
8
|
+
export interface Binding {
|
|
9
|
+
map: GeoMap;
|
|
10
|
+
order: LayerOrder;
|
|
11
|
+
/** The observers of the `<Viewshed>` components, set on the map together */
|
|
12
|
+
viewsheds: Map<object, ViewshedOptions>;
|
|
13
|
+
applyViewsheds(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const MapContext: import("react").Context<Binding | undefined>;
|
|
16
|
+
/** The layers of a `<Swipe>` around, its `<Layer>` children joining it; `other`: the group of its `<SwipeOther>` */
|
|
17
|
+
export interface SwipeGroup {
|
|
18
|
+
set(layer: LayerHandle): void;
|
|
19
|
+
unset(layer: LayerHandle): void;
|
|
20
|
+
other?: SwipeGroup;
|
|
21
|
+
}
|
|
22
|
+
export declare const SwipeContext: import("react").Context<SwipeGroup | undefined>;
|
|
23
|
+
/** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */
|
|
24
|
+
export declare const MarkerContext: import("react").Context<{
|
|
25
|
+
marker: MarkerHandle;
|
|
26
|
+
lonLat: LonLat;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
/** The map of the `<IsardMap>` around, once created (undefined before) */
|
|
29
|
+
export declare const useMap: () => GeoMap | undefined;
|
|
30
|
+
/** Listens to an event of the map around while the component is mounted; the listener may change at each render */
|
|
31
|
+
export declare const useMapEvent: <K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void) => void;
|
|
32
|
+
/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */
|
|
33
|
+
export declare const defined: <T extends object>(object: T) => { [K in keyof T]?: Exclude<T[K], undefined>; };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker
|
|
2
|
+
* around; the hooks */
|
|
3
|
+
import { createContext, useContext, useEffect, useRef } from 'react';
|
|
4
|
+
export const MapContext = createContext(undefined);
|
|
5
|
+
export const SwipeContext = createContext(undefined);
|
|
6
|
+
/** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */
|
|
7
|
+
export const MarkerContext = createContext(undefined);
|
|
8
|
+
/** The map of the `<IsardMap>` around, once created (undefined before) */
|
|
9
|
+
export const useMap = () => useContext(MapContext)?.map;
|
|
10
|
+
/** Listens to an event of the map around while the component is mounted; the listener may change at each render */
|
|
11
|
+
export const useMapEvent = (type, listener) => {
|
|
12
|
+
const map = useMap();
|
|
13
|
+
const latest = useRef(listener);
|
|
14
|
+
latest.current = listener;
|
|
15
|
+
// Listening while mounted, to the listener of the last render; stops when unmounted or the map changes
|
|
16
|
+
useEffect(() => map?.on(type, (event) => latest.current(event)), [map, type]);
|
|
17
|
+
};
|
|
18
|
+
/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */
|
|
19
|
+
export const defined = (object) => Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));
|
|
20
|
+
//# sourceMappingURL=context.js.map
|
|
@@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Content":["/** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker\n * around; the hooks */\n\nimport { createContext, useContext, useEffect, useRef } from 'react';\nimport type { LayerOrder } from '../bind/layers.ts';\nimport type { Layer as LayerHandle } from '../layers/layers.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { LonLat, MapEvents, ViewshedOptions } from '../types.ts';\nimport type { Marker as MarkerHandle } from '../ui/overlay.ts';\n\nexport interface Binding {\n map: GeoMap;\n order: LayerOrder;\n /** The observers of the `<Viewshed>` components, set on the map together */\n viewsheds: Map<object, ViewshedOptions>;\n applyViewsheds(): void;\n}\n\nexport const MapContext = createContext<Binding | undefined>(undefined);\n\n/** The layers of a `<Swipe>` around, its `<Layer>` children joining it; `other`: the group of its `<SwipeOther>` */\nexport interface SwipeGroup {\n set(layer: LayerHandle): void;\n unset(layer: LayerHandle): void;\n other?: SwipeGroup;\n}\n\nexport const SwipeContext = createContext<SwipeGroup | undefined>(undefined);\n\n/** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */\nexport const MarkerContext = createContext<{ marker: MarkerHandle; lonLat: LonLat } | undefined>(undefined);\n\n/** The map of the `<IsardMap>` around, once created (undefined before) */\nexport const useMap = (): GeoMap | undefined => useContext(MapContext)?.map;\n\n/** Listens to an event of the map around while the component is mounted; the listener may change at each render */\nexport const useMapEvent = <K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void): void => {\n const map = useMap();\n const latest = useRef(listener);\n\n latest.current = listener;\n // Listening while mounted, to the listener of the last render; stops when unmounted or the map changes\n useEffect(() => map?.on(type, (event) => latest.current(event)), [map, type]);\n};\n\n/** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */\nexport const defined = <T extends object>(object: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>\n Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined)) as {\n [K in keyof T]?: Exclude<T[K], undefined>;\n };\n"]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -9,111 +9,19 @@
|
|
|
9
9
|
* </IsardMap>
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
onHover?: (event: MapEvents['hover']) => void;
|
|
29
|
-
onHoverFeature?: (event: MapEvents['hoverfeature']) => void;
|
|
30
|
-
onClick?: (event: MapEvents['click']) => void;
|
|
31
|
-
onRender?: (event: MapEvents['render']) => void;
|
|
32
|
-
onIdle?: () => void;
|
|
33
|
-
onLeave?: () => void;
|
|
34
|
-
}
|
|
35
|
-
export interface IsardMapProps extends Omit<GeoMapOptions, keyof Camera>, MapEventProps {
|
|
36
|
-
/** The camera at creation, then left to the user's gestures */
|
|
37
|
-
center?: LonLat;
|
|
38
|
-
zoom?: number;
|
|
39
|
-
pitch?: number;
|
|
40
|
-
bearing?: number;
|
|
41
|
-
/** A camera the map follows: set again whenever it changes (with `onMove` to keep it in a state) */
|
|
42
|
-
camera?: Partial<Camera>;
|
|
43
|
-
/** The map, once created */
|
|
44
|
-
onLoad?: (map: GeoMap) => void;
|
|
45
|
-
/** The map's creation failed (no WebGL2, the engine not found) */
|
|
46
|
-
onError?: (error: unknown) => void;
|
|
47
|
-
id?: string;
|
|
48
|
-
className?: string;
|
|
49
|
-
style?: CSSProperties;
|
|
50
|
-
/** Layers, markers, popups, panels, effects; drawn once the map is created */
|
|
51
|
-
children?: ReactNode;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* A map filling its element (give it a height). Created once mounted, destroyed when unmounted; the options read at
|
|
55
|
-
* creation only (`body`, `preset`, `interactive`, the URLs) need a new `key` to take another value
|
|
56
|
-
*/
|
|
57
|
-
export declare const IsardMap: import("react").ForwardRefExoticComponent<IsardMapProps & import("react").RefAttributes<GeoMap | undefined>>;
|
|
58
|
-
export type LayerProps<P = Record<string, unknown>> = LayerSpec<P> & {
|
|
59
|
-
/** Its place among the layers of the components: from the bottom up, the same order by mounting (default 0) */
|
|
60
|
-
order?: number;
|
|
61
|
-
/** The layer, once created and each time it is made anew */
|
|
62
|
-
onLayer?: (layer: LayerHandle) => void;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* A layer: the options of its `add…` method with its `type` (`map.add`). A change of data, style or instances updates
|
|
66
|
-
* it; a change of what is set at creation (its URL, grid, nodes…) makes it anew, in its place. Data, functions and
|
|
67
|
-
* arrays are compared by identity: keep them in a memo or a state. The ref gives the layer's handle
|
|
68
|
-
*/
|
|
69
|
-
export declare const Layer: import("react").ForwardRefExoticComponent<LayerProps<Record<string, unknown>> & import("react").RefAttributes<LayerHandle | undefined>>;
|
|
70
|
-
export interface MarkerProps {
|
|
71
|
-
lonLat: LonLat;
|
|
72
|
-
/** Metres above the ground, its stem down to `base` (what it stands on: a roof, a mesh) */
|
|
73
|
-
height?: number;
|
|
74
|
-
base?: number;
|
|
75
|
-
draggable?: boolean;
|
|
76
|
-
offset?: Point;
|
|
77
|
-
/** Which part of the element sits on the position (default 'bottom' for the pin, 'center' with an icon) */
|
|
78
|
-
anchor?: Anchor;
|
|
79
|
-
className?: string;
|
|
80
|
-
/** The marker's look, in place of the default pin; the element changes with it */
|
|
81
|
-
icon?: ReactNode;
|
|
82
|
-
onDragStart?: (lonLat: LonLat) => void;
|
|
83
|
-
onDrag?: (lonLat: LonLat) => void;
|
|
84
|
-
onDragEnd?: (lonLat: LonLat) => void;
|
|
85
|
-
/** A `<Popup>` opened by a click on the marker */
|
|
86
|
-
children?: ReactNode;
|
|
87
|
-
}
|
|
88
|
-
/** A marker at a position, its look the default pin or the `icon` given */
|
|
89
|
-
export declare function Marker(props: MarkerProps): ReactNode;
|
|
90
|
-
export interface PopupProps extends PopupOptions {
|
|
91
|
-
/** Its position; in a `<Marker>`, the marker's */
|
|
92
|
-
lonLat?: LonLat;
|
|
93
|
-
/** Metres above the ground (in a `<Marker>`, the marker's) */
|
|
94
|
-
height?: number;
|
|
95
|
-
/** Open or closed, when the application decides; else open when mounted alone, on the marker's click in a marker */
|
|
96
|
-
open?: boolean;
|
|
97
|
-
onOpen?: () => void;
|
|
98
|
-
/** Closed by its button, a click on the map, or the marker's click */
|
|
99
|
-
onClose?: () => void;
|
|
100
|
-
children?: ReactNode;
|
|
101
|
-
}
|
|
102
|
-
/** A popup of JSX content, at a position or on a `<Marker>` */
|
|
103
|
-
export declare function Popup(props: PopupProps): ReactNode;
|
|
104
|
-
export interface PanelProps extends Omit<PanelOptions, 'element'> {
|
|
105
|
-
lonLat: LonLat;
|
|
106
|
-
/** What stands in 3D: a video, an iframe, a sign */
|
|
107
|
-
children?: ReactNode;
|
|
108
|
-
}
|
|
109
|
-
/** JSX standing in 3D at a position, `width` metres wide, facing `heading` */
|
|
110
|
-
export declare function Panel(props: PanelProps): ReactNode;
|
|
111
|
-
/** An observer's viewshed; several `<Viewshed>` are drawn together */
|
|
112
|
-
export declare function Viewshed(props: ViewshedOptions): ReactNode;
|
|
113
|
-
export interface SwipeProps extends Omit<SwipeOptions, 'layers'> {
|
|
114
|
-
/** The `<Layer>` shown on one side of the line only */
|
|
115
|
-
children?: ReactNode;
|
|
116
|
-
}
|
|
117
|
-
/** The `<Layer>` in it shown on one side of a vertical line only, at `position` CSS pixels from the left */
|
|
118
|
-
export declare function Swipe(props: SwipeProps): ReactNode;
|
|
119
|
-
export type { Camera, GeoMap, LayerHandle, LayerSpec, LonLat, MarkerHandle, PanelHandle, PopupHandle };
|
|
12
|
+
export type { Layer as LayerHandle } from '../layers/layers.ts';
|
|
13
|
+
export type { GeoMap, LayerSpec } from '../map.ts';
|
|
14
|
+
export type { LonLat } from '../types.ts';
|
|
15
|
+
export type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';
|
|
16
|
+
export type { Camera } from '../wasm/isard.js';
|
|
17
|
+
export { Control, type ControlProps } from './Control.tsx';
|
|
18
|
+
export { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';
|
|
19
|
+
export { useMap, useMapEvent } from './context.ts';
|
|
20
|
+
export { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';
|
|
21
|
+
export { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';
|
|
22
|
+
export { Marker, type MarkerProps } from './Marker.tsx';
|
|
23
|
+
export { Panel, type PanelProps } from './Panel.tsx';
|
|
24
|
+
export { Popup, type PopupProps } from './Popup.tsx';
|
|
25
|
+
export { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';
|
|
26
|
+
export { VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';
|
|
27
|
+
export { Viewshed } from './Viewshed.tsx';
|