@performant-software/geospatial 2.2.21-beta.16 → 2.2.21-beta.18

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 (228) hide show
  1. package/dist/index.cjs14.js +1 -1
  2. package/dist/index.cjs15.js +1 -1
  3. package/dist/index.cjs16.js +1 -1
  4. package/dist/index.cjs18.js +3 -6
  5. package/dist/index.cjs18.js.map +1 -1
  6. package/dist/index.cjs182.js +1 -1
  7. package/dist/index.cjs182.js.map +1 -1
  8. package/dist/index.cjs183.js +1 -1
  9. package/dist/index.cjs183.js.map +1 -1
  10. package/dist/index.cjs184.js +4 -1
  11. package/dist/index.cjs184.js.map +1 -1
  12. package/dist/index.cjs185.js +1 -1
  13. package/dist/index.cjs185.js.map +1 -1
  14. package/dist/index.cjs186.js +1 -1
  15. package/dist/index.cjs186.js.map +1 -1
  16. package/dist/index.cjs187.js +1 -1
  17. package/dist/index.cjs187.js.map +1 -1
  18. package/dist/index.cjs188.js +1 -1
  19. package/dist/index.cjs188.js.map +1 -1
  20. package/dist/index.cjs189.js +1 -1
  21. package/dist/index.cjs189.js.map +1 -1
  22. package/dist/index.cjs19.js +2 -2
  23. package/dist/index.cjs190.js +1 -1
  24. package/dist/index.cjs190.js.map +1 -1
  25. package/dist/index.cjs191.js +1 -1
  26. package/dist/index.cjs191.js.map +1 -1
  27. package/dist/index.cjs192.js +1 -4
  28. package/dist/index.cjs192.js.map +1 -1
  29. package/dist/index.cjs193.js +1 -1
  30. package/dist/index.cjs193.js.map +1 -1
  31. package/dist/index.cjs194.js +1 -1
  32. package/dist/index.cjs194.js.map +1 -1
  33. package/dist/index.cjs195.js +1 -1
  34. package/dist/index.cjs195.js.map +1 -1
  35. package/dist/index.cjs196.js +1 -1
  36. package/dist/index.cjs196.js.map +1 -1
  37. package/dist/index.cjs197.js +1 -1
  38. package/dist/index.cjs197.js.map +1 -1
  39. package/dist/index.cjs198.js +1 -1
  40. package/dist/index.cjs198.js.map +1 -1
  41. package/dist/index.cjs199.js +1 -1
  42. package/dist/index.cjs199.js.map +1 -1
  43. package/dist/index.cjs200.js +1 -1
  44. package/dist/index.cjs200.js.map +1 -1
  45. package/dist/index.cjs201.js +1 -1
  46. package/dist/index.cjs201.js.map +1 -1
  47. package/dist/index.cjs202.js +1 -1
  48. package/dist/index.cjs202.js.map +1 -1
  49. package/dist/index.cjs203.js +1 -1
  50. package/dist/index.cjs203.js.map +1 -1
  51. package/dist/index.cjs204.js +1 -1
  52. package/dist/index.cjs204.js.map +1 -1
  53. package/dist/index.cjs207.js +1 -1
  54. package/dist/index.cjs208.js +1 -1
  55. package/dist/index.cjs209.js +1 -1
  56. package/dist/index.cjs227.js +1 -1
  57. package/dist/index.cjs232.js +1 -1
  58. package/dist/index.cjs234.js +1 -1
  59. package/dist/index.cjs234.js.map +1 -1
  60. package/dist/index.cjs235.js +1 -1
  61. package/dist/index.cjs235.js.map +1 -1
  62. package/dist/index.cjs236.js +1 -1
  63. package/dist/index.cjs236.js.map +1 -1
  64. package/dist/index.cjs238.js +1 -1
  65. package/dist/index.cjs241.js +1 -1
  66. package/dist/index.cjs244.js +1 -1
  67. package/dist/index.cjs247.js +1 -1
  68. package/dist/index.cjs249.js +1 -1
  69. package/dist/index.cjs25.js +1 -1
  70. package/dist/index.cjs252.js +1 -1
  71. package/dist/index.cjs253.js +1 -1
  72. package/dist/index.cjs256.js +1 -1
  73. package/dist/index.cjs256.js.map +1 -1
  74. package/dist/index.cjs257.js +1 -1
  75. package/dist/index.cjs257.js.map +1 -1
  76. package/dist/index.cjs258.js +1 -1
  77. package/dist/index.cjs51.js +1 -1
  78. package/dist/index.cjs55.js +1 -1
  79. package/dist/index.cjs57.js +1 -1
  80. package/dist/index.cjs61.js +1 -1
  81. package/dist/index.cjs62.js +1 -1
  82. package/dist/index.cjs66.js +1 -1
  83. package/dist/index.cjs66.js.map +1 -1
  84. package/dist/index.cjs67.js +1 -1
  85. package/dist/index.cjs67.js.map +1 -1
  86. package/dist/index.cjs68.js +1 -1
  87. package/dist/index.cjs68.js.map +1 -1
  88. package/dist/index.cjs69.js +1 -1
  89. package/dist/index.cjs69.js.map +1 -1
  90. package/dist/index.cjs70.js +1 -1
  91. package/dist/index.cjs70.js.map +1 -1
  92. package/dist/index.cjs71.js +1 -1
  93. package/dist/index.cjs71.js.map +1 -1
  94. package/dist/index.cjs72.js +1 -1
  95. package/dist/index.cjs72.js.map +1 -1
  96. package/dist/index.cjs73.js +1 -1
  97. package/dist/index.cjs73.js.map +1 -1
  98. package/dist/index.cjs74.js +1 -1
  99. package/dist/index.cjs74.js.map +1 -1
  100. package/dist/index.cjs75.js +1 -1
  101. package/dist/index.cjs75.js.map +1 -1
  102. package/dist/index.cjs76.js +1 -1
  103. package/dist/index.cjs76.js.map +1 -1
  104. package/dist/index.cjs77.js +1 -1
  105. package/dist/index.cjs77.js.map +1 -1
  106. package/dist/index.cjs78.js +1 -1
  107. package/dist/index.cjs78.js.map +1 -1
  108. package/dist/index.cjs79.js +1 -1
  109. package/dist/index.cjs79.js.map +1 -1
  110. package/dist/index.cjs8.js +1 -1
  111. package/dist/index.cjs8.js.map +1 -1
  112. package/dist/index.es14.js +1 -1
  113. package/dist/index.es15.js +9 -9
  114. package/dist/index.es16.js +1 -1
  115. package/dist/index.es18.js +2832 -15806
  116. package/dist/index.es18.js.map +1 -1
  117. package/dist/index.es182.js +7 -320
  118. package/dist/index.es182.js.map +1 -1
  119. package/dist/index.es183.js +144 -71
  120. package/dist/index.es183.js.map +1 -1
  121. package/dist/index.es184.js +12197 -3
  122. package/dist/index.es184.js.map +1 -1
  123. package/dist/index.es185.js +3 -18
  124. package/dist/index.es185.js.map +1 -1
  125. package/dist/index.es186.js +3 -13
  126. package/dist/index.es186.js.map +1 -1
  127. package/dist/index.es187.js +33 -28
  128. package/dist/index.es187.js.map +1 -1
  129. package/dist/index.es188.js +3 -7
  130. package/dist/index.es188.js.map +1 -1
  131. package/dist/index.es189.js +23 -2
  132. package/dist/index.es189.js.map +1 -1
  133. package/dist/index.es19.js +3 -3
  134. package/dist/index.es190.js +2 -10
  135. package/dist/index.es190.js.map +1 -1
  136. package/dist/index.es191.js +3 -150
  137. package/dist/index.es191.js.map +1 -1
  138. package/dist/index.es192.js +2 -12199
  139. package/dist/index.es192.js.map +1 -1
  140. package/dist/index.es193.js +34 -3
  141. package/dist/index.es193.js.map +1 -1
  142. package/dist/index.es194.js +14 -2
  143. package/dist/index.es194.js.map +1 -1
  144. package/dist/index.es195.js +13 -35
  145. package/dist/index.es195.js.map +1 -1
  146. package/dist/index.es196.js +11 -3
  147. package/dist/index.es196.js.map +1 -1
  148. package/dist/index.es197.js +319 -21
  149. package/dist/index.es197.js.map +1 -1
  150. package/dist/index.es198.js +77 -2
  151. package/dist/index.es198.js.map +1 -1
  152. package/dist/index.es199.js +5 -3
  153. package/dist/index.es199.js.map +1 -1
  154. package/dist/index.es200.js +18 -2
  155. package/dist/index.es200.js.map +1 -1
  156. package/dist/index.es201.js +10 -31
  157. package/dist/index.es201.js.map +1 -1
  158. package/dist/index.es202.js +31 -13
  159. package/dist/index.es202.js.map +1 -1
  160. package/dist/index.es203.js +4 -13
  161. package/dist/index.es203.js.map +1 -1
  162. package/dist/index.es204.js +2 -9
  163. package/dist/index.es204.js.map +1 -1
  164. package/dist/index.es207.js +1 -1
  165. package/dist/index.es208.js +1 -1
  166. package/dist/index.es209.js +1 -1
  167. package/dist/index.es227.js +1 -1
  168. package/dist/index.es232.js +1 -1
  169. package/dist/index.es234.js +3 -8
  170. package/dist/index.es234.js.map +1 -1
  171. package/dist/index.es235.js +6 -3
  172. package/dist/index.es235.js.map +1 -1
  173. package/dist/index.es236.js +6 -4
  174. package/dist/index.es236.js.map +1 -1
  175. package/dist/index.es238.js +1 -1
  176. package/dist/index.es241.js +1 -1
  177. package/dist/index.es244.js +1 -1
  178. package/dist/index.es247.js +2 -2
  179. package/dist/index.es249.js +1 -1
  180. package/dist/index.es25.js +1 -1
  181. package/dist/index.es252.js +1 -1
  182. package/dist/index.es253.js +1 -1
  183. package/dist/index.es256.js +15 -4
  184. package/dist/index.es256.js.map +1 -1
  185. package/dist/index.es257.js +4 -15
  186. package/dist/index.es257.js.map +1 -1
  187. package/dist/index.es258.js +2 -2
  188. package/dist/index.es51.js +7 -7
  189. package/dist/index.es55.js +1 -1
  190. package/dist/index.es57.js +12 -12
  191. package/dist/index.es59.js +2 -2
  192. package/dist/index.es61.js +1 -1
  193. package/dist/index.es62.js +1 -1
  194. package/dist/index.es65.js +2 -2
  195. package/dist/index.es66.js +55 -2
  196. package/dist/index.es66.js.map +1 -1
  197. package/dist/index.es67.js +48 -4
  198. package/dist/index.es67.js.map +1 -1
  199. package/dist/index.es68.js +37 -28
  200. package/dist/index.es68.js.map +1 -1
  201. package/dist/index.es69.js +11 -56
  202. package/dist/index.es69.js.map +1 -1
  203. package/dist/index.es70.js +14 -47
  204. package/dist/index.es70.js.map +1 -1
  205. package/dist/index.es71.js +29 -38
  206. package/dist/index.es71.js.map +1 -1
  207. package/dist/index.es72.js +11 -8
  208. package/dist/index.es72.js.map +1 -1
  209. package/dist/index.es73.js +13 -14
  210. package/dist/index.es73.js.map +1 -1
  211. package/dist/index.es74.js +12 -29
  212. package/dist/index.es74.js.map +1 -1
  213. package/dist/index.es75.js +27 -12
  214. package/dist/index.es75.js.map +1 -1
  215. package/dist/index.es76.js +52 -13
  216. package/dist/index.es76.js.map +1 -1
  217. package/dist/index.es77.js +58 -44
  218. package/dist/index.es77.js.map +1 -1
  219. package/dist/index.es78.js +2 -65
  220. package/dist/index.es78.js.map +1 -1
  221. package/dist/index.es79.js +2 -11
  222. package/dist/index.es79.js.map +1 -1
  223. package/dist/index.es8.js +36 -35
  224. package/dist/index.es8.js.map +1 -1
  225. package/dist/style.css +1 -1
  226. package/package.json +2 -2
  227. package/src/components/MapDraw.js +6 -3
  228. package/types/components/MapDraw.js.flow +6 -3
