isard 1.6.0 → 1.7.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/basemap/furniture.d.ts +20 -2
  3. package/dist/basemap/furniture.js +72 -3
  4. package/dist/basemap/furniture.js.map +1 -1
  5. package/dist/basemap/meshes.d.ts +21 -0
  6. package/dist/basemap/meshes.js +159 -0
  7. package/dist/basemap/meshes.js.map +1 -0
  8. package/dist/basemap/placed.d.ts +13 -0
  9. package/dist/basemap/placed.js +14 -0
  10. package/dist/basemap/placed.js.map +1 -0
  11. package/dist/basemap/trees.d.ts +4 -14
  12. package/dist/basemap/trees.js +12 -93
  13. package/dist/basemap/trees.js.map +1 -1
  14. package/dist/basemap/vectortiles/context.d.ts +4 -2
  15. package/dist/basemap/vectortiles/context.js.map +1 -1
  16. package/dist/basemap/vectortiles/extrusions.d.ts +1 -1
  17. package/dist/basemap/vectortiles/extrusions.js +7 -16
  18. package/dist/basemap/vectortiles/extrusions.js.map +1 -1
  19. package/dist/basemap/vectortiles/furniture.d.ts +19 -0
  20. package/dist/basemap/vectortiles/furniture.js +29 -0
  21. package/dist/basemap/vectortiles/furniture.js.map +1 -0
  22. package/dist/basemap/vectortiles/labels.js +8 -1
  23. package/dist/basemap/vectortiles/labels.js.map +1 -1
  24. package/dist/basemap/vectortiles/lamps.js +11 -76
  25. package/dist/basemap/vectortiles/lamps.js.map +1 -1
  26. package/dist/basemap/vectortiles/placed.d.ts +38 -0
  27. package/dist/basemap/vectortiles/placed.js +143 -0
  28. package/dist/basemap/vectortiles/placed.js.map +1 -0
  29. package/dist/basemap/vectortiles/street-wind.js +4 -6
  30. package/dist/basemap/vectortiles/street-wind.js.map +1 -1
  31. package/dist/basemap/vectortiles/trees.d.ts +2 -9
  32. package/dist/basemap/vectortiles/trees.js +34 -165
  33. package/dist/basemap/vectortiles/trees.js.map +1 -1
  34. package/dist/basemap/vectortiles/vectors.d.ts +4 -5
  35. package/dist/basemap/vectortiles/vectors.js +17 -16
  36. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  37. package/dist/basemap/vectortiles.d.ts +14 -4
  38. package/dist/basemap/vectortiles.js +40 -12
  39. package/dist/basemap/vectortiles.js.map +1 -1
  40. package/dist/basemap/wmts.js +2 -2
  41. package/dist/basemap/wmts.js.map +1 -1
  42. package/dist/basemap.worker.js +2 -2
  43. package/dist/basemap.worker.js.map +18 -14
  44. package/dist/data/collada.js +3 -17
  45. package/dist/data/collada.js.map +1 -1
  46. package/dist/data/crs.js +1 -1
  47. package/dist/data/crs.js.map +1 -1
  48. package/dist/data/ifc.js +21 -22
  49. package/dist/data/ifc.js.map +1 -1
  50. package/dist/geoplateforme.d.ts +14 -2
  51. package/dist/geoplateforme.js +24 -2
  52. package/dist/geoplateforme.js.map +1 -1
  53. package/dist/index.d.ts +5 -4
  54. package/dist/index.js +3 -3
  55. package/dist/index.js.map +1 -1
  56. package/dist/isard_bg.wasm +0 -0
  57. package/dist/isard_core_bg.wasm +0 -0
  58. package/dist/isard_grid_bg.wasm +0 -0
  59. package/dist/isard_tess_bg.wasm +0 -0
  60. package/dist/layers/extrusions.js +5 -4
  61. package/dist/layers/extrusions.js.map +1 -1
  62. package/dist/layers/features.d.ts +0 -2
  63. package/dist/layers/features.js +5 -6
  64. package/dist/layers/features.js.map +1 -1
  65. package/dist/layers/layers.d.ts +2 -0
  66. package/dist/layers/layers.js +11 -0
  67. package/dist/layers/layers.js.map +1 -1
  68. package/dist/layers/panoramas.d.ts +32 -10
  69. package/dist/layers/panoramas.js +55 -28
  70. package/dist/layers/panoramas.js.map +1 -1
  71. package/dist/layers/photos.js +5 -6
  72. package/dist/layers/photos.js.map +1 -1
  73. package/dist/layers/trees.js +7 -7
  74. package/dist/layers/trees.js.map +1 -1
  75. package/dist/layers/vectors.d.ts +1 -0
  76. package/dist/layers/vectors.js +23 -8
  77. package/dist/layers/vectors.js.map +1 -1
  78. package/dist/map/frame-loop.d.ts +2 -0
  79. package/dist/map/frame-loop.js +3 -3
  80. package/dist/map/frame-loop.js.map +1 -1
  81. package/dist/map.js +17 -0
  82. package/dist/map.js.map +1 -1
  83. package/dist/panoramax.d.ts +6 -0
  84. package/dist/panoramax.js +29 -3
  85. package/dist/panoramax.js.map +1 -1
  86. package/dist/react/VectorGeometry.d.ts +18 -9
  87. package/dist/react/VectorGeometry.js +27 -13
  88. package/dist/react/VectorGeometry.js.map +1 -1
  89. package/dist/react/VectorTiles.d.ts +65 -0
  90. package/dist/react/VectorTiles.js +112 -0
  91. package/dist/react/VectorTiles.js.map +1 -0
  92. package/dist/react/context.d.ts +9 -0
  93. package/dist/react/context.js +32 -0
  94. package/dist/react/context.js.map +1 -1
  95. package/dist/react/index.d.ts +7 -1
  96. package/dist/react/index.js +7 -1
  97. package/dist/react/index.js.map +1 -1
  98. package/dist/types.d.ts +2 -0
  99. package/dist/types.js.map +1 -1
  100. package/dist/util/geo.d.ts +8 -0
  101. package/dist/util/geo.js +8 -0
  102. package/dist/util/geo.js.map +1 -1
  103. package/dist/util/gltf.d.ts +18 -1
  104. package/dist/util/gltf.js +26 -1
  105. package/dist/util/gltf.js.map +1 -1
  106. package/dist/util/roofs.d.ts +8 -0
  107. package/dist/util/roofs.js +16 -2
  108. package/dist/util/roofs.js.map +1 -1
  109. package/dist/util/style-floats.d.ts +33 -0
  110. package/dist/util/style-floats.js +34 -0
  111. package/dist/util/style-floats.js.map +1 -0
  112. package/dist/util/sun.js +1 -1
  113. package/dist/util/sun.js.map +1 -1
  114. package/dist/workers/basemap/furniture.d.ts +13 -0
  115. package/dist/workers/basemap/geometry.d.ts +2 -5
  116. package/dist/workers/basemap/labels.d.ts +5 -2
  117. package/dist/workers/basemap/lamps.d.ts +3 -3
  118. package/dist/workers/basemap/tiles.d.ts +2 -0
  119. package/dist/workers/basemap/trees.d.ts +3 -0
  120. package/dist/workers/basemap.worker.d.ts +17 -1
  121. package/dist/workers/basemap.worker.js +12 -1
  122. package/dist/workers/basemap.worker.js.map +1 -1
  123. package/package.json +1 -1
