@performant-software/geospatial 2.1.2-beta.3 → 2.1.2

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 (42) hide show
  1. package/dist/index.cjs12.js +1 -1
  2. package/dist/index.cjs17.js +1 -1
  3. package/dist/index.cjs18.js +1 -1
  4. package/dist/index.cjs19.js +1 -1
  5. package/dist/index.cjs204.js +1 -1
  6. package/dist/index.cjs205.js +1 -1
  7. package/dist/index.cjs23.js +1 -1
  8. package/dist/index.cjs230.js +1 -1
  9. package/dist/index.cjs230.js.map +1 -1
  10. package/dist/index.cjs231.js +1 -1
  11. package/dist/index.cjs231.js.map +1 -1
  12. package/dist/index.cjs59.js +1 -1
  13. package/dist/index.cjs59.js.map +1 -1
  14. package/dist/index.cjs60.js +1 -1
  15. package/dist/index.cjs60.js.map +1 -1
  16. package/dist/index.cjs61.js +1 -1
  17. package/dist/index.cjs61.js.map +1 -1
  18. package/dist/index.cjs8.js +1 -1
  19. package/dist/index.cjs8.js.map +1 -1
  20. package/dist/index.es12.js +1 -1
  21. package/dist/index.es17.js +1 -1
  22. package/dist/index.es18.js +2 -2
  23. package/dist/index.es19.js +2 -2
  24. package/dist/index.es204.js +1 -1
  25. package/dist/index.es205.js +1 -1
  26. package/dist/index.es23.js +1 -1
  27. package/dist/index.es230.js +6 -3
  28. package/dist/index.es230.js.map +1 -1
  29. package/dist/index.es231.js +3 -6
  30. package/dist/index.es231.js.map +1 -1
  31. package/dist/index.es55.js +2 -2
  32. package/dist/index.es59.js +2 -107
  33. package/dist/index.es59.js.map +1 -1
  34. package/dist/index.es60.js +107 -10
  35. package/dist/index.es60.js.map +1 -1
  36. package/dist/index.es61.js +10 -2
  37. package/dist/index.es61.js.map +1 -1
  38. package/dist/index.es8.js +34 -28
  39. package/dist/index.es8.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/components/MapDraw.js +11 -4
  42. package/types/components/MapDraw.js.flow +11 -4
@@ -1,5 +1,13 @@
1
- var e = { exports: {} };
1
+ import e from "react";
2
+ var t = {
3
+ color: void 0,
4
+ size: void 0,
5
+ className: void 0,
6
+ style: void 0,
7
+ attr: void 0
8
+ }, d = e.createContext && /* @__PURE__ */ e.createContext(t);
2
9
  export {
3
- e as __module
10
+ t as DefaultContext,
11
+ d as IconContext
4
12
  };
5
13
  //# sourceMappingURL=index.es61.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es61.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es61.js","sources":["../../../node_modules/react-icons/lib/iconContext.mjs"],"sourcesContent":["import React from \"react\";\nexport var DefaultContext = {\n color: undefined,\n size: undefined,\n className: undefined,\n style: undefined,\n attr: undefined\n};\nexport var IconContext = React.createContext && /*#__PURE__*/React.createContext(DefaultContext);"],"names":["DefaultContext","IconContext","React"],"mappings":";AACU,IAACA,IAAiB;AAAA,EAC1B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AACR,GACWC,IAAcC,EAAM,iBAA8BA,gBAAAA,EAAM,cAAcF,CAAc;","x_google_ignoreList":[0]}
package/dist/index.es8.js CHANGED
@@ -1,7 +1,7 @@
1
- import { j as r } from "./index.es15.js";
2
- import m from "./index.es12.js";
1
+ import { j as n } from "./index.es15.js";
2
+ import l from "./index.es12.js";
3
3
  import b from "./index.es17.js";