@@ -1,2 +1,2 @@
1
- "use strict";const i=require("./index.cjs17.js"),s=require("./index.cjs14.js"),C=require("./index.cjs19.js"),t=require("react"),f=require("./index.cjs15.js"),R=require("./index.cjs51.js"),b=require("./index.cjs22.js");require("./index.cjs23.js");require("./index.cjs24.js");require("./index.cjs25.js");require("./index.cjs26.js");require("./index.cjs27.js");require("./index.cjs28.js");require("./index.cjs29.js");require("./index.cjs30.js");require("./index.cjs31.js");require("./index.cjs32.js");require("./index.cjs33.js");require("./index.cjs34.js");require("./index.cjs35.js");require("./index.cjs36.js");require("./index.cjs37.js");require("./index.cjs38.js");require("./index.cjs39.js");require("./index.cjs40.js");require("./index.cjs41.js");require("./index.cjs42.js");require("./index.cjs43.js");require("./index.cjs44.js");require("./index.cjs45.js");require("./index.cjs46.js");require("./index.cjs47.js");require("./index.cjs48.js");require("./index.cjs49.js");const h=require("./index.cjs2.js"),D=require("./index.cjs4.js"),E=require("./index.cjs12.js");require("./index.cjs52.js");const G=require("./index.cjs53.js");s.constants.classes.CONTROL_BASE="maplibregl-ctrl";s.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-";s.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";const j=2,w=1e3,a={geometryCollection:"GeometryCollection",point:"Point",polygon:"Polygon"},q=e=>{const[l,d]=t.useState(!1),o=t.useRef(),c=t.useRef(),g=t.useCallback(r=>{if(!r)return!1;const{geometry:{type:u}}=r;return e.geocoding==="point"&&u===a.point||e.geocoding==="polygon"&&u===a.polygon},[e.geocoding]),n=t.useCallback(()=>e.onChange(o.current.getAll()),[e.onChange]),m=t.useCallback(({detail:r})=>{g(r)&&(o.current.add(r.geometry),n(),e.onGeocodingSelection(r))},[g,n,e.onGeocodingSelection]),y=t.useMemo(()=>`${e.mapStyle}?key=${e.apiKey}`,[e.apiKey,e.mapStyle]),x=t.useMemo(()=>({height:500,width:"100%",...e.style||{}}),[e.style]);return t.useEffect(()=>{if(l&&e.data){const r=E.getBoundingBox(e.data,e.buffer);r&&c.current.fitBounds(r,{duration:e.zoomDuration}),e.data.type===a.geometryCollection?b.each(e.data.geometries,u=>{o.current.add(G.feature(u))}):o.current.add(e.data)}},[l,e.data]),i.jsxRuntimeExports.jsxs(f.Map,{attributionControl:!1,cooperativeGestures:e.cooperativeGestures,mapLib:C.default,maxPitch:e.maxPitch,onLoad:()=>d(!0),preserveDrawingBuffer:e.preserveDrawingBuffer,ref:c,style:x,mapStyle:y,children:[i.jsxRuntimeExports.jsx(h,{ref:o,controls:{line_string:!0,point:!0,polygon:!0,trash:!0},displayControlsDefault:!1,onCreate:n,onUpdate:n,onDelete:n,position:"bottom-left"}),e.geocoding&&i.jsxRuntimeExports.jsx(D,{apiKey:e.apiKey,marker:!1,position:"top-left",onSelection:m,showFullGeometry:e.geocoding==="polygon",showResultMarkers:!1}),e.navigation&&i.jsxRuntimeExports.jsx(f.NavigationControl,{}),e.fullscreen&&i.jsxRuntimeExports.jsx(R.FullscreenControl,{}),e.children]})};q.defaultProps={buffer:j,cooperativeGestures:!0,preserveDrawingBuffer:!1,zoomDuration:w};module.exports=q;
1
+ "use strict";const i=require("./index.cjs17.js"),l=require("./index.cjs14.js"),C=require("./index.cjs19.js"),r=require("react"),f=require("./index.cjs15.js"),R=require("./index.cjs51.js"),b=require("./index.cjs22.js");require("./index.cjs23.js");require("./index.cjs24.js");require("./index.cjs25.js");require("./index.cjs26.js");require("./index.cjs27.js");require("./index.cjs28.js");require("./index.cjs29.js");require("./index.cjs30.js");require("./index.cjs31.js");require("./index.cjs32.js");require("./index.cjs33.js");require("./index.cjs34.js");require("./index.cjs35.js");require("./index.cjs36.js");require("./index.cjs37.js");require("./index.cjs38.js");require("./index.cjs39.js");require("./index.cjs40.js");require("./index.cjs41.js");require("./index.cjs42.js");require("./index.cjs43.js");require("./index.cjs44.js");require("./index.cjs45.js");require("./index.cjs46.js");require("./index.cjs47.js");require("./index.cjs48.js");require("./index.cjs49.js");const h=require("./index.cjs2.js"),D=require("./index.cjs4.js"),G=require("./index.cjs12.js");require("./index.cjs52.js");const E=require("./index.cjs53.js");l.constants.classes.CONTROL_BASE="maplibregl-ctrl";l.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-";l.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";const j=2,w=1e3,a={geometryCollection:"GeometryCollection",point:"Point",polygon:["Polygon","MultiPolygon"]},d=e=>{const[s,q]=r.useState(!1),o=r.useRef(),c=r.useRef(),g=r.useCallback(t=>{if(!t)return!1;const{geometry:{type:u}}=t;return e.geocoding==="point"&&u===a.point||e.geocoding==="polygon"&&a.polygon.includes(u)},[e.geocoding]),n=r.useCallback(()=>e.onChange(o.current.getAll()),[e.onChange]),m=r.useCallback(({detail:t})=>{g(t)&&(o.current.add(t.geometry),n(),e.onGeocodingSelection&&e.onGeocodingSelection(t))},[g,n,e.onGeocodingSelection]),y=r.useMemo(()=>`${e.mapStyle}?key=${e.apiKey}`,[e.apiKey,e.mapStyle]),x=r.useMemo(()=>({height:500,width:"100%",...e.style||{}}),[e.style]);return r.useEffect(()=>{if(s&&e.data){const t=G.getBoundingBox(e.data,e.buffer);t&&c.current.fitBounds(t,{duration:e.zoomDuration}),e.data.type===a.geometryCollection?b.each(e.data.geometries,u=>{o.current.add(E.feature(u))}):o.current.add(e.data)}},[s,e.data]),i.jsxRuntimeExports.jsxs(f.Map,{attributionControl:!1,cooperativeGestures:e.cooperativeGestures,mapLib:C.default,maxPitch:e.maxPitch,onLoad:()=>q(!0),preserveDrawingBuffer:e.preserveDrawingBuffer,ref:c,style:x,mapStyle:y,children:[i.jsxRuntimeExports.jsx(h,{ref:o,controls:{line_string:!0,point:!0,polygon:!0,trash:!0},displayControlsDefault:!1,onCreate:n,onUpdate:n,onDelete:n,position:"bottom-left"}),e.geocoding&&i.jsxRuntimeExports.jsx(D,{apiKey:e.apiKey,marker:!1,position:"top-left",onSelection:m,showFullGeometry:e.geocoding==="polygon",showResultMarkers:!1},e.geocoding),e.navigation&&i.jsxRuntimeExports.jsx(f.NavigationControl,{}),e.fullscreen&&i.jsxRuntimeExports.jsx(R.FullscreenControl,{}),e.children]})};d.defaultProps={buffer:j,cooperativeGestures:!0,preserveDrawingBuffer:!1,zoomDuration:w};module.exports=d;
2
2
  //# sourceMappingURL=index.cjs8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs8.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":"4mCAsBAA,EAAW,UAAU,QAAQ,aAAe,kBAC5CA,EAAW,UAAU,QAAQ,eAAiB,mBAC9CA,EAAW,UAAU,QAAQ,cAAgB,wBAiF7C,MAAMC,EAAiB,EACjBC,EAAqB,IAErBC,EAAgB,CACpB,mBAAoB,qBACpB,MAAO,QACP,QAAS,SACX,EAMMC,EAAWC,GAAiB,CAChC,KAAM,CAACC,EAAQC,CAAS,EAAIC,WAAS,EAAK,EAEpCC,EAAUC,EAAAA,SACVC,EAASD,EAAAA,SAUTE,EAAUC,cAAaC,GAAW,CACtC,GAAI,CAACA,EACI,MAAA,GAGT,KAAM,CAAE,SAAU,CAAE,KAAAC,IAAWD,EAEvB,OAAAT,EAAM,YAAc,SAAWU,IAASZ,EAAc,OACxDE,EAAM,YAAc,WAAaU,IAASZ,EAAc,OAAA,EAC7D,CAACE,EAAM,SAAS,CAAC,EAOdW,EAAWH,EAAA,YAAY,IAAMR,EAAM,SAASI,EAAQ,QAAQ,OAAQ,CAAA,EAAG,CAACJ,EAAM,QAAQ,CAAC,EAOvFY,EAAcJ,EAAAA,YAAY,CAAC,CAAE,OAAAC,KAAa,CAC1CF,EAAQE,CAAM,IAERL,EAAA,QAAQ,IAAIK,EAAO,QAAQ,EAG1BE,IAGTX,EAAM,qBAAqBS,CAAM,IAElC,CAACF,EAASI,EAAUX,EAAM,oBAAoB,CAAC,EAO5Ca,EAAcC,EAAAA,QAAQ,IAAM,GAAGd,EAAM,QAAQ,QAAQA,EAAM,MAAM,GAAI,CAACA,EAAM,OAA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AAA,kBAAkB,CAAA,CAAA,EAEnB7B,EAAM,QAAA,CAAA,CAAA,CAGd,EAEAD,EAAQ,aAAe,CACrB,OAAQH,EACR,oBAAqB,GACrB,sBAAuB,GACvB,aAAcC,CAChB"}