@@ -1,13 +1,16 @@
1
- /** `<VectorGeometry>`: the fills and lines of a MapLibre style drawn as geometry (`vectorTiles().vectors()`), among the
2
- * layers of the components */
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** `<Geometry>`: the fills, lines and buildings of the vector tiles around drawn as geometry (`VectorTiles.vectors`),
3
+ * among the layers of the components; `<VectorGeometry>`, the same with tiles of its own */
3
4
  import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
4
- import { MapContext, SwipeContext } from "./context.js";
5
+ import { MapContext, SwipeContext, VectorTilesContext } from "./context.js";
6
+ import { VectorTiles } from "./VectorTiles.js";
5
7
  /** The paint properties of `next` that differ from those of `sent`, as `[layer, name, value]` */
6
8
  const changed = (sent, next) => Object.entries(next ?? {}).flatMap(([layer, properties]) => Object.entries(properties)
7
9
  .filter(([name, value]) => JSON.stringify(sent?.[layer]?.[name]) !== JSON.stringify(value))
8
10
  .map(([name, value]) => [layer, name, value]));
9
- const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, layers, streets, roofs, facades = false, paint, visible = true, order = 0, onLayer }, ref) {
11
+ const GeometryComponent = forwardRef(function Geometry({ layers, streets, roofs, facades = false, paint, visible = true, order = 0, onLayer }, ref) {
10
12
  const binding = useContext(MapContext);
13
+ const tiles = useContext(VectorTilesContext);
11
14
  const swipe = useContext(SwipeContext);
12
15
  const latest = useRef({ order, onLayer });
13
16
  /** The paint properties sent to the current layer */
@@ -15,12 +18,11 @@ const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, laye
15
18
  const [layer, setLayer] = useState();
16
19
  latest.current = { order, onLayer };
17
20
  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, the streets or the roofs change; the tiles (and their layer) destroyed when unmounted
21
+ // The geometry layer created once the tiles are there, in the declared order; made anew when the layers kept, the
22
+ // streets or the roofs change; removed when unmounted
20
23
  useEffect(() => {
21
- if (!binding)
24
+ if (!binding || !tiles)
22
25
  return;
23
- const tiles = binding.map.vectorTiles(style === undefined ? {} : { style });
24
26
  const created = tiles.vectors({
25
27
  ...(layers && { layers }),
26
28
  ...(streets && { streets }),
@@ -34,10 +36,12 @@ const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, laye
34
36
  return () => {
35
37
  binding.order.remove(created);
36
38
  swipe?.unset(created);
37
- tiles.destroy();
39
+ // Gone already with its tiles, or with the map
40
+ if (binding.map.hasLayer(created))
41
+ created.remove();
38
42
  setLayer(undefined);
39
43
  };
40
- }, [binding, swipe, style, layers, streets, roofs]);
44
+ }, [binding, swipe, tiles, layers, streets, roofs]);
41
45
  // The paint properties changed since the last ones sent (all of them to a layer made anew), those of a function
42
46
  // once the style is loaded; a later render or layer drops the wait
43
47
  useEffect(() => {
@@ -82,9 +86,19 @@ const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, laye
82
86
  return null;
83
87
  });
84
88
  /**
85
- * The fills and lines of a MapLibre style drawn as geometry on the globe and the relief (`vectorTiles().vectors()`):
86
- * sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again, picked by feature
87
- * (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`, `ready`)
89
+ * The fills, lines and buildings of the vector tiles around (`<VectorTiles>`) drawn as geometry on the globe and the
90
+ * relief (`VectorTiles.vectors`): sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again,
91
+ * picked by feature (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`,
92
+ * `ready`)
93
+ */
94
+ export const Geometry = GeometryComponent;
95
+ const VectorGeometryComponent = forwardRef(function VectorGeometry({ style, ...props }, ref) {
96
+ return (_jsx(VectorTiles, { ...(style === undefined ? {} : { style }), children: _jsx(GeometryComponent, { ref: ref, ...props }) }));
97
+ });
98
+ /**
99
+ * The fills and lines of a MapLibre style drawn as geometry, with tiles of its own: a `<Geometry>` in a
100
+ * `<VectorTiles>` of its `style`. Beside its trees, labels or lamps, a `<VectorTiles>` with each of them as children
101
+ * shares one set of tiles
88
102
  */
89
103
  export const VectorGeometry = VectorGeometryComponent;
90
104
  //# sourceMappingURL=VectorGeometry.js.map
@@ -1 +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;AAIf,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA+BxD,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,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC1F,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAA6B,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAC3E,CAAC;AAEJ,MAAM,uBAAuB,GAAG,UAAU,CACxC,SAAS,cAAc,CACrB,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,KAAK,GAAG,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AC,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,kCAAkC;IAClC,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAErB,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 type { RoofMode } from '../workers/basemap/geometry.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 /** The buildings' roofs (as `vectors({ roofs })`: `'data'` by default); another one makes the layer anew */\n roofs?: RoofMode;\n /** The buildings' walls show their windows (default false: `setFacades`, the tiles not cut again) */\n facades?: 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(\n { style, layers, streets, roofs, facades = false, paint, visible = true, order = 0, onLayer },\n ref,\n ) {\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, the streets or the roofs 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({\n ...(layers && { layers }),\n ...(streets && { streets }),\n ...(roofs && { roofs }),\n });\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, roofs]);\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 // The walls' windows shown or not\n useEffect(() => {\n layer?.setFacades(facades);\n }, [layer, facades]);\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"]}
1
+ {"version":3,"file":"VectorGeometry.js","sourceRoot":"","sources":["../../src/react/VectorGeometry.tsx"],"names":[],"mappings":";AAAA;4FAC4F;AAE5F,OAAO,EACL,UAAU,EAGV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAkChD,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,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KAC1F,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAA6B,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAC3E,CAAC;AAEJ,MAAM,iBAAiB,GAAG,UAAU,CAAsD,SAAS,QAAQ,CACzG,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,O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AW,OAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,YACrD,KAAC,iBAAiB,IAAC,GAAG,EAAE,GAAG,KAAM,KAAK,GAAI,GAC9B,CACf,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAoE,CAAC","sourcesContent":["/** `<Geometry>`: the fills, lines and buildings of the vector tiles around drawn as geometry (`VectorTiles.vectors`),\n * among the layers of the components; `<VectorGeometry>`, the same with tiles of its own */\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 type { RoofMode } from '../util/roofs.ts';\nimport { MapContext, SwipeContext, VectorTilesContext } from './context.ts';\nimport { VectorTiles } from './VectorTiles.tsx';\n\nexport interface GeometryProps {\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 /** The buildings' roofs (as `vectors({ roofs })`: `'data'` by default); another one makes the layer anew */\n roofs?: RoofMode;\n /** The buildings' walls show their windows (default false: `setFacades`, the tiles not cut again) */\n facades?: 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\nexport interface VectorGeometryProps extends GeometryProps {\n /** A style URL or object (default OpenFreeMap's Positron); another one makes the layer anew */\n style?: string | Style;\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 GeometryComponent = forwardRef<VectorLayer | undefined, Omit<GeometryProps, 'ref'>>(function Geometry(\n { layers, streets, roofs, facades = false, paint, visible = true, order = 0, onLayer },\n ref,\n) {\n const binding = useContext(MapContext);\n const tiles = useContext(VectorTilesContext);\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 geometry layer created once the tiles are there, in the declared order; made anew when the layers kept, the\n // streets or the roofs change; removed when unmounted\n useEffect(() => {\n if (!binding || !tiles) return;\n\n const created = tiles.vectors({\n ...(layers && { layers }),\n ...(streets && { streets }),\n ...(roofs && { roofs }),\n });\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 // Gone already with its tiles, or with the map\n if (binding.map.hasLayer(created)) created.remove();\n setLayer(undefined);\n };\n }, [binding, swipe, tiles, layers, streets, roofs]);\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 // The walls' windows shown or not\n useEffect(() => {\n layer?.setFacades(facades);\n }, [layer, facades]);\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 * The fills, lines and buildings of the vector tiles around (`<VectorTiles>`) drawn as geometry on the globe and the\n * relief (`VectorTiles.vectors`): sharp at any zoom and pitch, restyled by `paint` without cutting the tiles again,\n * picked by feature (`map.pickFeature`). The ref and `onLayer` give its handle (`VectorLayer`: `layers`, `featureAt`,\n * `ready`)\n */\nexport const Geometry = GeometryComponent as (props: GeometryProps) => ReactNode;\n\nconst VectorGeometryComponent = forwardRef<VectorLayer | undefined, Omit<VectorGeometryProps, 'ref'>>(\n function VectorGeometry({ style, ...props }, ref) {\n return (\n <VectorTiles {...(style === undefined ? {} : { style })}>\n <GeometryComponent ref={ref} {...props} />\n </VectorTiles>\n );\n },\n);\n\n/**\n * The fills and lines of a MapLibre style drawn as geometry, with tiles of its own: a `<Geometry>` in a\n * `<VectorTiles>` of its `style`. Beside its trees, labels or lamps, a `<VectorTiles>` with each of them as children\n * shares one set of tiles\n */\nexport const VectorGeometry = VectorGeometryComponent as (props: VectorGeometryProps) => ReactNode;\n"]}
@@ -0,0 +1,65 @@
1
+ /** `<VectorTiles>`: the vector tiles of a MapLibre style, the parts drawn from them as its children (`<Geometry>`,
2
+ * `<Trees>`, `<Lamps>`, `<Furniture>`, `<Labels>`) sharing its tiles and its workers */
3
+ import { type ReactNode, type Ref } from 'react';
4
+ import type { VectorExtrusionOptions } from '../basemap/vectortiles/extrusions.ts';
5
+ import type { FurnitureOptions } from '../basemap/vectortiles/furniture.ts';
6
+ import type { LabelsOptions } from '../basemap/vectortiles/labels.ts';
7
+ import type { LampsOptions } from '../basemap/vectortiles/lamps.ts';
8
+ import type { TreesOptions } from '../basemap/vectortiles/trees.ts';
9
+ import type { VectorTiles as VectorTilesHandle, VectorTilesOptions } from '../basemap/vectortiles.ts';
10
+ import type { ExtrusionLayer } from '../layers/extrusions.ts';
11
+ import type { ModelLayer } from '../layers/layers.ts';
12
+ import type { SymbolLayer } from '../layers/symbols.ts';
13
+ import type { LabelCandidate } from '../workers/basemap.worker.ts';
14
+ export interface VectorTilesProps extends VectorTilesOptions {
15
+ /** The vector tiles, once made and each time they are made anew (another style, other workers) */
16
+ onTiles?: (tiles: VectorTilesHandle) => void;
17
+ ref?: Ref<VectorTilesHandle | undefined>;
18
+ /** The parts drawn from its tiles: `<Geometry>`, `<Trees>`, `<Lamps>`, `<Furniture>`, `<Labels>`, or a component of
19
+ * your own using `useVectorTiles` */
20
+ children?: ReactNode;
21
+ }
22
+ /**
23
+ * The vector tiles of a MapLibre style (`map.vectorTiles`), its children drawing from them: the style's fills, lines
24
+ * and buildings as geometry (`<Geometry>`), its trees, street lamps, street furniture, labels. One set of tiles and
25
+ * workers for all of them: the tiles fetched and decoded once. Its options (`style`, `workers`…) compared by value: an
26
+ * inline object keeps the tiles, another style makes them anew. The ref and `onTiles` give its handle
27
+ * (`VectorTiles`).
28
+ *
29
+ * ```tsx
30
+ * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>
31
+ * <Geometry roofs="generated" />
32
+ * <Trees />
33
+ * <Labels />
34
+ * </VectorTiles>
35
+ * ```
36
+ */
37
+ export declare const VectorTiles: (props: VectorTilesProps) => ReactNode;
38
+ /** The vector tiles of the `<VectorTiles>` around, once made (undefined before): a part of your own drawn from them
39
+ * (`streetWind`, `raster`…) */
40
+ export declare const useVectorTiles: () => VectorTilesHandle | undefined;
41
+ /** What a part drawn from the vector tiles around takes besides its options */
42
+ interface PartHandle<L> {
43
+ /** The layer, once made and each time it is made anew */
44
+ onLayer?: (layer: L) => void;
45
+ }
46
+ /** The props of a part: its options (those of its `VectorTiles` method), its handle */
47
+ type PartProps<O, L> = O & PartHandle<L> & {
48
+ ref?: Ref<L | undefined>;
49
+ };
50
+ /** The trees of the vector tiles around on their woods, forests and grass, as 3D models (`VectorTiles.trees`: its
51
+ * options as props) */
52
+ export declare const Trees: (props: PartProps<TreesOptions, ModelLayer>) => ReactNode;
53
+ /** Street lamps along the streets of the vector tiles around, lit at night (`VectorTiles.lamps`) */
54
+ export declare const Lamps: (props: PartProps<LampsOptions, ModelLayer>) => ReactNode;
55
+ /** The street furniture of the vector tiles around: bus shelters, waste baskets, post boxes, fountains, bicycle racks,
56
+ * benches (`VectorTiles.furniture`) */
57
+ export declare const Furniture: (props: PartProps<FurnitureOptions, ModelLayer>) => ReactNode;
58
+ /** The labels of the vector tiles around (`VectorTiles.labels`): hidden by the buildings of a `<Geometry>` beside
59
+ * them */
60
+ export declare const Labels: (props: PartProps<LabelsOptions, SymbolLayer<LabelCandidate>>) => ReactNode;
61
+ /** The buildings of the vector tiles around as an extrusion layer, its style per feature (`VectorTiles.extrusions`:
62
+ * its options as props; functions compared by identity, so at the module's level or in a memo). The properties of
63
+ * its features named by `<Extrusions<Building> …>` */
64
+ export declare const Extrusions: <P = Record<string, unknown>>(props: PartProps<VectorExtrusionOptions<P>, ExtrusionLayer<P>>) => ReactNode;
65
+ export {};
@@ -0,0 +1,112 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** `<VectorTiles>`: the vector tiles of a MapLibre style, the parts drawn from them as its children (`<Geometry>`,
3
+ * `<Trees>`, `<Lamps>`, `<Furniture>`, `<Labels>`) sharing its tiles and its workers */
4
+ import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
5
+ import { MapContext, useStableOptions, VectorTilesContext } from "./context.js";
6
+ const VectorTilesComponent = forwardRef(function VectorTiles({ children, onTiles, ...options }, ref) {
7
+ const binding = useContext(MapContext);
8
+ const stable = useStableOptions(options);
9
+ const latest = useRef(onTiles);
10
+ const [tiles, setTiles] = useState();
11
+ latest.current = onTiles;
12
+ useImperativeHandle(ref, () => tiles, [tiles]);
13
+ // Made once the map is there, anew when its options change; destroyed with its parts when unmounted
14
+ useEffect(() => {
15
+ if (!binding)
16
+ return;
17
+ const made = binding.map.vectorTiles(stable);
18
+ setTiles(made);
19
+ latest.current?.(made);
20
+ return () => {
21
+ made.destroy();
22
+ setTiles(undefined);
23
+ };
24
+ }, [binding, stable]);
25
+ return _jsx(VectorTilesContext.Provider, { value: tiles, children: children });
26
+ });
27
+ /**
28
+ * The vector tiles of a MapLibre style (`map.vectorTiles`), its children drawing from them: the style's fills, lines
29
+ * and buildings as geometry (`<Geometry>`), its trees, street lamps, street furniture, labels. One set of tiles and
30
+ * workers for all of them: the tiles fetched and decoded once. Its options (`style`, `workers`…) compared by value: an
31
+ * inline object keeps the tiles, another style makes them anew. The ref and `onTiles` give its handle
32
+ * (`VectorTiles`).
33
+ *
34
+ * ```tsx
35
+ * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>
36
+ * <Geometry roofs="generated" />
37
+ * <Trees />
38
+ * <Labels />
39
+ * </VectorTiles>
40
+ * ```
41
+ */
42
+ export const VectorTiles = VectorTilesComponent;
43
+ /** The vector tiles of the `<VectorTiles>` around, once made (undefined before): a part of your own drawn from them
44
+ * (`streetWind`, `raster`…) */
45
+ export const useVectorTiles = () => useContext(VectorTilesContext);
46
+ /** A part drawn from the vector tiles around: made by `make` once they are there, anew when its options change
47
+ * (compared by value, `useStableOptions`), removed when unmounted */
48
+ const usePart = (make, props, ref) => {
49
+ const binding = useContext(MapContext);
50
+ const tiles = useContext(VectorTilesContext);
51
+ // Its options: its props but `onLayer` (a function written inline would make it anew at each render)
52
+ const stable = useStableOptions({ ...props, onLayer: undefined });
53
+ const latest = useRef(props.onLayer);
54
+ const [layer, setLayer] = useState();
55
+ latest.current = props.onLayer;
56
+ useImperativeHandle(ref, () => layer, [layer]);
57
+ useEffect(() => {
58
+ if (!binding || !tiles)
59
+ return;
60
+ const made = make(tiles, stable);
61
+ setLayer(made);
62
+ latest.current?.(made);
63
+ return () => {
64
+ // Gone already with its tiles, or with the map
65
+ if (binding.map.hasLayer(made))
66
+ made.remove();
67
+ setLayer(undefined);
68
+ };
69
+ }, [binding, tiles, stable, make]);
70
+ };
71
+ /** The parts' layers made from the vector tiles (at the module's level: the same functions from render to render) */
72
+ const makeTrees = (tiles, options) => tiles.trees(options);
73
+ const makeLamps = (tiles, options) => tiles.lamps(options);
74
+ const makeFurniture = (tiles, options) => tiles.furniture(options);
75
+ const makeLabels = (tiles, options) => tiles.labels(options);
76
+ const makeExtrusions = (tiles, options) => tiles.extrusions(options);
77
+ const TreesComponent = forwardRef(function Trees(props, ref) {
78
+ usePart(makeTrees, props, ref);
79
+ return null;
80
+ });
81
+ const LampsComponent = forwardRef(function Lamps(props, ref) {
82
+ usePart(makeLamps, props, ref);
83
+ return null;
84
+ });
85
+ const FurnitureComponent = forwardRef(function Furniture(props, ref) {
86
+ usePart(makeFurniture, props, ref);
87
+ return null;
88
+ });
89
+ const LabelsComponent = forwardRef(function Labels(props, ref) {
90
+ usePart(makeLabels, props, ref);
91
+ return null;
92
+ });
93
+ const ExtrusionsComponent = forwardRef(function Extrusions(props, ref) {
94
+ usePart(makeExtrusions, props, ref);
95
+ return null;
96
+ });
97
+ /** The trees of the vector tiles around on their woods, forests and grass, as 3D models (`VectorTiles.trees`: its
98
+ * options as props) */
99
+ export const Trees = TreesComponent;
100
+ /** Street lamps along the streets of the vector tiles around, lit at night (`VectorTiles.lamps`) */
101
+ export const Lamps = LampsComponent;
102
+ /** The street furniture of the vector tiles around: bus shelters, waste baskets, post boxes, fountains, bicycle racks,
103
+ * benches (`VectorTiles.furniture`) */
104
+ export const Furniture = FurnitureComponent;
105
+ /** The labels of the vector tiles around (`VectorTiles.labels`): hidden by the buildings of a `<Geometry>` beside
106
+ * them */
107
+ export const Labels = LabelsComponent;
108
+ /** The buildings of the vector tiles around as an extrusion layer, its style per feature (`VectorTiles.extrusions`:
109
+ * its options as props; functions compared by identity, so at the module's level or in a memo). The properties of
110
+ * its features named by `<Extrusions<Building> …>` */
111
+ export const Extrusions = ExtrusionsComponent;
112
+ //# sourceMappingURL=VectorTiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VectorTiles.js","sourceRoot":"","sources":["../../src/react/VectorTiles.tsx"],"names":[],"mappings":";AAAA;wFACwF;AAExF,OAAO,EAEL,UAAU,EAGV,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAWhF,MAAM,oBAAoB,GAAG,UAAU,CACrC,SAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,GAAG;IACzD,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAqB,CAAC;IAExD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/C,oGAAoG;IACpG,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,O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K,EAAE,GAAG,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,MAAM,cAAc,GAAG,UAAU,CAC/B,SAAS,KAAK,CAAC,KAAK,EAAE,GAAG;IACvB,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAE/B,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,MAAM,kBAAkB,GAAG,UAAU,CACnC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG;IAC3B,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAEnC,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,MAAM,eAAe,GAAG,UAAU,CAGhC,SAAS,MAAM,CAAC,KAAK,EAAE,GAAG;IAC1B,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAEhC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,UAAU,CAGpC,SAAS,UAAU,CAAC,KAAK,EAAE,GAAG;IAC9B,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAEpC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH;uBACuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAG,cAA2E,CAAC;AAEjG,oGAAoG;AACpG,MAAM,CAAC,MAAM,KAAK,GAAG,cAA2E,CAAC;AAEjG;uCACuC;AACvC,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAmF,CAAC;AAE7G;UACU;AACV,MAAM,CAAC,MAAM,MAAM,GAAG,eAA8F,CAAC;AAErH;;sDAEsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,mBAEZ,CAAC","sourcesContent":["/** `<VectorTiles>`: the vector tiles of a MapLibre style, the parts drawn from them as its children (`<Geometry>`,\n * `<Trees>`, `<Lamps>`, `<Furniture>`, `<Labels>`) sharing its tiles and its workers */\n\nimport {\n type ForwardedRef,\n forwardRef,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport type { VectorExtrusionOptions } from '../basemap/vectortiles/extrusions.ts';\nimport type { FurnitureOptions } from '../basemap/vectortiles/furniture.ts';\nimport type { LabelsOptions } from '../basemap/vectortiles/labels.ts';\nimport type { LampsOptions } from '../basemap/vectortiles/lamps.ts';\nimport type { TreesOptions } from '../basemap/vectortiles/trees.ts';\nimport type { VectorTiles as VectorTilesHandle, VectorTilesOptions } from '../basemap/vectortiles.ts';\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport type { Layer as LayerHandle, ModelLayer } from '../layers/layers.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { LabelCandidate } from '../workers/basemap.worker.ts';\nimport { MapContext, useStableOptions, VectorTilesContext } from './context.ts';\n\nexport interface VectorTilesProps extends VectorTilesOptions {\n /** The vector tiles, once made and each time they are made anew (another style, other workers) */\n onTiles?: (tiles: VectorTilesHandle) => void;\n ref?: Ref<VectorTilesHandle | undefined>;\n /** The parts drawn from its tiles: `<Geometry>`, `<Trees>`, `<Lamps>`, `<Furniture>`, `<Labels>`, or a component of\n * your own using `useVectorTiles` */\n children?: ReactNode;\n}\n\nconst VectorTilesComponent = forwardRef<VectorTilesHandle | undefined, Omit<VectorTilesProps, 'ref'>>(\n function VectorTiles({ children, onTiles, ...options }, ref) {\n const binding = useContext(MapContext);\n const stable = useStableOptions(options);\n const latest = useRef(onTiles);\n const [tiles, setTiles] = useState<VectorTilesHandle>();\n\n latest.current = onTiles;\n useImperativeHandle(ref, () => tiles, [tiles]);\n\n // Made once the map is there, anew when its options change; destroyed with its parts when unmounted\n useEffect(() => {\n if (!binding) return;\n\n const made = binding.map.vectorTiles(stable);\n\n setTiles(made);\n latest.current?.(made);\n\n return () => {\n made.destroy();\n setTiles(undefined);\n };\n }, [binding, stable]);\n\n return <VectorTilesContext.Provider value={tiles}>{children}</VectorTilesContext.Provider>;\n },\n);\n\n/**\n * The vector tiles of a MapLibre style (`map.vectorTiles`), its children drawing from them: the style's fills, lines\n * and buildings as geometry (`<Geometry>`), its trees, street lamps, street furniture, labels. One set of tiles and\n * workers for all of them: the tiles fetched and decoded once. Its options (`style`, `workers`…) compared by value: an\n * inline object keeps the tiles, another style makes them anew. The ref and `onTiles` give its handle\n * (`VectorTiles`).\n *\n * ```tsx\n * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>\n * <Geometry roofs=\"generated\" />\n * <Trees />\n * <Labels />\n * </VectorTiles>\n * ```\n */\nexport const VectorTiles = VectorTilesComponent as (props: VectorTilesProps) => ReactNode;\n\n/** The vector tiles of the `<VectorTiles>` around, once made (undefined before): a part of your own drawn from them\n * (`streetWind`, `raster`…) */\nexport const useVectorTiles = (): VectorTilesHandle | undefined => useContext(VectorTilesContext);\n\n/** What a part drawn from the vector tiles around takes besides its options */\ninterface PartHandle<L> {\n /** The layer, once made and each time it is made anew */\n onLayer?: (layer: L) => void;\n}\n\n/** The props of a part: its options (those of its `VectorTiles` method), its handle */\ntype PartProps<O, L> = O & PartHandle<L> & { ref?: Ref<L | undefined> };\n\n/** A part drawn from the vector tiles around: made by `make` once they are there, anew when its options change\n * (compared by value, `useStableOptions`), removed when unmounted */\nconst usePart = <O extends object, L extends LayerHandle>(\n make: (tiles: VectorTilesHandle, options: O) => L,\n props: O & PartHandle<L>,\n ref: ForwardedRef<L | undefined>,\n): void => {\n const binding = useContext(MapContext);\n const tiles = useContext(VectorTilesContext);\n // Its options: its props but `onLayer` (a function written inline would make it anew at each render)\n const stable = useStableOptions({ ...props, onLayer: undefined });\n const latest = useRef(props.onLayer);\n const [layer, setLayer] = useState<L>();\n\n latest.current = props.onLayer;\n useImperativeHandle(ref, () => layer, [layer]);\n useEffect(() => {\n if (!binding || !tiles) return;\n\n const made = make(tiles, stable);\n\n setLayer(made);\n latest.current?.(made);\n\n return () => {\n // Gone already with its tiles, or with the map\n if (binding.map.hasLayer(made)) made.remove();\n setLayer(undefined);\n };\n }, [binding, tiles, stable, make]);\n};\n\n/** The parts' layers made from the vector tiles (at the module's level: the same functions from render to render) */\nconst makeTrees = (tiles: VectorTilesHandle, options: TreesOptions) => tiles.trees(options);\nconst makeLamps = (tiles: VectorTilesHandle, options: LampsOptions) => tiles.lamps(options);\nconst makeFurniture = (tiles: VectorTilesHandle, options: FurnitureOptions) => tiles.furniture(options);\nconst makeLabels = (tiles: VectorTilesHandle, options: LabelsOptions) => tiles.labels(options);\nconst makeExtrusions = (tiles: VectorTilesHandle, options: VectorExtrusionOptions<Record<string, unknown>>) =>\n tiles.extrusions(options);\n\nconst TreesComponent = forwardRef<ModelLayer | undefined, TreesOptions & PartHandle<ModelLayer>>(\n function Trees(props, ref) {\n usePart(makeTrees, props, ref);\n\n return null;\n },\n);\n\nconst LampsComponent = forwardRef<ModelLayer | undefined, LampsOptions & PartHandle<ModelLayer>>(\n function Lamps(props, ref) {\n usePart(makeLamps, props, ref);\n\n return null;\n },\n);\n\nconst FurnitureComponent = forwardRef<ModelLayer | undefined, FurnitureOptions & PartHandle<ModelLayer>>(\n function Furniture(props, ref) {\n usePart(makeFurniture, props, ref);\n\n return null;\n },\n);\n\nconst LabelsComponent = forwardRef<\n SymbolLayer<LabelCandidate> | undefined,\n LabelsOptions & PartHandle<SymbolLayer<LabelCandidate>>\n>(function Labels(props, ref) {\n usePart(makeLabels, props, ref);\n\n return null;\n});\n\nconst ExtrusionsComponent = forwardRef<\n ExtrusionLayer<Record<string, unknown>> | undefined,\n VectorExtrusionOptions<Record<string, unknown>> & PartHandle<ExtrusionLayer<Record<string, unknown>>>\n>(function Extrusions(props, ref) {\n usePart(makeExtrusions, props, ref);\n\n return null;\n});\n\n/** The trees of the vector tiles around on their woods, forests and grass, as 3D models (`VectorTiles.trees`: its\n * options as props) */\nexport const Trees = TreesComponent as (props: PartProps<TreesOptions, ModelLayer>) => ReactNode;\n\n/** Street lamps along the streets of the vector tiles around, lit at night (`VectorTiles.lamps`) */\nexport const Lamps = LampsComponent as (props: PartProps<LampsOptions, ModelLayer>) => ReactNode;\n\n/** The street furniture of the vector tiles around: bus shelters, waste baskets, post boxes, fountains, bicycle racks,\n * benches (`VectorTiles.furniture`) */\nexport const Furniture = FurnitureComponent as (props: PartProps<FurnitureOptions, ModelLayer>) => ReactNode;\n\n/** The labels of the vector tiles around (`VectorTiles.labels`): hidden by the buildings of a `<Geometry>` beside\n * them */\nexport const Labels = LabelsComponent as (props: PartProps<LabelsOptions, SymbolLayer<LabelCandidate>>) => ReactNode;\n\n/** The buildings of the vector tiles around as an extrusion layer, its style per feature (`VectorTiles.extrusions`:\n * its options as props; functions compared by identity, so at the module's level or in a memo). The properties of\n * its features named by `<Extrusions<Building> …>` */\nexport const Extrusions = ExtrusionsComponent as <P = Record<string, unknown>>(\n props: PartProps<VectorExtrusionOptions<P>, ExtrusionLayer<P>>,\n) => ReactNode;\n"]}
@@ -1,5 +1,6 @@
1
1
  /** What the components of a map share: the map, the order of their layers, the viewsheds, the swipe and the marker
2
2
  * around; the hooks */
3
+ import type { VectorTiles } from '../basemap/vectortiles.ts';
3
4
  import type { LayerOrder } from '../bind/layers.ts';
4
5
  import type { Layer as LayerHandle } from '../layers/layers.ts';
5
6
  import type { GeoMap } from '../map.ts';
@@ -25,9 +26,17 @@ export declare const MarkerContext: import("react").Context<{
25
26
  marker: MarkerHandle;
26
27
  lonLat: LonLat;
27
28
  } | undefined>;
29
+ /** The vector tiles of the `<VectorTiles>` around, once the map is there */
30
+ export declare const VectorTilesContext: import("react").Context<VectorTiles | undefined>;
28
31
  /** The map of the `<IsardMap>` around, once created (undefined before) */
29
32
  export declare const useMap: () => GeoMap | undefined;
30
33
  /** Listens to an event of the map around while the component is mounted; the listener may change at each render */
31
34
  export declare const useMapEvent: <K extends keyof MapEvents>(type: K, listener: (event: MapEvents[K]) => void) => void;
32
35
  /** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */
33
36
  export declare const defined: <T extends object>(object: T) => { [K in keyof T]?: Exclude<T[K], undefined>; };
37
+ /** A key of options that changes when they do: plain data compared by value (an object written inline in the JSX
38
+ * keeps its key), functions, layers and binary data by identity */
39
+ export declare const propsKey: (options: object) => string;
40
+ /** The same options while their `propsKey` stays: an object written inline in the JSX, the same from render to render
41
+ * until a value in it changes */
42
+ export declare const useStableOptions: <T extends object>(options: T) => T;
@@ -5,6 +5,8 @@ export const MapContext = createContext(undefined);
5
5
  export const SwipeContext = createContext(undefined);
6
6
  /** The marker of a `<Marker>` around and its position (a `<Popup>` in it opens on its click, at that position) */
7
7
  export const MarkerContext = createContext(undefined);
8
+ /** The vector tiles of the `<VectorTiles>` around, once the map is there */
9
+ export const VectorTilesContext = createContext(undefined);
8
10
  /** The map of the `<IsardMap>` around, once created (undefined before) */
9
11
  export const useMap = () => useContext(MapContext)?.map;
10
12
  /** Listens to an event of the map around while the component is mounted; the listener may change at each render */
@@ -17,4 +19,34 @@ export const useMapEvent = (type, listener) => {
17
19
  };
18
20
  /** The entries of an object whose value is defined (`exactOptionalPropertyTypes`) */
19
21
  export const defined = (object) => Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));
