@performant-software/geospatial 2.2.21-beta.2 → 2.2.21-beta.20

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 (235) hide show
  1. package/build/index.js +2 -0
  2. package/build/index.js.map +1 -0
  3. package/build/main.css +127 -0
  4. package/dist/index.cjs14.js +1 -1
  5. package/dist/index.cjs15.js +1 -1
  6. package/dist/index.cjs16.js +1 -1
  7. package/dist/index.cjs17.js +1 -1
  8. package/dist/index.cjs182.js +1 -1
  9. package/dist/index.cjs182.js.map +1 -1
  10. package/dist/index.cjs183.js +1 -1
  11. package/dist/index.cjs183.js.map +1 -1
  12. package/dist/index.cjs184.js +4 -1
  13. package/dist/index.cjs184.js.map +1 -1
  14. package/dist/index.cjs185.js +1 -1
  15. package/dist/index.cjs185.js.map +1 -1
  16. package/dist/index.cjs186.js +1 -1
  17. package/dist/index.cjs186.js.map +1 -1
  18. package/dist/index.cjs187.js +1 -1
  19. package/dist/index.cjs187.js.map +1 -1
  20. package/dist/index.cjs188.js +1 -1
  21. package/dist/index.cjs188.js.map +1 -1
  22. package/dist/index.cjs189.js +1 -1
  23. package/dist/index.cjs189.js.map +1 -1
  24. package/dist/index.cjs19.js +1 -1
  25. package/dist/index.cjs190.js +1 -1
  26. package/dist/index.cjs190.js.map +1 -1
  27. package/dist/index.cjs191.js +1 -1
  28. package/dist/index.cjs191.js.map +1 -1
  29. package/dist/index.cjs192.js +1 -4
  30. package/dist/index.cjs192.js.map +1 -1
  31. package/dist/index.cjs193.js +1 -1
  32. package/dist/index.cjs193.js.map +1 -1
  33. package/dist/index.cjs194.js +1 -1
  34. package/dist/index.cjs194.js.map +1 -1
  35. package/dist/index.cjs195.js +1 -1
  36. package/dist/index.cjs195.js.map +1 -1
  37. package/dist/index.cjs196.js +1 -1
  38. package/dist/index.cjs196.js.map +1 -1
  39. package/dist/index.cjs197.js +1 -1
  40. package/dist/index.cjs197.js.map +1 -1
  41. package/dist/index.cjs198.js +1 -1
  42. package/dist/index.cjs198.js.map +1 -1
  43. package/dist/index.cjs199.js +1 -1
  44. package/dist/index.cjs199.js.map +1 -1
  45. package/dist/index.cjs20.js +1 -1
  46. package/dist/index.cjs200.js +1 -1
  47. package/dist/index.cjs200.js.map +1 -1
  48. package/dist/index.cjs201.js +1 -1
  49. package/dist/index.cjs201.js.map +1 -1
  50. package/dist/index.cjs202.js +1 -1
  51. package/dist/index.cjs202.js.map +1 -1
  52. package/dist/index.cjs203.js +1 -1
  53. package/dist/index.cjs203.js.map +1 -1
  54. package/dist/index.cjs204.js +1 -1
  55. package/dist/index.cjs204.js.map +1 -1
  56. package/dist/index.cjs208.js +1 -1
  57. package/dist/index.cjs209.js +1 -1
  58. package/dist/index.cjs21.js +1 -1
  59. package/dist/index.cjs232.js +1 -1
  60. package/dist/index.cjs234.js +1 -1
  61. package/dist/index.cjs234.js.map +1 -1
  62. package/dist/index.cjs235.js +1 -1
  63. package/dist/index.cjs235.js.map +1 -1
  64. package/dist/index.cjs238.js +1 -1
  65. package/dist/index.cjs241.js +1 -1
  66. package/dist/index.cjs247.js +1 -1
  67. package/dist/index.cjs25.js +1 -1
  68. package/dist/index.cjs253.js +1 -1
  69. package/dist/index.cjs258.js +1 -1
  70. package/dist/index.cjs51.js +1 -1
  71. package/dist/index.cjs55.js +1 -1
  72. package/dist/index.cjs57.js +1 -1
  73. package/dist/index.cjs58.js +1 -1
  74. package/dist/index.cjs59.js +1 -9
  75. package/dist/index.cjs59.js.map +1 -1
  76. package/dist/index.cjs60.js +1 -19
  77. package/dist/index.cjs60.js.map +1 -1
  78. package/dist/index.cjs61.js +1 -1
  79. package/dist/index.cjs62.js +9 -1
  80. package/dist/index.cjs62.js.map +1 -1
  81. package/dist/index.cjs63.js +19 -1
  82. package/dist/index.cjs63.js.map +1 -1
  83. package/dist/index.cjs64.js +1 -1
  84. package/dist/index.cjs64.js.map +1 -1
  85. package/dist/index.cjs65.js +1 -1
  86. package/dist/index.cjs65.js.map +1 -1
  87. package/dist/index.cjs66.js +1 -1
  88. package/dist/index.cjs66.js.map +1 -1
  89. package/dist/index.cjs67.js +1 -1
  90. package/dist/index.cjs67.js.map +1 -1
  91. package/dist/index.cjs68.js +1 -1
  92. package/dist/index.cjs68.js.map +1 -1
  93. package/dist/index.cjs69.js +1 -1
  94. package/dist/index.cjs69.js.map +1 -1
  95. package/dist/index.cjs70.js +1 -1
  96. package/dist/index.cjs70.js.map +1 -1
  97. package/dist/index.cjs71.js +1 -1
  98. package/dist/index.cjs71.js.map +1 -1
  99. package/dist/index.cjs72.js +1 -1
  100. package/dist/index.cjs72.js.map +1 -1
  101. package/dist/index.cjs73.js +1 -1
  102. package/dist/index.cjs73.js.map +1 -1
  103. package/dist/index.cjs74.js +1 -1
  104. package/dist/index.cjs74.js.map +1 -1
  105. package/dist/index.cjs75.js +1 -1
  106. package/dist/index.cjs75.js.map +1 -1
  107. package/dist/index.cjs76.js +1 -1
  108. package/dist/index.cjs76.js.map +1 -1
  109. package/dist/index.cjs77.js +1 -1
  110. package/dist/index.cjs77.js.map +1 -1
  111. package/dist/index.cjs78.js +1 -1
  112. package/dist/index.cjs78.js.map +1 -1
  113. package/dist/index.cjs79.js +1 -1
  114. package/dist/index.cjs79.js.map +1 -1
  115. package/dist/index.cjs8.js +1 -1
  116. package/dist/index.cjs8.js.map +1 -1
  117. package/dist/index.es14.js +2 -2
  118. package/dist/index.es15.js +8 -8
  119. package/dist/index.es16.js +1 -1
  120. package/dist/index.es17.js +3 -3
  121. package/dist/index.es182.js +7 -320
  122. package/dist/index.es182.js.map +1 -1
  123. package/dist/index.es183.js +144 -71
  124. package/dist/index.es183.js.map +1 -1
  125. package/dist/index.es184.js +12197 -3
  126. package/dist/index.es184.js.map +1 -1
  127. package/dist/index.es185.js +3 -18
  128. package/dist/index.es185.js.map +1 -1
  129. package/dist/index.es186.js +3 -13
  130. package/dist/index.es186.js.map +1 -1
  131. package/dist/index.es187.js +33 -28
  132. package/dist/index.es187.js.map +1 -1
  133. package/dist/index.es188.js +3 -7
  134. package/dist/index.es188.js.map +1 -1
  135. package/dist/index.es189.js +23 -2
  136. package/dist/index.es189.js.map +1 -1
  137. package/dist/index.es19.js +2 -2
  138. package/dist/index.es190.js +2 -10
  139. package/dist/index.es190.js.map +1 -1
  140. package/dist/index.es191.js +3 -150
  141. package/dist/index.es191.js.map +1 -1
  142. package/dist/index.es192.js +2 -12199
  143. package/dist/index.es192.js.map +1 -1
  144. package/dist/index.es193.js +34 -3
  145. package/dist/index.es193.js.map +1 -1
  146. package/dist/index.es194.js +14 -2
  147. package/dist/index.es194.js.map +1 -1
  148. package/dist/index.es195.js +13 -35
  149. package/dist/index.es195.js.map +1 -1
  150. package/dist/index.es196.js +11 -3
  151. package/dist/index.es196.js.map +1 -1
  152. package/dist/index.es197.js +319 -21
  153. package/dist/index.es197.js.map +1 -1
  154. package/dist/index.es198.js +77 -2
  155. package/dist/index.es198.js.map +1 -1
  156. package/dist/index.es199.js +5 -3
  157. package/dist/index.es199.js.map +1 -1
  158. package/dist/index.es20.js +2 -2
  159. package/dist/index.es200.js +18 -2
  160. package/dist/index.es200.js.map +1 -1
  161. package/dist/index.es201.js +10 -31
  162. package/dist/index.es201.js.map +1 -1
  163. package/dist/index.es202.js +31 -13
  164. package/dist/index.es202.js.map +1 -1
  165. package/dist/index.es203.js +4 -13
  166. package/dist/index.es203.js.map +1 -1
  167. package/dist/index.es204.js +2 -9
  168. package/dist/index.es204.js.map +1 -1
  169. package/dist/index.es208.js +1 -1
  170. package/dist/index.es209.js +1 -1
  171. package/dist/index.es21.js +2 -2
  172. package/dist/index.es232.js +1 -1
  173. package/dist/index.es234.js +3 -6
  174. package/dist/index.es234.js.map +1 -1
  175. package/dist/index.es235.js +6 -3
  176. package/dist/index.es235.js.map +1 -1
  177. package/dist/index.es238.js +1 -1
  178. package/dist/index.es241.js +1 -1
  179. package/dist/index.es247.js +2 -2
  180. package/dist/index.es25.js +1 -1
  181. package/dist/index.es253.js +1 -1
  182. package/dist/index.es258.js +2 -2
  183. package/dist/index.es51.js +5 -5
  184. package/dist/index.es55.js +1 -1
  185. package/dist/index.es57.js +12 -12
  186. package/dist/index.es58.js +6 -2
  187. package/dist/index.es58.js.map +1 -1
  188. package/dist/index.es59.js +2 -30
  189. package/dist/index.es59.js.map +1 -1
  190. package/dist/index.es60.js +2 -602
  191. package/dist/index.es60.js.map +1 -1
  192. package/dist/index.es61.js +2 -6
  193. package/dist/index.es61.js.map +1 -1
  194. package/dist/index.es62.js +30 -2
  195. package/dist/index.es62.js.map +1 -1
  196. package/dist/index.es63.js +601 -106
  197. package/dist/index.es63.js.map +1 -1
  198. package/dist/index.es64.js +107 -10
  199. package/dist/index.es64.js.map +1 -1
  200. package/dist/index.es65.js +10 -2
  201. package/dist/index.es65.js.map +1 -1
  202. package/dist/index.es66.js +28 -2
  203. package/dist/index.es66.js.map +1 -1
  204. package/dist/index.es67.js +55 -2
  205. package/dist/index.es67.js.map +1 -1
  206. package/dist/index.es68.js +47 -56
  207. package/dist/index.es68.js.map +1 -1
  208. package/dist/index.es69.js +37 -46
  209. package/dist/index.es69.js.map +1 -1
  210. package/dist/index.es70.js +11 -38
  211. package/dist/index.es70.js.map +1 -1
  212. package/dist/index.es71.js +13 -10
  213. package/dist/index.es71.js.map +1 -1
  214. package/dist/index.es72.js +29 -14
  215. package/dist/index.es72.js.map +1 -1
  216. package/dist/index.es73.js +14 -29
  217. package/dist/index.es73.js.map +1 -1
  218. package/dist/index.es74.js +12 -13
  219. package/dist/index.es74.js.map +1 -1
  220. package/dist/index.es75.js +52 -13
  221. package/dist/index.es75.js.map +1 -1
  222. package/dist/index.es76.js +64 -10
  223. package/dist/index.es76.js.map +1 -1
  224. package/dist/index.es77.js +10 -27
  225. package/dist/index.es77.js.map +1 -1
  226. package/dist/index.es78.js +2 -51
  227. package/dist/index.es78.js.map +1 -1
  228. package/dist/index.es79.js +2 -65
  229. package/dist/index.es79.js.map +1 -1
  230. package/dist/index.es8.js +36 -35
  231. package/dist/index.es8.js.map +1 -1
  232. package/package.json +2 -2
  233. package/src/components/MapDraw.js +6 -3
  234. package/types/components/LocationMarker.js.flow +82 -0
  235. package/types/components/MapDraw.js.flow +6 -3