1
+ {"version":3,"file":"index.cjs8.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":"4mCAsBAA,EAAW,UAAU,QAAQ,aAAe,kBAC5CA,EAAW,UAAU,QAAQ,eAAiB,mBAC9CA,EAAW,UAAU,QAAQ,cAAgB,wBAiF7C,MAAMC,EAAiB,EACjBC,EAAqB,IAErBC,EAAgB,CACpB,mBAAoB,qBACpB,MAAO,QACP,QAAS,CAAC,UAAW,cAAc,CACrC,EAMMC,EAAWC,GAAiB,CAChC,KAAM,CAACC,EAAQC,CAAS,EAAIC,WAAS,EAAK,EAEpCC,EAAUC,EAAAA,SACVC,EAASD,EAAAA,SAUTE,EAAUC,cAAaC,GAAW,CACtC,GAAI,CAACA,EACI,MAAA,GAGT,KAAM,CAAE,SAAU,CAAE,KAAAC,IAAWD,EAE/B,OAAQT,EAAM,YAAc,SAAWU,IAASZ,EAAc,OACxDE,EAAM,YAAc,WAAaF,EAAc,QAAQ,SAASY,CAAI,CAAA,EACzE,CAACV,EAAM,SAAS,CAAC,EAOdW,EAAWH,EAAA,YAAY,IAAMR,EAAM,SAASI,EAAQ,QAAQ,OAAQ,CAAA,EAAG,CAACJ,EAAM,QAAQ,CAAC,EAOvFY,EAAcJ,EAAAA,YAAY,CAAC,CAAE,OAAAC,KAAa,CAC1CF,EAAQE,CAAM,IAERL,EAAA,QAAQ,IAAIK,EAAO,QAAQ,EAG1BE,IAGLX,EAAM,sBACRA,EAAM,qBAAqBS,CAAM,IAGpC,CAACF,EAASI,EAAUX,E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Ac,UACtC,kBAAmB,EAAA,EACdA,EAAM,SACb,EAEAA,EAAM,YACNyB,wBAACG,EAAAA,kBAAkB,CAAA,CAAA,EAEnB5B,EAAM,YACNyB,wBAACI,EAAAA,kBAAkB,CAAA,CAAA,EAEnB7B,EAAM,QAAA,CAAA,CAAA,CAGd,EAEAD,EAAQ,aAAe,CACrB,OAAQH,EACR,oBAAqB,GACrB,sBAAuB,GACvB,aAAcC,CAChB"}
@@ -1,5 +1,5 @@
1
1
  import { commonjsGlobal as Je, getDefaultExportFromCjs as oo } from "./index.es58.js";