22
+ /** Numbers standing for the values compared by identity in `propsKey`, the next one */
23
+ const identities = { of: new WeakMap(), next: 1 };
24
+ /** The number of a value compared by identity */
25
+ const identity = (value) => {
26
+ const known = identities.of.get(value);
27
+ if (known !== undefined)
28
+ return known;
29
+ identities.of.set(value, identities.next);
30
+ identities.next += 1;
31
+ return identities.next - 1;
32
+ };
33
+ /** A value compared by identity: a function, a class's instance (a layer), binary data */
34
+ const byIdentity = (value) => typeof value === 'function' ||
35
+ (typeof value === 'object' &&
36
+ value !== null &&
37
+ !Array.isArray(value) &&
38
+ Object.getPrototypeOf(value) !== Object.prototype &&
39
+ Object.getPrototypeOf(value) !== null);
40
+ /** A key of options that changes when they do: plain data compared by value (an object written inline in the JSX
41
+ * keeps its key), functions, layers and binary data by identity */
42
+ export const propsKey = (options) => JSON.stringify(options, (_, value) => (byIdentity(value) ? `#${identity(value)}` : value));
43
+ /** The same options while their `propsKey` stays: an object written inline in the JSX, the same from render to render
44
+ * until a value in it changes */
45
+ export const useStableOptions = (options) => {
46
+ const kept = useRef({ key: propsKey(options), options });
47
+ const key = propsKey(options);
48
+ if (kept.current.key !== key)
49
+ kept.current = { key, options };
50
+ return kept.current.options;
51
+ };
20
52
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;uBACuB;AAEvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAerE,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAsB,SAAS,CAAC,CAAC;AASxE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAyB,SAAS,CAAC,CAAC;AAE7E,kHAAkH;AAClH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAuD,SAAS,CAAC,CAAC;AAE5G,0EAA0E;AAC1E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAuB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC;AAE5E,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAA4B,IAAO,EAAE,QAAuC,EAAQ,EAAE;IAC/G,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,uGAAuG;IACvG,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAmB,MAAS,EAAiD,EAAE,CACpG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAEnF,CAAC","sourcesContent":["/** 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"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;uBACuB;AAEvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAgBrE,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAsB,SAAS,CAAC,CAAC;AASxE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAyB,SAAS,CAAC,CAAC;AAE7E,kHAAkH;AAClH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAuD,SAAS,CAAC,CAAC;AAE5G,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAA0B,SAAS,CAAC,CAAC;AAEpF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAuB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC;AAE5E,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAA4B,IAAO,EAAE,QAAuC,EAAQ,EAAE;IAC/G,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,uGAAuG;IACvG,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAA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,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAc,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEtG;iCACiC;AACjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAmB,OAAU,EAAK,EAAE;IAClE,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE9B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG;QAAE,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAE9D,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["/** 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 { VectorTiles } from '../basemap/vectortiles.ts';\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 vector tiles of the `<VectorTiles>` around, once the map is there */\nexport const VectorTilesContext = createContext<VectorTiles | 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\n/** Numbers standing for the values compared by identity in `propsKey`, the next one */\nconst identities = { of: new WeakMap<object, number>(), next: 1 };\n\n/** The number of a value compared by identity */\nconst identity = (value: object): number => {\n const known = identities.of.get(value);\n\n if (known !== undefined) return known;\n identities.of.set(value, identities.next);\n identities.next += 1;\n\n return identities.next - 1;\n};\n\n/** A value compared by identity: a function, a class's instance (a layer), binary data */\nconst byIdentity = (value: unknown): value is object =>\n typeof value === 'function' ||\n (typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null);\n\n/** A key of options that changes when they do: plain data compared by value (an object written inline in the JSX\n * keeps its key), functions, layers and binary data by identity */\nexport const propsKey = (options: object): string =>\n JSON.stringify(options, (_, value: unknown) => (byIdentity(value) ? `#${identity(value)}` : value));\n\n/** The same options while their `propsKey` stays: an object written inline in the JSX, the same from render to render\n * until a value in it changes */\nexport const useStableOptions = <T extends object>(options: T): T => {\n const kept = useRef({ key: propsKey(options), options });\n const key = propsKey(options);\n\n if (kept.current.key !== key) kept.current = { key, options };\n\n return kept.current.options;\n};\n"]}
@@ -4,6 +4,11 @@
4
4
  *