@@ -1,14 +1,68 @@
1
- import * as e from "react";
2
- import { useContext as n, useMemo as a } from "react";
3
- import { MapContext as u } from "./index.es68.js";
4
- const p = e.createContext(null);
5
- function c() {
6
- var o;
7
- const r = (o = n(p)) === null || o === void 0 ? void 0 : o.maps, t = n(u);
8
- return a(() => ({ ...r, current: t == null ? void 0 : t.map }), [r, t]);
1
+ import * as u from "react";
2
+ import { useContext as f, useRef as y, useState as m, useMemo as g, useEffect as S, cloneElement as h } from "react";
3
+ import { MapContext as C } from "./index.es67.js";
4
+ import s from "./index.es203.js";
5
+ import { deepEqual as v } from "./index.es202.js";
6
+ let x = 0;
7
+ function U(t, e, a) {
8
+ if (t.style && t.style._loaded) {
9
+ const n = { ...a };
10
+ return delete n.id, delete n.children, t.addSource(e, n), t.getSource(e);
11
+ }
12
+ return null;
13
+ }
14
+ function b(t, e, a) {
15
+ s(e.id === a.id, "source id changed"), s(e.type === a.type, "source type changed");
16
+ let n = "", r = 0;
17
+ for (const o in e)
18
+ o !== "children" && o !== "id" && !v(a[o], e[o]) && (n = o, r++);
19
+ if (!r)
20
+ return;
21
+ const l = e.type;
22
+ if (l === "geojson")
23
+ t.setData(e.data);
24
+ else if (l === "image")
25
+ t.updateImage({
26
+ url: e.url,
27
+ coordinates: e.coordinates
28
+ });
29
+ else if ("setCoordinates" in t && r === 1 && n === "coordinates")
30
+ t.setCoordinates(e.coordinates);
31
+ else if ("setUrl" in t)
32
+ switch (n) {
33
+ case "url":
34
+ t.setUrl(e.url);
35
+ break;
36
+ case "tiles":
37
+ t.setTiles(e.tiles);
38
+ break;
39
+ }
40
+ else
41
+ console.warn(`Unable to update <Source> prop: ${n}`);
42
+ }
43
+ function R(t) {
44
+ const e = f(C).map.getMap(), a = y(t), [, n] = m(0), r = g(() => t.id || `jsx-source-${x++}`, []);
45
+ S(() => {
46
+ if (e) {
47
+ const o = () => setTimeout(() => n((i) => i + 1), 0);
48
+ return e.on("styledata", o), o(), () => {
49
+ var i;
50
+ if (e.off("styledata", o), e.style && e.style._loaded && e.getSource(r)) {
51
+ const c = (i = e.getStyle()) === null || i === void 0 ? void 0 : i.layers;
52
+ if (c)
53
+ for (const d of c)
54
+ d.source === r && e.removeLayer(d.id);
55
+ e.removeSource(r);
56
+ }
57
+ };
58
+ }
59
+ }, [e]);
60
+ let l = e && e.style && e.getSource(r);
61
+ return l ? b(l, t, a.current) : l = U(e, r, t), a.current = t, l && u.Children.map(t.children, (o) => o && h(o, {
62
+ source: r
63
+ })) || null;
9
64
  }
10
65
  export {
11
- p as MountedMapsContext,
12
- c as useMap
66
+ R as default
13
67
  };
14
68
  //# sourceMappingURL=index.es76.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es76.js","sources":["../../../node_modules/react-map-gl/dist/esm/components/use-map.js"],"sourcesContent":["import * as React from 'react';\nimport { useState, useCallback, useMemo, useContext } from 'react';\nimport { MapContext } from './map';\nexport const MountedMapsContext = React.createContext(null);\nexport const MapProvider = props => {\n const [maps, setMaps] = useState({});\n const onMapMount = useCallback((map, id = 'default') => {\n setMaps(currMaps => {\n if (id === 'current') {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return { ...currMaps, [id]: map };\n });\n }, []);\n const onMapUnmount = useCallback((id = 'default') => {\n setMaps(currMaps => {\n if (currMaps[id]) {\n const nextMaps = { ...currMaps };\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n return (React.createElement(MountedMapsContext.Provider, { value: {\n maps,\n onMapMount,\n onMapUnmount\n } }, props.children));\n};\nexport function useMap() {\n var _a;\n const maps = (_a = useContext(MountedMapsContext)) === null || _a === void 0 ? void 0 : _a.maps;\n const currentMap = useContext(MapContext);\n const mapsWithCurrent = useMemo(() => {\n return { ...maps, current: currentMap === null || currentMap === void 0 ? void 0 : currentMap.map };\n }, [maps, currentMap]);\n return mapsWithCurrent;\n}\n//# sourceMappingURL=use-map.js.map"],"names":["MountedMapsContext","React","useMap","_a","maps","useContext","currentMap","MapContext","useMemo"],"mappings":";;;AAGa,MAAAA,IAAqBC,EAAM,cAAc,IAAI;AA8BnD,SAASC,IAAS;AACjB,MAAAC;AACE,QAAAC,KAAQD,IAAKE,EAAWL,CAAkB,OAAO,QAAQG,MAAO,SAAS,SAASA,EAAG,MACrFG,IAAaD,EAAWE,CAAU;AAIjC,SAHiBC,EAAQ,OACrB,EAAE,GAAGJ,GAAM,SAASE,KAAe,OAAgC,SAASA,EAAW,IAAI,IACnG,CAACF,GAAME,CAAU,CAAC;AAEzB;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es76.js","sources":["../../../node_modules/react-map-gl/dist/esm/components/source.js"],"sourcesContent":["import * as React from 'react';\nimport { useContext, useEffect, useMemo, useState, useRef } from 'react';\nimport { cloneElement } from 'react';\nimport { MapContext } from './map';\nimport assert from '../utils/assert';\nimport { deepEqual } from '../utils/deep-equal';\nlet sourceCounter = 0;\nfunction createSource(map, id, props) {\n // @ts-ignore\n if (map.style && map.style._loaded) {\n const options = { ...props };\n delete options.id;\n delete options.children;\n // @ts-ignore\n map.addSource(id, options);\n return map.getSource(id);\n }\n return null;\n}\n/* eslint-disable complexity */\nfunction updateSource(source, props, prevProps) {\n assert(props.id === prevProps.id, 'source id changed');\n assert(props.type === prevProps.type, 'source type changed');\n let changedKey = '';\n let changedKeyCount = 0;\n for (const key in props) {\n if (key !== 'children' && key !== 'id' && !deepEqual(prevProps[key], props[key])) {\n changedKey = key;\n changedKeyCount++;\n }\n }\n if (!changedKeyCount) {\n return;\n }\n const type = props.type;\n if (type === 'geojson') {\n source.setData(props.data);\n }\n else if (type === 'image') {\n source.updateImage({\n url: props.url,\n coordinates: props.coordinates\n });\n }\n else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') {\n source.setCoordinates(props.coordinates);\n }\n else if ('setUrl' in source) {\n // Added in 1.12.0:\n // vectorTileSource.setTiles\n // vectorTileSource.setUrl\n switch (changedKey) {\n case 'url':\n source.setUrl(props.url);\n break;\n case 'tiles':\n source.setTiles(props.tiles);\n break;\n default:\n }\n }\n else {\n // eslint-disable-next-line\n console.warn(`Unable to update <Source> prop: ${changedKey}`);\n }\n}\n/* eslint-enable complexity */\nfunction Source(props) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n const id = useMemo(() => props.id || `jsx-source-${sourceCounter++}`, []);\n useEffect(() => {\n if (map) {\n /* global setTimeout */\n const forceUpdate = () => setTimeout(() => setStyleLoaded(version => version + 1), 0);\n map.on('styledata', forceUpdate);\n forceUpdate();\n return () => {\n var _a;\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getSource(id)) {\n // Parent effects are destroyed before child ones, see\n // https://github.com/facebook/react/issues/16728\n // Source can only be removed after all child layers are removed\n const allLayers = (_a = map.getStyle()) === null || _a === void 0 ? void 0 : _a.layers;\n if (allLayers) {\n for (const layer of allLayers) {\n // @ts-ignore (2339) source does not exist on all layer types\n if (layer.source === id) {\n map.removeLayer(layer.id);\n }\n }\n }\n map.removeSource(id);\n }\n };\n }\n return undefined;\n }, [map]);\n // @ts-ignore\n let source = map && map.style && map.getSource(id);\n if (source) {\n updateSource(source, props, propsRef.current);\n }\n else {\n source = createSource(map, id, props);\n }\n propsRef.current = props;\n return ((source &&\n React.Children.map(props.children, child => child &&\n cloneElement(child, {\n source: id\n }))) ||\n null);\n}\nexport default Source;\n//# sourceMappingURL=source.js.map"],"names":["sourceCounter","createSource","map","id","props","options","updateSource","source","prevProps","assert","changedKey","changedKeyCount","key","deepEqual","type","Source","useContext","MapContext","propsRef","useRef","setStyleLoaded","useState","useMemo","useEffect","forceUpdate","version","_a","allLayers","layer","React","child","cloneElement"],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ACvB,GAAGgB,CAAc,IAAIC,EAAS,CAAC,GAC/BlB,IAAKmB,EAAQ,MAAMlB,EAAM,MAAM,cAAcJ,GAAe,IAAI,CAAA,CAAE;AACxE,EAAAuB,EAAU,MAAM;AACZ,QAAIrB,GAAK;AAEC,YAAAsB,IAAc,MAAM,WAAW,MAAMJ,EAAe,CAAWK,MAAAA,IAAU,CAAC,GAAG,CAAC;AAChF,aAAAvB,EAAA,GAAG,aAAasB,CAAW,GACnBA,KACL,MAAM;AACL,YAAAE;AAGA,YAFAxB,EAAA,IAAI,aAAasB,CAAW,GAE5BtB,EAAI,SAASA,EAAI,MAAM,WAAWA,EAAI,UAAUC,CAAE,GAAG;AAI/C,gBAAAwB,KAAaD,IAAKxB,EAAI,SAAA,OAAgB,QAAQwB,MAAO,SAAS,SAASA,EAAG;AAChF,cAAIC;AACA,uBAAWC,KAASD;AAEZ,cAAAC,EAAM,WAAWzB,KACbD,EAAA,YAAY0B,EAAM,EAAE;AAIpC,UAAA1B,EAAI,aAAaC,CAAE;AAAA,QACvB;AAAA,MAAA;AAAA,IAER;AAAA,EACO,GACR,CAACD,CAAG,CAAC;AAER,MAAIK,IAASL,KAAOA,EAAI,SAASA,EAAI,UAAUC,CAAE;AACjD,SAAII,IACaD,EAAAC,GAAQH,GAAOc,EAAS,OAAO,IAGnCX,IAAAN,EAAaC,GAAKC,GAAIC,CAAK,GAExCc,EAAS,UAAUd,GACVG,KACLsB,EAAM,SAAS,IAAIzB,EAAM,UAAU,CAAA0B,MAASA,KACxCC,EAAaD,GAAO;AAAA,IAChB,QAAQ3B;AAAA,EAAA,CACX,CAAC,KACN;AACR;","x_google_ignoreList":[0]}
@@ -1,31 +1,14 @@
1
- import { __exports as a } from "./index.es189.js";
2
- function i(r, s) {
3
- for (var o = 0; o < s.length; o++) {
4
- const e = s[o];
5
- if (typeof e != "string" && !Array.isArray(e)) {
6
- for (const t in e)
7
- if (t !== "default" && !(t in r)) {
8
- const n = Object.getOwnPropertyDescriptor(e, t);
9
- n && Object.defineProperty(r, t, n.get ? n : {
10
- enumerable: !0,
11
- get: () => e[t]
12
- });
13
- }
14
- }
15
- }
16
- return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
1
+ import * as e from "react";
2
+ import { useContext as n, useMemo as a } from "react";
3
+ import { MapContext as u } from "./index.es67.js";
4
+ const p = e.createContext(null);
5
+ function c() {
6
+ var o;
7
+ const r = (o = n(p)) === null || o === void 0 ? void 0 : o.maps, t = n(u);
8
+ return a(() => ({ ...r, current: t == null ? void 0 : t.map }), [r, t]);
17
9
  }
18
- var f = a.printMsg = function() {
19
- console.log("This is a message from the demo package");
20
- };
21
- const p = /* @__PURE__ */ i({
22
- __proto__: null,
23
- default: a,
24
- printMsg: f
25
- }, [a]);
26
10
  export {
27
- a as default,
28
- p as i,
29
- f as printMsg
11
+ p as MountedMapsContext,
12
+ c as useMap
30
13
  };
31
14
  //# sourceMappingURL=index.es77.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es77.js","sources":["../../../node_modules/mapbox-gl/index.js"],"sourcesContent":["exports.printMsg = function() {\r\n console.log(\"This is a message from the demo package\");\r\n }"],"names":["printMsg","mapboxGl"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAAC,EAAA,WAAmB,WAAW;AAC1B,UAAQ,IAAI,yCAAyC;AACvD;;;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es77.js","sources":["../../../node_modules/react-map-gl/dist/esm/components/use-map.js"],"sourcesContent":["import * as React from 'react';\nimport { useState, useCallback, useMemo, useContext } from 'react';\nimport { MapContext } from './map';\nexport const MountedMapsContext = React.createContext(null);\nexport const MapProvider = props => {\n const [maps, setMaps] = useState({});\n const onMapMount = useCallback((map, id = 'default') => {\n setMaps(currMaps => {\n if (id === 'current') {\n throw new Error(\"'current' cannot be used as map id\");\n }\n if (currMaps[id]) {\n throw new Error(`Multiple maps with the same id: ${id}`);\n }\n return { ...currMaps, [id]: map };\n });\n }, []);\n const onMapUnmount = useCallback((id = 'default') => {\n setMaps(currMaps => {\n if (currMaps[id]) {\n const nextMaps = { ...currMaps };\n delete nextMaps[id];\n return nextMaps;\n }\n return currMaps;\n });\n }, []);\n return (React.createElement(MountedMapsContext.Provider, { value: {\n maps,\n onMapMount,\n onMapUnmount\n } }, props.children));\n};\nexport function useMap() {\n var _a;\n const maps = (_a = useContext(MountedMapsContext)) === null || _a === void 0 ? void 0 : _a.maps;\n const currentMap = useContext(MapContext);\n const mapsWithCurrent = useMemo(() => {\n return { ...maps, current: currentMap === null || currentMap === void 0 ? void 0 : currentMap.map };\n }, [maps, currentMap]);\n return mapsWithCurrent;\n}\n//# sourceMappingURL=use-map.js.map"],"names":["MountedMapsContext","React","useMap","_a","maps","useContext","currentMap","MapContext","useMemo"],"mappings":";;;AAGa,MAAAA,IAAqBC,EAAM,cAAc,IAAI;AA8BnD,SAASC,IAAS;AACjB,MAAAC;AACE,QAAAC,KAAQD,IAAKE,EAAWL,CAAkB,OAAO,QAAQG,MAAO,SAAS,SAASA,EAAG,MACrFG,IAAaD,EAAWE,CAAU;AAIjC,SAHiBC,EAAQ,OACrB,EAAE,GAAGJ,GAAM,SAASE,KAAe,OAAgC,SAASA,EAAW,IAAI,IACnG,CAACF,GAAME,CAAU,CAAC;AAEzB;","x_google_ignoreList":[0]}
@@ -1,54 +1,5 @@
1
- import { useContext as m, useRef as L, useState as g, useMemo as x, useEffect as h } from "react";
2
- import { MapContext as b } from "./index.es68.js";
3
- import d from "./index.es188.js";
4
- import { deepEqual as l } from "./index.es187.js";
5
- function k(t, e, a, o) {
6
- if (d(a.id === o.id, "layer id changed"), d(a.type === o.type, "layer type changed"), a.type === "custom" || o.type === "custom")
7
- return;
8
- const { layout: r = {}, paint: i = {}, filter: y, minzoom: c, maxzoom: u, beforeId: s } = a;
9
- if (s !== o.beforeId && t.moveLayer(e, s), r !== o.layout) {
10
- const f = o.layout || {};
11
- for (const n in r)
12
- l(r[n], f[n]) || t.setLayoutProperty(e, n, r[n]);
13
- for (const n in f)
14
- r.hasOwnProperty(n) || t.setLayoutProperty(e, n, void 0);
15
- }
16
- if (i !== o.paint) {
17
- const f = o.paint || {};
18
- for (const n in i)
19
- l(i[n], f[n]) || t.setPaintProperty(e, n, i[n]);
20
- for (const n in f)
21
- i.hasOwnProperty(n) || t.setPaintProperty(e, n, void 0);
22
- }
23
- l(y, o.filter) || t.setFilter(e, y), (c !== o.minzoom || u !== o.maxzoom) && t.setLayerZoomRange(e, c, u);
24
- }
25
- function z(t, e, a) {
26
- if (t.style && t.style._loaded && (!("source" in a) || t.getSource(a.source))) {
27
- const o = { ...a, id: e };
28
- delete o.beforeId, t.addLayer(o, a.beforeId);
29
- }
30
- }
31
- let I = 0;
32
- function S(t) {
33
- const e = m(b).map.getMap(), a = L(t), [, o] = g(0), r = x(() => t.id || `jsx-layer-${I++}`, []);
34
- if (h(() => {
35
- if (e) {
36
- const y = () => o((c) => c + 1);
37
- return e.on("styledata", y), y(), () => {
38
- e.off("styledata", y), e.style && e.style._loaded && e.getLayer(r) && e.removeLayer(r);
39
- };
40
- }
41
- }, [e]), e && e.style && e.getLayer(r))
42
- try {
43
- k(e, r, t, a.current);
44
- } catch (y) {
45
- console.warn(y);
46
- }
47
- else
48
- z(e, r, t);
49
- return a.current = t, null;
50
- }
1
+ var r = {};
51
2
  export {
52
- S as default
3
+ r as __exports
53
4
  };
54
5
  //# sourceMappingURL=index.es78.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es78.js","sources":["../../../node_modules/react-map-gl/dist/esm/components/layer.js"],"sourcesContent":["import { useContext, useEffect, useMemo, useState, useRef } from 'react';\nimport { MapContext } from './map';\nimport assert from '../utils/assert';\nimport { deepEqual } from '../utils/deep-equal';\n/* eslint-disable complexity, max-statements */\nfunction updateLayer(map, id, props, prevProps) {\n assert(props.id === prevProps.id, 'layer id changed');\n assert(props.type === prevProps.type, 'layer type changed');\n if (props.type === 'custom' || prevProps.type === 'custom') {\n return;\n }\n const { layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId } = props;\n if (beforeId !== prevProps.beforeId) {\n map.moveLayer(id, beforeId);\n }\n if (layout !== prevProps.layout) {\n const prevLayout = prevProps.layout || {};\n for (const key in layout) {\n if (!deepEqual(layout[key], prevLayout[key])) {\n map.setLayoutProperty(id, key, layout[key]);\n }\n }\n for (const key in prevLayout) {\n if (!layout.hasOwnProperty(key)) {\n map.setLayoutProperty(id, key, undefined);\n }\n }\n }\n if (paint !== prevProps.paint) {\n const prevPaint = prevProps.paint || {};\n for (const key in paint) {\n if (!deepEqual(paint[key], prevPaint[key])) {\n map.setPaintProperty(id, key, paint[key]);\n }\n }\n for (const key in prevPaint) {\n if (!paint.hasOwnProperty(key)) {\n map.setPaintProperty(id, key, undefined);\n }\n }\n }\n if (!deepEqual(filter, prevProps.filter)) {\n map.setFilter(id, filter);\n }\n if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {\n map.setLayerZoomRange(id, minzoom, maxzoom);\n }\n}\nfunction createLayer(map, id, props) {\n // @ts-ignore\n if (map.style && map.style._loaded && (!('source' in props) || map.getSource(props.source))) {\n const options = { ...props, id };\n delete options.beforeId;\n // @ts-ignore\n map.addLayer(options, props.beforeId);\n }\n}\n/* eslint-enable complexity, max-statements */\nlet layerCounter = 0;\nfunction Layer(props) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);\n useEffect(() => {\n if (map) {\n const forceUpdate = () => setStyleLoaded(version => version + 1);\n map.on('styledata', forceUpdate);\n forceUpdate();\n return () => {\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getLayer(id)) {\n map.removeLayer(id);\n }\n };\n }\n return undefined;\n }, [map]);\n // @ts-ignore\n const layer = map && map.style && map.getLayer(id);\n if (layer) {\n try {\n updateLayer(map, id, props, propsRef.current);\n }\n catch (error) {\n console.warn(error); // eslint-disable-line\n }\n }\n else {\n createLayer(map, id, props);\n }\n // Store last rendered props\n propsRef.current = props;\n return null;\n}\nexport default Layer;\n//# sourceMappingURL=layer.js.map"],"names":["updateLayer","map","id","props","prevProps","assert","layout","paint","filter","minzoom","maxzoom","beforeId","prevLayout","key","deepEqual","prevPaint","createLayer","options","layerCounter","Layer","useContext","MapContext","propsRef","useRef","setStyleLoaded","useState","useMemo","useEffect","forceUpdate","version","error"],"mappings":";;;;AAKA,SAASA,EAAYC,GAAKC,GAAIC,GAAOC,GAAW;AAG5C,MAFAC,EAAOF,EAAM,OAAOC,EAAU,IAAI,kBAAkB,GACpDC,EAAOF,EAAM,SAASC,EAAU,MAAM,oBAAoB,GACtDD,EAAM,SAAS,YAAYC,EAAU,SAAS;AAC9C;AAEE,QAAA,EAAE,QAAAE,IAAS,IAAI,OAAAC,IAAQ,CAAC,GAAG,QAAAC,GAAQ,SAAAC,GAAS,SAAAC,GAAS,UAAAC,EAAa,IAAAR;AAIpE,MAHAQ,MAAaP,EAAU,YACnBH,EAAA,UAAUC,GAAIS,CAAQ,GAE1BL,MAAWF,EAAU,QAAQ;AACvB,UAAAQ,IAAaR,EAAU,UAAU;AACvC,eAAWS,KAAOP;AACV,MAACQ,EAAUR,EAAOO,CAAG,GAAGD,EAAWC,CAAG,CAAC,KACvCZ,EAAI,kBAAkBC,GAAIW,GAAKP,EAAOO,CAAG,CAAC;AAGlD,eAAWA,KAAOD;AACd,MAAKN,EAAO,eAAeO,CAAG,KACtBZ,EAAA,kBAAkBC,GAAIW,GAAK,MAAS;AAAA,EAGpD;AACI,MAAAN,MAAUH,EAAU,OAAO;AACrB,UAAAW,IAAYX,EAAU,SAAS;AACrC,eAAWS,KAAON;AACV,MAACO,EAAUP,EAAMM,CAAG,GAAGE,EAAUF,CAAG,CAAC,KACrCZ,EAAI,iBAAiBC,GAAIW,GAAKN,EAAMM,CAAG,CAAC;AAGhD,eAAWA,KAAOE;AACd,MAAKR,EAAM,eAA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AQ,KAAKA,CAAK;AAAA,IACtB;AAAA;AAGY,IAAAd,EAAAf,GAAKC,GAAIC,CAAK;AAG9B,SAAAmB,EAAS,UAAUnB,GACZ;AACX;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es78.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,68 +1,5 @@
1
- import * as u from "react";
2
- import { useContext as f, useRef as y, useState as m, useMemo as g, useEffect as S, cloneElement as h } from "react";
3
- import { MapContext as C } from "./index.es68.js";
4
- import s from "./index.es188.js";
5
- import { deepEqual as v } from "./index.es187.js";
6
- let x = 0;
7
- function U(t, e, a) {
8
- if (t.style && t.style._loaded) {
9
- const n = { ...a };
10
- return delete n.id, delete n.children, t.addSource(e, n), t.getSource(e);
11
- }
12
- return null;
13
- }
14
- function b(t, e, a) {
15
- s(e.id === a.id, "source id changed"), s(e.type === a.type, "source type changed");
16
- let n = "", r = 0;
17
- for (const o in e)
18
- o !== "children" && o !== "id" && !v(a[o], e[o]) && (n = o, r++);
19
- if (!r)
20
- return;
21
- const l = e.type;
22
- if (l === "geojson")
23
- t.setData(e.data);
24
- else if (l === "image")
25
- t.updateImage({
26
- url: e.url,
27
- coordinates: e.coordinates
28
- });
29
- else if ("setCoordinates" in t && r === 1 && n === "coordinates")
30
- t.setCoordinates(e.coordinates);
31
- else if ("setUrl" in t)
32
- switch (n) {
33
- case "url":
34
- t.setUrl(e.url);
35
- break;
36
- case "tiles":
37
- t.setTiles(e.tiles);
38
- break;
39
- }
40
- else
41
- console.warn(`Unable to update <Source> prop: ${n}`);
42
- }
43
- function R(t) {
44
- const e = f(C).map.getMap(), a = y(t), [, n] = m(0), r = g(() => t.id || `jsx-source-${x++}`, []);
45
- S(() => {
46
- if (e) {
47
- const o = () => setTimeout(() => n((i) => i + 1), 0);
48
- return e.on("styledata", o), o(), () => {
49
- var i;
50
- if (e.off("styledata", o), e.style && e.style._loaded && e.getSource(r)) {
51
- const c = (i = e.getStyle()) === null || i === void 0 ? void 0 : i.layers;
52
- if (c)
53
- for (const d of c)
54
- d.source === r && e.removeLayer(d.id);
55
- e.removeSource(r);
56
- }
57
- };
58
- }
59
- }, [e]);
60
- let l = e && e.style && e.getSource(r);
61
- return l ? b(l, t, a.current) : l = U(e, r, t), a.current = t, l && u.Children.map(t.children, (o) => o && h(o, {
62
- source: r
63
- })) || null;
64
- }
1
+ var e = {};
65
2
  export {
66
- R as default
3
+ e as __exports
67
4
  };
68
5
  //# sourceMappingURL=index.es79.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es79.js","sources":["../../../node_modules/react-map-gl/dist/esm/components/source.js"],"sourcesContent":["import * as React from 'react';\nimport { useContext, useEffect, useMemo, useState, useRef } from 'react';\nimport { cloneElement } from 'react';\nimport { MapContext } from './map';\nimport assert from '../utils/assert';\nimport { deepEqual } from '../utils/deep-equal';\nlet sourceCounter = 0;\nfunction createSource(map, id, props) {\n // @ts-ignore\n if (map.style && map.style._loaded) {\n const options = { ...props };\n delete options.id;\n delete options.children;\n // @ts-ignore\n map.addSource(id, options);\n return map.getSource(id);\n }\n return null;\n}\n/* eslint-disable complexity */\nfunction updateSource(source, props, prevProps) {\n assert(props.id === prevProps.id, 'source id changed');\n assert(props.type === prevProps.type, 'source type changed');\n let changedKey = '';\n let changedKeyCount = 0;\n for (const key in props) {\n if (key !== 'children' && key !== 'id' && !deepEqual(prevProps[key], props[key])) {\n changedKey = key;\n changedKeyCount++;\n }\n }\n if (!changedKeyCount) {\n return;\n }\n const type = props.type;\n if (type === 'geojson') {\n source.setData(props.data);\n }\n else if (type === 'image') {\n source.updateImage({\n url: props.url,\n coordinates: props.coordinates\n });\n }\n else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') {\n source.setCoordinates(props.coordinates);\n }\n else if ('setUrl' in source) {\n // Added in 1.12.0:\n // vectorTileSource.setTiles\n // vectorTileSource.setUrl\n switch (changedKey) {\n case 'url':\n source.setUrl(props.url);\n break;\n case 'tiles':\n source.setTiles(props.tiles);\n break;\n default:\n }\n }\n else {\n // eslint-disable-next-line\n console.warn(`Unable to update <Source> prop: ${changedKey}`);\n }\n}\n/* eslint-enable complexity */\nfunction Source(props) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n const id = useMemo(() => props.id || `jsx-source-${sourceCounter++}`, []);\n useEffect(() => {\n if (map) {\n /* global setTimeout */\n const forceUpdate = () => setTimeout(() => setStyleLoaded(version => version + 1), 0);\n map.on('styledata', forceUpdate);\n forceUpdate();\n return () => {\n var _a;\n map.off('styledata', forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getSource(id)) {\n // Parent effects are destroyed before child ones, see\n // https://github.com/facebook/react/issues/16728\n // Source can only be removed after all child layers are removed\n const allLayers = (_a = map.getStyle()) === null || _a === void 0 ? void 0 : _a.layers;\n if (allLayers) {\n for (const layer of allLayers) {\n // @ts-ignore (2339) source does not exist on all layer types\n if (layer.source === id) {\n map.removeLayer(layer.id);\n }\n }\n }\n map.removeSource(id);\n }\n };\n }\n return undefined;\n }, [map]);\n // @ts-ignore\n let source = map && map.style && map.getSource(id);\n if (source) {\n updateSource(source, props, propsRef.current);\n }\n else {\n source = createSource(map, id, props);\n }\n propsRef.current = props;\n return ((source &&\n React.Children.map(props.children, child => child &&\n cloneElement(child, {\n source: id\n }))) ||\n null);\n}\nexport default Source;\n//# sourceMappingURL=source.js.map"],"names":["sourceCounter","createSource","map","id","props","options","updateSource","source","prevProps","assert","changedKey","changedKeyCount","key","deepEqual","type","Source","useContext","MapContext","propsRef","useRef","setStyleLoaded","useState","useMemo","useEffect","forceUpdate","version","_a","allLayers","layer","React","child","cloneElement"],"mappings":";;;;;AAMA,IAAIA,IAAgB;AACpB,SAASC,EAAaC,GAAKC,GAAIC,GAAO;AAElC,MAAIF,EAAI,SAASA,EAAI,MAAM,SAAS;AAC1B,UAAAG,IAAU,EAAE,GAAGD;AACrB,kBAAOC,EAAQ,IACf,OAAOA,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,MAAM,WAAW,MAAMJ,EAAe,CAAWK,MAAAA,IAAU,CAAC,GAAG,CAAC;AAChF,aAAAvB,EAAA,GAAG,aAAasB,CAAW,GACnBA,KACL,MAAM;AACL,YAAAE;AAGA,YAFAxB,EAAA,IAAI,aAAasB,CAAW,GAE5BtB,EAAI,SAASA,EAAI,MAAM,WAAWA,EAAI,UAAUC,CAAE,GAAG;AAI/C,gBAAAwB,KAAaD,IAAKxB,EAAI,SAAA,OAAgB,QAAQwB,MAAO,SAAS,SAASA,EAAG;AAChF,cAAIC;AACA,uBAAWC,KAASD;AAEZ,cAAAC,EAAM,WAAWzB,KACbD,EAAA,YAAY0B,EAAM,EAAE;AAIpC,UAAA1B,EAAI,aAAaC,CAAE;AAAA,QACvB;AAAA,MAAA;AAAA,IAER;AAAA,EACO,GACR,CAACD,CAAG,CAAC;AAER,MAAIK,IAASL,KAAOA,EAAI,SAASA,EAAI,UAAUC,CAAE;AACjD,SAAII,IACaD,EAAAC,GAAQH,GAAOc,EAAS,OAAO,IAGnCX,IAAAN,EAAaC,GAAKC,GAAIC,CAAK,GAExCc,EAAS,UAAUd,GACVG,KACLsB,EAAM,SAAS,IAAIzB,EAAM,UAAU,CAAA0B,MAASA,KACxCC,EAAaD,GAAO;AAAA,IAChB,QAAQ3B;AAAA,EAAA,CACX,CAAC,KACN;AACR;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es79.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/dist/index.es8.js CHANGED
@@ -1,10 +1,10 @@
1
- import { j as i } from "./index.es17.js";
2
- import l from "./index.es14.js";
1
+ import { j as r } from "./index.es17.js";
2
+ import m from "./index.es14.js";
3
3
  import h from "./index.es19.js";
4
- import { useState as b, useRef as u, useCallback as a, useMemo as g, useEffect as x } from "react";
5
- import { Map as D, NavigationControl as R } from "./index.es15.js";
6
- import { FullscreenControl as w } from "./index.es51.js";
7
- import G from "./index.es22.js";
4
+ import { useState as b, useRef as g, useCallback as a, useMemo as u, useEffect as x } from "react";
5
+ import { Map as D, NavigationControl as G } from "./index.es15.js";
6
+ import { FullscreenControl as R } from "./index.es51.js";
7
+ import w from "./index.es22.js";
8
8
  import "./index.es23.js";
9
9
  import "./index.es24.js";
10
10
  import "./index.es25.js";
@@ -32,35 +32,35 @@ import "./index.es46.js";
32
32
  import "./index.es47.js";
33
33
  import "./index.es48.js";
34
34
  import "./index.es49.js";
35
- import L from "./index.es2.js";
36
- import O from "./index.es4.js";
37
- import S from "./index.es12.js";
35
+ import S from "./index.es2.js";
36
+ import L from "./index.es4.js";
37
+ import O from "./index.es12.js";
38
38
  import "./index.es52.js";
39
39
  import { feature as v } from "./index.es53.js";
40
- l.constants.classes.CONTROL_BASE = "maplibregl-ctrl";
41
- l.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-";
42
- l.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group";
43
- const B = 2, E = 1e3, m = {
40
+ m.constants.classes.CONTROL_BASE = "maplibregl-ctrl";
41
+ m.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-";
42
+ m.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group";
43
+ const B = 2, E = 1e3, l = {
44
44
  geometryCollection: "GeometryCollection",
45
45
  point: "Point",
46
- polygon: "Polygon"
47
- }, _ = (t) => {
48
- const [c, d] = b(!1), o = u(), s = u(), f = a((e) => {
46
+ polygon: ["Polygon", "MultiPolygon"]
47
+ }, M = (t) => {
48
+ const [c, d] = b(!1), o = g(), s = g(), f = a((e) => {
49
49
  if (!e)
50
50
  return !1;
51
51
  const { geometry: { type: n } } = e;
52
- return t.geocoding === "point" && n === m.point || t.geocoding === "polygon" && n === m.polygon;
53
- }, [t.geocoding]), r = a(() => t.onChange(o.current.getAll()), [t.onChange]), y = a(({ detail: e }) => {
54
- f(e) && (o.current.add(e.geometry), r(), t.onGeocodingSelection(e));
55
- }, [f, r, t.onGeocodingSelection]), p = g(() => `${t.mapStyle}?key=${t.apiKey}`, [t.apiKey, t.mapStyle]), C = g(() => ({ height: 500, width: "100%", ...t.style || {} }), [t.style]);
52
+ return t.geocoding === "point" && n === l.point || t.geocoding === "polygon" && l.polygon.includes(n);
53
+ }, [t.geocoding]), i = a(() => t.onChange(o.current.getAll()), [t.onChange]), y = a(({ detail: e }) => {
54
+ f(e) && (o.current.add(e.geometry), i(), t.onGeocodingSelection && t.onGeocodingSelection(e));
55
+ }, [f, i, t.onGeocodingSelection]), p = u(() => `${t.mapStyle}?key=${t.apiKey}`, [t.apiKey, t.mapStyle]), C = u(() => ({ height: 500, width: "100%", ...t.style || {} }), [t.style]);
56
56
  return x(() => {
57
57
  if (c && t.data) {
58
- const e = S.getBoundingBox(t.data, t.buffer);
59
- e && s.current.fitBounds(e, { duration: t.zoomDuration }), t.data.type === m.geometryCollection ? G.each(t.data.geometries, (n) => {
58
+ const e = O.getBoundingBox(t.data, t.buffer);
59
+ e && s.current.fitBounds(e, { duration: t.zoomDuration }), t.data.type === l.geometryCollection ? w.each(t.data.geometries, (n) => {
60
60
  o.current.add(v(n));
61
61
  }) : o.current.add(t.data);
62
62
  }
63
- }, [c, t.data]), /* @__PURE__ */ i.jsxs(
63
+ }, [c, t.data]), /* @__PURE__ */ r.jsxs(
64
64
  D,
65
65
  {
66
66
  attributionControl: !1,
@@ -73,8 +73,8 @@ const B = 2, E = 1e3, m = {
73
73
  style: C,
74
74
  mapStyle: p,
75
75
  children: [
76
- /* @__PURE__ */ i.jsx(
77
- L,
76
+ /* @__PURE__ */ r.jsx(
77
+ S,
78
78
  {
79
79
  ref: o,
80
80
  controls: {
@@ -84,14 +84,14 @@ const B = 2, E = 1e3, m = {
84
84
  trash: !0
85
85
  },
86
86
  displayControlsDefault: !1,
87
- onCreate: r,
88
- onUpdate: r,
89
- onDelete: r,
87
+ onCreate: i,
88
+ onUpdate: i,
89
+ onDelete: i,
90
90
  position: "bottom-left"
91
91
  }
92
92
  ),
93
- t.geocoding && /* @__PURE__ */ i.jsx(
94
- O,
93
+ t.geocoding && /* @__PURE__ */ r.jsx(
94
+ L,
95
95
  {
96
96
  apiKey: t.apiKey,
97
97
  marker: !1,
@@ -99,22 +99,23 @@ const B = 2, E = 1e3, m = {
99
99
  onSelection: y,
100
100
  showFullGeometry: t.geocoding === "polygon",
101
101
  showResultMarkers: !1
102
- }
102
+ },
103
+ t.geocoding
103
104
  ),
104
- t.navigation && /* @__PURE__ */ i.jsx(R, {}),
105
- t.fullscreen && /* @__PURE__ */ i.jsx(w, {}),
105
+ t.navigation && /* @__PURE__ */ r.jsx(G, {}),
106
+ t.fullscreen && /* @__PURE__ */ r.jsx(R, {}),
106
107
  t.children
107
108
  ]
108
109
  }
109
110
  );
110
111
  };
111
- _.defaultProps = {
112
+ M.defaultProps = {
112
113
  buffer: B,
113
114
  cooperativeGestures: !0,
114
115
  preserveDrawingBuffer: !1,
115
116
  zoomDuration: E
116
117
  };
117
118
  export {
118
- _ as default
119
+ M as default
119
120
  };
120
121
  //# sourceMappingURL=index.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es8.js","sources":["../src/components/MapDraw.js"],"sourcesContent":["// @flow\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport { feature, type FeatureCollection, type GeometryCollection } from '@turf/turf';\nimport maplibregl from 'maplibre-gl';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type Node\n} from 'react';\nimport Map, { type MapboxMap, NavigationControl } from 'react-map-gl';\nimport { FullscreenControl } from 'react-map-gl/maplibre';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\nimport GeocodingControl from './GeocodingControl';\nimport MapUtils from '../utils/Map';\nimport './MapDraw.css';\n\n// Override the MapboxDraw components to use MapLibre styles\nMapboxDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl';\nMapboxDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-';\nMapboxDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group';\n\ntype Props = {\n /**\n * MapTiler API key.\n */\n apiKey?: string,\n\n /**\n * The number of miles to buffer the GeoJSON data.\n */\n buffer?: number,\n\n /**\n * Additional child nodes to render.\n */\n children?: Node,\n\n /**\n * If `true`, the map will require CTRL + scroll to zoom.\n */\n cooperativeGestures?: boolean,\n\n /**\n * GeoJSON structured data to be displayed on the map.\n */\n data: GeometryCollection | FeatureCollection,\n\n /**\n * If `true`, a control will be rendered to put the map in full screen mode.\n */\n fullscreen?: boolean,\n\n /**\n * Controls the type of GeoJSON data returned from the MapTiler Geocoding API.\n */\n geocoding?: undefined | 'point' | 'polygon',\n\n /**\n * URL of the map style to render. This URL should contain any necessary API keys.\n */\n mapStyle: string,\n\n /**\n * The maximum pitch of the map (0-85).\n */\n maxPitch?: number,\n\n /**\n * If `true`, the navigation controls will display.\n */\n navigation?: boolean,\n\n /**\n * Callback fired when the map geometries are changed.\n *\n * @param features\n */\n onChange: (features: Array<any>) => void,\n\n /**\n * Callback fired when an item is selected from the geocoding dropdown.\n */\n onGeocodingSelection?: (data: any) => void,\n\n /**\n * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`.\n */\n preserveDrawingBuffer?: boolean,\n\n /**\n * Map style object.\n */\n style?: any,\n\n /**\n * The time in milliseconds to zoom into the location.\n */\n zoomDuration?: number\n};\n\nconst DEFAULT_BUFFER = 2;\nconst DEFAULT_ZOOM_DELAY = 1000;\n\nconst GeometryTypes = {\n geometryCollection: 'GeometryCollection',\n point: 'Point',\n polygon: 'Polygon'\n};\n\n/**\n * This component renders a map with controls for drawing one or more geometries. Geometries can be a point (lat/long),\n * a line, or a polygon.\n */\nconst MapDraw = (props: Props) => {\n const [loaded, setLoaded] = useState(false);\n\n const drawRef = useRef<MapboxDraw>();\n const mapRef = useRef<MapboxMap>();\n\n /**\n * Returns true if the passed geometry type is valid. MapTiler fires the onSelection callback twice: Once after\n * selecting the record from the list (with a point geometry), and once after making a call to the server for the\n * full record (polygon geometry). We should on fire the onGeocodingSelection callback and add the geometry to the\n * map once.\n *\n * @type {function({geometry: {type: *}}): *}\n */\n const isValid = useCallback((detail) => {\n if (!detail) {\n return false;\n }\n\n const { geometry: { type } } = detail;\n\n return (props.geocoding === 'point' && type === GeometryTypes.point)\n || (props.geocoding === 'polygon' && type === GeometryTypes.polygon);\n }, [props.geocoding]);\n\n /**\n * Calls the onChange prop with all of the geometries in the current drawer.\n *\n * @type {(function(): void)|*}\n */\n const onChange = useCallback(() => props.onChange(drawRef.current.getAll()), [props.onChange]);\n\n /**\n * Adds the selected geometry to the map.\n *\n * @type {(function({detail: *}): void)|*}\n */\n const onSelection = useCallback(({ detail }) => {\n if (isValid(detail)) {\n // Add the geometry to the map\n drawRef.current.add(detail.geometry);\n\n // Trigger the onChange prop\n onChange();\n\n // Call the onGeocoding selection callback\n props.onGeocodingSelection(detail);\n }\n }, [isValid, onChange, props.onGeocodingSelection]);\n\n /**\n * Sets the map style URL.\n *\n * @type {string}\n */\n const mapStyleUrl = useMemo(() => `${props.mapStyle}?key=${props.apiKey}`, [props.apiKey, props.mapStyle]);\n\n /**\n * Sets the element map style.\n *\n * @type {{width: string, height: number}}\n */\n const style = useMemo(() => ({ height: 500, width: '100%', ...(props.style || {}) }), [props.style]);\n\n /**\n * Updates the map bounding box and drawer when the geometry is changed.\n */\n useEffect(() => {\n if (loaded && props.data) {\n // Sets the bounding box for the current geometry\n const bbox = MapUtils.getBoundingBox(props.data, props.buffer);\n\n if (bbox) {\n mapRef.current.fitBounds(bbox, { duration: props.zoomDuration });\n }\n\n // Handle special cases for geometry collection (not supported by mabox-gl-draw) and point\n if (props.data.type === GeometryTypes.geometryCollection) {\n _.each(props.data.geometries, (geometry) => {\n drawRef.current.add(feature(geometry));\n });\n } else {\n drawRef.current.add(props.data);\n }\n }\n }, [loaded, props.data]);\n\n return (\n <Map\n attributionControl={false}\n cooperativeGestures={props.cooperativeGestures}\n mapLib={maplibregl}\n maxPitch={props.maxPitch}\n onLoad={() => setLoaded(true)}\n preserveDrawingBuffer={props.preserveDrawingBuffer}\n ref={mapRef}\n style={style}\n mapStyle={mapStyleUrl}\n >\n <DrawControl\n ref={drawRef}\n controls={{\n line_string: true,\n point: true,\n polygon: true,\n trash: true\n }}\n displayControlsDefault={false}\n onCreate={onChange}\n onUpdate={onChange}\n onDelete={onChange}\n position='bottom-left'\n />\n { props.geocoding && (\n <GeocodingControl\n apiKey={props.apiKey}\n marker={false}\n position='top-left'\n onSelection={onSelection}\n showFullGeometry={props.geocoding === 'polygon'}\n showResultMarkers={false}\n />\n )}\n { props.navigation && (\n <NavigationControl />\n )}\n { props.fullscreen && (\n <FullscreenControl />\n )}\n { props.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\n cooperativeGestures: true,\n preserveDrawingBuffer: false,\n zoomDuration: DEFAULT_ZOOM_DELAY\n};\n\nexport default MapDraw;\n"],"names":["MapboxDraw","DEFAULT_BUFFER","DEFAULT_ZOOM_DELAY","GeometryTypes","MapDraw","props","loaded","setLoaded","useState","drawRef","useRef","mapRef","isValid","useCallback","detail","type","onChange","onSelection","mapStyleUrl","useMemo","style","useEffect","bbox","MapUtils","_","geometry","feature","jsxs","Map","maplibregl","jsx","DrawControl","GeocodingControl","NavigationControl","FullscreenControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBAA,EAAW,UAAU,QAAQ,eAAe;AAC5CA,EAAW,UAAU,QAAQ,iBAAiB;AAC9CA,EAAW,UAAU,QAAQ,gBAAgB;AAiF7C,MAAMC,IAAiB,GACjBC,IAAqB,KAErBC,IAAgB;AAAA,EACpB,oBAAoB;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AACX,GAMMC,IAAU,CAACC,MAAiB;AAChC,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAUC,KACVC,IAASD,KAUTE,IAAUC,EAAY,CAACC,MAAW;AACtC,QAAI,CAACA;AACI,aAAA;AAGT,UAAM,EAAE,UAAU,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BvB,EAAM;AAAA,MAC3B,QAAQwB;AAAA,MACR,UAAUxB,EAAM;AAAA,MAChB,QAAQ,MAAME,EAAU,EAAI;AAAA,MAC5B,uBAAuBF,EAAM;AAAA,MAC7B,KAAKM;AAAA,MACL,OAAAS;AAAA,MACA,UAAUF;AAAA,MAEV,UAAA;AAAA,QAAAY,gBAAAA,EAAA;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,KAAKtB;AAAA,YACL,UAAU;AAAA,cACR,aAAa;AAAA,cACb,OAAO;AAAA,cACP,SAAS;AAAA,cACT,OAAO;AAAA,YACT;AAAA,YACA,wBAAwB;AAAA,YACxB,UAAUO;AAAA,YACV,UAAUA;AAAA,YACV,UAAUA;AAAA,YACV,UAAS;AAAA,UAAA;AAAA,QACX;AAAA,QACEX,EAAM,aACNyB,gBAAAA,EAAA;AAAA,UAACE;AAAA,UAAA;AAAA,YACC,QAAQ3B,EAAM;AAAA,YACd,QAAQ;AAAA,YACR,UAAS;AAAA,YACT,aAAAY;AAAA,YACA,kBAAkBZ,EAAM,cAAc;AAAA,YACtC,mBAAmB;AAAA,UAAA;AAAA,QACrB;AAAA,QAEAA,EAAM,cACNyB,gBAAAA,MAACG,GAAkB,CAAA,CAAA;AAAA,QAEnB5B,EAAM,cACNyB,gBAAAA,MAACI,GAAkB,CAAA,CAAA;AAAA,QAEnB7B,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGd;AAEAD,EAAQ,eAAe;AAAA,EACrB,QAAQH;AAAA,EACR,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,cAAcC;AAChB;"}
1
+ {"version":3,"file":"index.es8.js","sources":["../src/components/MapDraw.js"],"sourcesContent":["// @flow\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport { feature, type FeatureCollection, type GeometryCollection } from '@turf/turf';\nimport maplibregl from 'maplibre-gl';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type Node\n} from 'react';\nimport Map, { type MapboxMap, NavigationControl } from 'react-map-gl';\nimport { FullscreenControl } from 'react-map-gl/maplibre';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\nimport GeocodingControl from './GeocodingControl';\nimport MapUtils from '../utils/Map';\nimport './MapDraw.css';\n\n// Override the MapboxDraw components to use MapLibre styles\nMapboxDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl';\nMapboxDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-';\nMapboxDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group';\n\ntype Props = {\n /**\n * MapTiler API key.\n */\n apiKey?: string,\n\n /**\n * The number of miles to buffer the GeoJSON data.\n */\n buffer?: number,\n\n /**\n * Additional child nodes to render.\n */\n children?: Node,\n\n /**\n * If `true`, the map will require CTRL + scroll to zoom.\n */\n cooperativeGestures?: boolean,\n\n /**\n * GeoJSON structured data to be displayed on the map.\n */\n data: GeometryCollection | FeatureCollection,\n\n /**\n * If `true`, a control will be rendered to put the map in full screen mode.\n */\n fullscreen?: boolean,\n\n /**\n * Controls the type of GeoJSON data returned from the MapTiler Geocoding API.\n */\n geocoding?: undefined | 'point' | 'polygon',\n\n /**\n * URL of the map style to render. This URL should contain any necessary API keys.\n */\n mapStyle: string,\n\n /**\n * The maximum pitch of the map (0-85).\n */\n maxPitch?: number,\n\n /**\n * If `true`, the navigation controls will display.\n */\n navigation?: boolean,\n\n /**\n * Callback fired when the map geometries are changed.\n *\n * @param features\n */\n onChange: (features: Array<any>) => void,\n\n /**\n * Callback fired when an item is selected from the geocoding dropdown.\n */\n onGeocodingSelection?: (data: any) => void,\n\n /**\n * If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`.\n */\n preserveDrawingBuffer?: boolean,\n\n /**\n * Map style object.\n */\n style?: any,\n\n /**\n * The time in milliseconds to zoom into the location.\n */\n zoomDuration?: number\n};\n\nconst DEFAULT_BUFFER = 2;\nconst DEFAULT_ZOOM_DELAY = 1000;\n\nconst GeometryTypes = {\n geometryCollection: 'GeometryCollection',\n point: 'Point',\n polygon: ['Polygon', 'MultiPolygon']\n};\n\n/**\n * This component renders a map with controls for drawing one or more geometries. Geometries can be a point (lat/long),\n * a line, or a polygon.\n */\nconst MapDraw = (props: Props) => {\n const [loaded, setLoaded] = useState(false);\n\n const drawRef = useRef<MapboxDraw>();\n const mapRef = useRef<MapboxMap>();\n\n /**\n * Returns true if the passed geometry type is valid. MapTiler fires the onSelection callback twice: Once after\n * selecting the record from the list (with a point geometry), and once after making a call to the server for the\n * full record (polygon geometry). We should on fire the onGeocodingSelection callback and add the geometry to the\n * map once.\n *\n * @type {function({geometry: {type: *}}): *}\n */\n const isValid = useCallback((detail) => {\n if (!detail) {\n return false;\n }\n\n const { geometry: { type } } = detail;\n\n return (props.geocoding === 'point' && type === GeometryTypes.point)\n || (props.geocoding === 'polygon' && GeometryTypes.polygon.includes(type));\n }, [props.geocoding]);\n\n /**\n * Calls the onChange prop with all of the geometries in the current drawer.\n *\n * @type {(function(): void)|*}\n */\n const onChange = useCallback(() => props.onChange(drawRef.current.getAll()), [props.onChange]);\n\n /**\n * Adds the selected geometry to the map.\n *\n * @type {(function({detail: *}): void)|*}\n */\n const onSelection = useCallback(({ detail }) => {\n if (isValid(detail)) {\n // Add the geometry to the map\n drawRef.current.add(detail.geometry);\n\n // Trigger the onChange prop\n onChange();\n\n // Call the onGeocoding selection callback\n if (props.onGeocodingSelection) {\n props.onGeocodingSelection(detail);\n }\n }\n }, [isValid, onChange, props.onGeocodingSelection]);\n\n /**\n * Sets the map style URL.\n *\n * @type {string}\n */\n const mapStyleUrl = useMemo(() => `${props.mapStyle}?key=${props.apiKey}`, [props.apiKey, props.mapStyle]);\n\n /**\n * Sets the element map style.\n *\n * @type {{width: string, height: number}}\n */\n const style = useMemo(() => ({ height: 500, width: '100%', ...(props.style || {}) }), [props.style]);\n\n /**\n * Updates the map bounding box and drawer when the geometry is changed.\n */\n useEffect(() => {\n if (loaded && props.data) {\n // Sets the bounding box for the current geometry\n const bbox = MapUtils.getBoundingBox(props.data, props.buffer);\n\n if (bbox) {\n mapRef.current.fitBounds(bbox, { duration: props.zoomDuration });\n }\n\n // Handle special cases for geometry collection (not supported by mabox-gl-draw) and point\n if (props.data.type === GeometryTypes.geometryCollection) {\n _.each(props.data.geometries, (geometry) => {\n drawRef.current.add(feature(geometry));\n });\n } else {\n drawRef.current.add(props.data);\n }\n }\n }, [loaded, props.data]);\n\n return (\n <Map\n attributionControl={false}\n cooperativeGestures={props.cooperativeGestures}\n mapLib={maplibregl}\n maxPitch={props.maxPitch}\n onLoad={() => setLoaded(true)}\n preserveDrawingBuffer={props.preserveDrawingBuffer}\n ref={mapRef}\n style={style}\n mapStyle={mapStyleUrl}\n >\n <DrawControl\n ref={drawRef}\n controls={{\n line_string: true,\n point: true,\n polygon: true,\n trash: true\n }}\n displayControlsDefault={false}\n onCreate={onChange}\n onUpdate={onChange}\n onDelete={onChange}\n position='bottom-left'\n />\n { props.geocoding && (\n <GeocodingControl\n apiKey={props.apiKey}\n marker={false}\n position='top-left'\n onSelection={onSelection}\n showFullGeometry={props.geocoding === 'polygon'}\n showResultMarkers={false}\n key={props.geocoding}\n />\n )}\n { props.navigation && (\n <NavigationControl />\n )}\n { props.fullscreen && (\n <FullscreenControl />\n )}\n { props.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\n cooperativeGestures: true,\n preserveDrawingBuffer: false,\n zoomDuration: DEFAULT_ZOOM_DELAY\n};\n\nexport default MapDraw;\n"],"names":["MapboxDraw","DEFAULT_BUFFER","DEFAULT_ZOOM_DELAY","GeometryTypes","MapDraw","props","loaded","setLoaded","useState","drawRef","useRef","mapRef","isValid","useCallback","detail","type","onChange","onSelection","mapStyleUrl","useMemo","style","useEffect","bbox","MapUtils","_","geometry","feature","jsxs","Map","maplibregl","jsx","DrawControl","GeocodingControl","NavigationControl","FullscreenControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAA,CAAA;AAAA,QAEnB5B,EAAM,cACNyB,gBAAAA,MAACI,GAAkB,CAAA,CAAA;AAAA,QAEnB7B,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGd;AAEAD,EAAQ,eAAe;AAAA,EACrB,QAAQH;AAAA,EACR,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,cAAcC;AAChB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/geospatial",
3
- "version": "2.2.21-beta.2",
3
+ "version": "2.2.21-beta.20",
4
4
  "description": "A package of components for all things map-related.",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@allmaps/maplibre": "^1.0.0-beta.25",
22
22
  "@mapbox/mapbox-gl-draw": "^1.4.3",
23
- "@maptiler/geocoding-control": "^1.2.2",
23
+ "@maptiler/geocoding-control": "^1.4.1",
24
24
  "@turf/turf": "^6.5.0",
25
25
  "mapbox-gl": "npm:empty-npm-package@1.0.0",
26
26
  "maplibre-gl": "^3.6.2",
@@ -109,7 +109,7 @@ const DEFAULT_ZOOM_DELAY = 1000;
109
109
  const GeometryTypes = {
110
110
  geometryCollection: 'GeometryCollection',
111
111
  point: 'Point',
112
- polygon: 'Polygon'
112
+ polygon: ['Polygon', 'MultiPolygon']
113
113
  };
114
114
 
115
115
  /**
@@ -138,7 +138,7 @@ const MapDraw = (props: Props) => {
138
138
  const { geometry: { type } } = detail;
139
139
 
140
140
  return (props.geocoding === 'point' && type === GeometryTypes.point)
141
- || (props.geocoding === 'polygon' && type === GeometryTypes.polygon);
141
+ || (props.geocoding === 'polygon' && GeometryTypes.polygon.includes(type));
142
142
  }, [props.geocoding]);
143
143
 
144
144
  /**
@@ -162,7 +162,9 @@ const MapDraw = (props: Props) => {
162
162
  onChange();
163
163
 
164
164
  // Call the onGeocoding selection callback
165
- props.onGeocodingSelection(detail);
165
+ if (props.onGeocodingSelection) {
166
+ props.onGeocodingSelection(detail);
167
+ }
166
168
  }
167
169
  }, [isValid, onChange, props.onGeocodingSelection]);
168
170
 
@@ -237,6 +239,7 @@ const MapDraw = (props: Props) => {
237
239
  onSelection={onSelection}
238
240
  showFullGeometry={props.geocoding === 'polygon'}
239
241
  showResultMarkers={false}
242
+ key={props.geocoding}
240
243
  />
241
244
  )}
242
245
  { props.navigation && (