2
- import { __module as Zn } from "./index.es65.js";
2
+ import { __module as Zn } from "./index.es59.js";
3
3
  (function(Wn, ao) {
4
4
  (function(ze, de) {
5
5
  Wn.exports = de();
@@ -1,19 +1,19 @@
1
1
  import * as i from "react";
2
- import p from "./index.es69.js";
2
+ import p from "./index.es66.js";
3
+ import "./index.es67.js";
4
+ import "./index.es68.js";
5
+ import "./index.es69.js";
3
6
  import "./index.es70.js";
4
7
  import "./index.es71.js";
5
- import "./index.es72.js";
8
+ import m from "./index.es72.js";
6
9
  import "./index.es73.js";
7
- import "./index.es74.js";
8
- import m from "./index.es75.js";
9
- import "./index.es76.js";
10
- import a from "./index.es77.js";
11
- import n from "./index.es78.js";
12
- import { useMap as e } from "./index.es79.js";
10
+ import a from "./index.es76.js";
11
+ import n from "./index.es77.js";
12
+ import { useMap as e } from "./index.es74.js";
13
13
  function C() {
14
14
  return e();
15
15
  }
16
- const f = import("./index.es68.js").then((o) => o.i), N = i.forwardRef(function(r, t) {
16
+ const f = import("./index.es75.js").then((o) => o.i), N = i.forwardRef(function(r, t) {
17
17
  return p(r, t, f);
18
18
  }), R = m, S = a, b = n;
19
19
  export {
@@ -1,5 +1,5 @@
1
1
  import { useContext as p, useMemo as r, useEffect as m } from "react";
2
- import { MapContext as d } from "./index.es69.js";
2
+ import { MapContext as d } from "./index.es66.js";
3
3
  function x(c, o, n, l) {
4
4
  const e = p(d), t = r(() => c(e), []);
5
5
  return m(() => {