5
5
  * ```tsx
6
6
  * <IsardMap preset="ign-3d" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>
7
+ * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>
8
+ * <Geometry roofs="generated" />
9
+ * <Trees />
10
+ * <Labels />
11
+ * </VectorTiles>
7
12
  * <Layer type="lines" data={routes} color="#0057b8" width={3} />
8
13
  * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>
9
14
  * </IsardMap>
@@ -23,5 +28,6 @@ export { Marker, type MarkerProps } from './Marker.tsx';
23
28
  export { Panel, type PanelProps } from './Panel.tsx';
24
29
  export { Popup, type PopupProps } from './Popup.tsx';
25
30
  export { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';
26
- export { VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';
31
+ export { Geometry, type GeometryProps, VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';
32
+ export { Extrusions, Furniture, Labels, Lamps, Trees, useVectorTiles, VectorTiles, type VectorTilesProps, } from './VectorTiles.tsx';
27
33
  export { Viewshed } from './Viewshed.tsx';
@@ -4,6 +4,11 @@
4
4
  *
5
5
  * ```tsx
6
6
  * <IsardMap preset="ign-3d" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>
7
+ * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>
8
+ * <Geometry roofs="generated" />
9
+ * <Trees />
10
+ * <Labels />
11
+ * </VectorTiles>
7
12
  * <Layer type="lines" data={routes} color="#0057b8" width={3} />