4
- import { useState as h, useRef as f, useCallback as n, useMemo as d, useEffect as R } from "react";
4
+ import { useState as h, useRef as g, useCallback as a, useMemo as d, useEffect as R } from "react";
5
5
  import { Map as D } from "./index.es13.js";
6
6
  import x from "./index.es20.js";
7
7
  import "./index.es21.js";
@@ -36,35 +36,40 @@ import O from "./index.es4.js";
36
36
  import S from "./index.es10.js";
37
37
  import "./index.es49.js";
38
38
  import { feature as E } from "./index.es50.js";
39
- m.constants.classes.CONTROL_BASE = "maplibregl-ctrl";
40
- m.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-";
41
- m.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group";
42
- const _ = 2, M = 1e3, a = {
39
+ l.constants.classes.CONTROL_BASE = "maplibregl-ctrl";
40
+ l.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-";
41
+ l.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group";
42
+ const _ = 2, w = 1e3, m = {
43
43
  geometryCollection: "GeometryCollection",
44
44
  point: "Point",
45
45
  polygon: "Polygon"
46
- }, U = (t) => {
47
- const [l, g] = h(!1), e = f(), c = f(), s = n(({ geometry: { type: o } }) => t.geocoding === "point" && o === a.point || t.geocoding === "polygon" && o === a.polygon, [t.geocoding]), i = n(() => t.onChange(e.current.getAll()), [t.onChange]), u = n(({ detail: o }) => {
48
- s(o) && (e.current.add(o.geometry), i(), t.onGeocodingSelection(o));
49
- }, [s, i, t.onGeocodingSelection]), p = d(() => `${t.mapStyle}?key=${t.apiKey}`, [t.apiKey, t.mapStyle]), y = d(() => ({ height: 500, width: "100%", ...t.style || {} }), [t.style]);
46
+ }, G = (t) => {
47
+ const [c, u] = h(!1), e = g(), s = g(), f = a((o) => {
48
+ if (!o)
49
+ return !1;
50
+ const { geometry: { type: i } } = o;
51
+ return t.geocoding === "point" && i === m.point || t.geocoding === "polygon" && i === m.polygon;
52
+ }, [t.geocoding]), r = a(() => t.onChange(e.current.getAll()), [t.onChange]), p = a(({ detail: o }) => {
53
+ f(o) && (e.current.add(o.geometry), r(), t.onGeocodingSelection(o));
54
+ }, [f, r, t.onGeocodingSelection]), y = d(() => `${t.mapStyle}?key=${t.apiKey}`, [t.apiKey, t.mapStyle]), C = d(() => ({ height: 500, width: "100%", ...t.style || {} }), [t.style]);
50
55
  return R(() => {
51
- if (l && t.data) {
56
+ if (c && t.data) {
52
57
  const o = S.getBoundingBox(t.data, t.buffer);
53
- o && c.current.fitBounds(o, { duration: t.zoomDuration }), t.data.type === a.geometryCollection ? x.each(t.data.geometries, (C) => {
54
- e.current.add(E(C));
58
+ o && s.current.fitBounds(o, { duration: t.zoomDuration }), t.data.type === m.geometryCollection ? x.each(t.data.geometries, (i) => {
59
+ e.current.add(E(i));
55
60
  }) : e.current.add(t.data);
56
61
  }
57
- }, [l, t.data]), /* @__PURE__ */ r.jsxs(
62
+ }, [c, t.data]), /* @__PURE__ */ n.jsxs(
58
63
  D,
59
64
  {
60
65
  attributionControl: !1,
61
- onLoad: () => g(!0),
66
+ onLoad: () => u(!0),
62
67
  mapLib: b,
63
- ref: c,
64
- style: y,
65
- mapStyle: p,
68
+ ref: s,
69
+ style: C,
70
+ mapStyle: y,
66
71
  children: [
67
- /* @__PURE__ */ r.jsx(
72
+ /* @__PURE__ */ n.jsx(
68
73
  L,
69
74
  {
70
75
  ref: e,
@@ -75,19 +80,20 @@ const _ = 2, M = 1e3, a = {
75
80
  trash: !0
76
81
  },
77
82
  displayControlsDefault: !1,
78
- onCreate: i,
79
- onUpdate: i,
80
- onDelete: i,
83
+ onCreate: r,
84
+ onUpdate: r,
85
+ onDelete: r,
81
86
  position: "bottom-left"
82
87
  }
83
88
  ),
84
- t.geocoding && /* @__PURE__ */ r.jsx(
89
+ t.geocoding && /* @__PURE__ */ n.jsx(
85
90
  O,
86
91
  {
87
92
  apiKey: t.apiKey,
88
93
  marker: !1,
89
94
  position: "top-left",
90
- onSelection: u,
95
+ onSelection: p,
96
+ showFullGeometry: t.geocoding === "polygon",
91
97
  showResultMarkers: !1
92
98
  }
93
99
  ),
@@ -96,11 +102,11 @@ const _ = 2, M = 1e3, a = {
96
102
  }
97
103
  );
98
104
  };
99
- U.defaultProps = {
105
+ G.defaultProps = {
100
106
  buffer: _,
101
- zoomDuration: M
107
+ zoomDuration: w
102
108
  };
103
109
  export {
104
- U as default
110
+ G as default
105
111
  };
106
112
  //# 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 } from 'react-map-gl';\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 * GeoJSON structured data to be displayed on the map.\n */\n data: GeometryCollection | FeatureCollection,\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 * 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 * 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(({ geometry: { type } }) => (\n (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 onLoad={() => setLoaded(true)}\n mapLib={maplibregl}\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 showResultMarkers={false}\n />\n )}\n { props.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\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","type","onChange","onSelection","detail","mapStyleUrl","useMemo","style","useEffect","bbox","MapUtils","_","geometry","feature","jsxs","Map","maplibregl","jsx","DrawControl","GeocodingControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBAA,EAAW,UAAU,QAAQ,eAAe;AAC5CA,EAAW,UAAU,QAAQ,iBAAiB;AAC9CA,EAAW,UAAU,QAAQ,gBAAgB;AAwD7C,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,CAAC,EAAE,UAAU,EAAE,MAAAC,EAAK,EAAA,MAC7CT,EAAM,cAAc,WAAWS,MAASX,EAAc,SACnDE,EAAM,cAAc,aAAaS,MAASX,EAAc,SAC3D,CAACE,EAAM,SAAS,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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,UAAUM;AAAA,YACV,UAAUA;AAAA,YACV,UAAUA;AAAA,YACV,UAAS;AAAA,UAAA;AAAA,QACX;AAAA,QACEV,EAAM,aACNyB,gBAAAA,EAAA;AAAA,UAACE;AAAA,UAAA;AAAA,YACC,QAAQ3B,EAAM;AAAA,YACd,QAAQ;AAAA,YACR,UAAS;AAAA,YACT,aAAAW;AAAA,YACA,mBAAmB;AAAA,UAAA;AAAA,QACrB;AAAA,QAEAX,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGd;AAEAD,EAAQ,eAAe;AAAA,EACrB,QAAQH;AAAA,EACR,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 } from 'react-map-gl';\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 * GeoJSON structured data to be displayed on the map.\n */\n data: GeometryCollection | FeatureCollection,\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 * 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 * 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 onLoad={() => setLoaded(true)}\n mapLib={maplibregl}\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.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBAA,EAAW,UAAU,QAAQ,eAAe;AAC5CA,EAAW,UAAU,QAAQ,iBAAiB;AAC9CA,EAAW,UAAU,QAAQ,gBAAgB;AAwD7C,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,EAAE,MAAAC,QAAWD;AAEvB,WAAAT,EAAM,cAAc,WAAWU,MAASZ,EAAc,SACxDE,EAAM,cAAc,aAAaU,MAASZ,EAAc;AAAA,EAAA,GAC7D,CAACE,EAAM,SAAS,CAAC,GAOdW,IAAWH,EAAY,MAAMR,EAAM,SAASI,EAAQ,QAAQ,OAAQ,CAAA,GAAG,CAACJ,EAAM,QAAQ,CAAC,GAOvFY,IAAcJ,EAAY,CAAC,EAAE,QAAAC,QAAa;AAC1C,IAAAF,EAAQE,CAAM,MAERL,EAAA,QAAQ,IAAIK,EAAO,QAAQ,GAG1BE,KAGTX,EAAM,qBAAqBS,CAAM;AAAA,KAElC,CAACF,GAASI,GAAUX,EAAM,oBAAoB,CAAC,GAO5Ca,IAAcC,EAAQ,MAAM,GAAGd,EAAM,QAAQ,QAAQA,EAAM,MAAM,IAAI,CAACA,EAAM,QAAQA,EAAM,QAAQ,CAAC,GAOnGe,IAAQD,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,mBAAmB;AAAA,UAAA;AAAA,QACrB;AAAA,QAEAA,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGd;AAEAD,EAAQ,eAAe;AAAA,EACrB,QAAQH;AAAA,EACR,cAAcC;AAChB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/geospatial",
3
- "version": "2.1.2-beta.3",
3
+ "version": "2.1.2",
4
4
  "description": "A package of components for all things map-related.",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs.js",
@@ -104,10 +104,16 @@ const MapDraw = (props: Props) => {
104
104
  *
105
105
  * @type {function({geometry: {type: *}}): *}
106
106
  */
107
- const isValid = useCallback(({ geometry: { type } }) => (
108
- (props.geocoding === 'point' && type === GeometryTypes.point)
109
- || (props.geocoding === 'polygon' && type === GeometryTypes.polygon)
110
- ), [props.geocoding]);
107
+ const isValid = useCallback((detail) => {
108
+ if (!detail) {
109
+ return false;
110
+ }
111
+
112
+ const { geometry: { type } } = detail;
113
+
114
+ return (props.geocoding === 'point' && type === GeometryTypes.point)
115
+ || (props.geocoding === 'polygon' && type === GeometryTypes.polygon);
116
+ }, [props.geocoding]);
111
117
 
112
118
  /**
113
119
  * Calls the onChange prop with all of the geometries in the current drawer.
@@ -200,6 +206,7 @@ const MapDraw = (props: Props) => {
200
206
  marker={false}
201
207
  position='top-left'
202
208
  onSelection={onSelection}
209
+ showFullGeometry={props.geocoding === 'polygon'}
203
210
  showResultMarkers={false}
204
211
  />
205
212
  )}
@@ -104,10 +104,16 @@ const MapDraw = (props: Props) => {
104
104
  *
105
105
  * @type {function({geometry: {type: *}}): *}
106
106
  */
107
- const isValid = useCallback(({ geometry: { type } }) => (
108
- (props.geocoding === 'point' && type === GeometryTypes.point)
109
- || (props.geocoding === 'polygon' && type === GeometryTypes.polygon)
110
- ), [props.geocoding]);
107
+ const isValid = useCallback((detail) => {
108
+ if (!detail) {
109
+ return false;
110
+ }
111
+
112
+ const { geometry: { type } } = detail;
113
+
114
+ return (props.geocoding === 'point' && type === GeometryTypes.point)
115
+ || (props.geocoding === 'polygon' && type === GeometryTypes.polygon);
116
+ }, [props.geocoding]);
111
117
 
112
118
  /**
113
119
  * Calls the onChange prop with all of the geometries in the current drawer.
@@ -200,6 +206,7 @@ const MapDraw = (props: Props) => {
200
206
  marker={false}
201
207
  position='top-left'
202
208
  onSelection={onSelection}
209
+ showFullGeometry={props.geocoding === 'polygon'}
203
210
  showResultMarkers={false}
204
211
  />
205
212
  )}