8
13
  * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>
9
14
  * </IsardMap>
@@ -18,6 +23,7 @@ export { Marker } from "./Marker.js";
18
23
  export { Panel } from "./Panel.js";
19
24
  export { Popup } from "./Popup.js";
20
25
  export { Swipe, SwipeOther } from "./Swipe.js";
21
- export { VectorGeometry } from "./VectorGeometry.js";
26
+ export { Geometry, VectorGeometry } from "./VectorGeometry.js";
27
+ export { Extrusions, Furniture, Labels, Lamps, Trees, useVectorTiles, VectorTiles, } from "./VectorTiles.js";
22
28
  export { Viewshed } from "./Viewshed.js";
23
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAmB,MAAM,YAAa,CAAC;AACjE,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAsB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard.js';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';\nexport { VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAmB,MAAM,YAAa,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAsB,cAAc,EAA4B,MAAM,qBAAsB,CAAC;AAC9G,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,KAAK,EACL,KAAK,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,kBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>\n * <Geometry roofs=\"generated\" />\n * <Trees />\n * <Labels />\n * </VectorTiles>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard.js';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';\nexport { Geometry, type GeometryProps, VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';\nexport {\n Extrusions,\n Furniture,\n Labels,\n Lamps,\n Trees,\n useVectorTiles,\n VectorTiles,\n type VectorTilesProps,\n} from './VectorTiles.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
package/dist/types.d.ts CHANGED
@@ -410,4 +410,6 @@ export interface LayerHost {
410
410
  replaceLayer(layer: Layer, old: number): void;
411
411
  /** Resolves once the map is idle (everything in view loaded and drawn) */
412
412
  whenIdle(): Promise<void>;
413
+ /** Work the map waits on before it is idle (`GeoMap.track`) */
414
+ track<T>(work: Promise<T>): Promise<T>;
413
415
  }