@performant-software/geospatial 3.1.7-beta.4 → 3.1.7-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs14.js +1 -1
- package/dist/index.cjs15.js +1 -1
- package/dist/index.cjs16.js +1 -1
- package/dist/index.cjs17.js +1 -1
- package/dist/index.cjs18.js +1 -1
- package/dist/index.cjs186.js +1 -1
- package/dist/index.cjs186.js.map +1 -1
- package/dist/index.cjs187.js +1 -1
- package/dist/index.cjs187.js.map +1 -1
- package/dist/index.cjs188.js +1 -1
- package/dist/index.cjs188.js.map +1 -1
- package/dist/index.cjs189.js +1 -1
- package/dist/index.cjs189.js.map +1 -1
- package/dist/index.cjs19.js +1 -1
- package/dist/index.cjs190.js +1 -1
- package/dist/index.cjs190.js.map +1 -1
- package/dist/index.cjs191.js +1 -1
- package/dist/index.cjs191.js.map +1 -1
- package/dist/index.cjs192.js +1 -1
- package/dist/index.cjs192.js.map +1 -1
- package/dist/index.cjs193.js +1 -1
- package/dist/index.cjs193.js.map +1 -1
- package/dist/index.cjs194.js +1 -1
- package/dist/index.cjs194.js.map +1 -1
- package/dist/index.cjs195.js +1 -1
- package/dist/index.cjs195.js.map +1 -1
- package/dist/index.cjs196.js +1 -1
- package/dist/index.cjs196.js.map +1 -1
- package/dist/index.cjs197.js +1 -1
- package/dist/index.cjs197.js.map +1 -1
- package/dist/index.cjs198.js +1 -1
- package/dist/index.cjs198.js.map +1 -1
- package/dist/index.cjs199.js +1 -1
- package/dist/index.cjs199.js.map +1 -1
- package/dist/index.cjs20.js +1 -1
- package/dist/index.cjs200.js +1 -1
- package/dist/index.cjs200.js.map +1 -1
- package/dist/index.cjs201.js +1 -1
- package/dist/index.cjs201.js.map +1 -1
- package/dist/index.cjs202.js +1 -1
- package/dist/index.cjs202.js.map +1 -1
- package/dist/index.cjs203.js +1 -1
- package/dist/index.cjs203.js.map +1 -1
- package/dist/index.cjs204.js +1 -1
- package/dist/index.cjs204.js.map +1 -1
- package/dist/index.cjs205.js +1 -1
- package/dist/index.cjs205.js.map +1 -1
- package/dist/index.cjs206.js +1 -1
- package/dist/index.cjs206.js.map +1 -1
- package/dist/index.cjs207.js +1 -1
- package/dist/index.cjs207.js.map +1 -1
- package/dist/index.cjs208.js +1 -1
- package/dist/index.cjs208.js.map +1 -1
- package/dist/index.cjs21.js +1 -1
- package/dist/index.cjs211.js +1 -1
- package/dist/index.cjs212.js +1 -1
- package/dist/index.cjs213.js +1 -1
- package/dist/index.cjs22.js +1 -1
- package/dist/index.cjs23.js +1 -1
- package/dist/index.cjs231.js +1 -1
- package/dist/index.cjs236.js +7 -1
- package/dist/index.cjs236.js.map +1 -1
- package/dist/index.cjs237.js +1 -1
- package/dist/index.cjs237.js.map +1 -1
- package/dist/index.cjs238.js +1 -7
- package/dist/index.cjs238.js.map +1 -1
- package/dist/index.cjs239.js +1 -1
- package/dist/index.cjs239.js.map +1 -1
- package/dist/index.cjs24.js +1 -1
- package/dist/index.cjs240.js +1 -1
- package/dist/index.cjs240.js.map +1 -1
- package/dist/index.cjs241.js +1 -1
- package/dist/index.cjs241.js.map +1 -1
- package/dist/index.cjs242.js +1 -1
- package/dist/index.cjs242.js.map +1 -1
- package/dist/index.cjs244.js +1 -1
- package/dist/index.cjs247.js +1 -1
- package/dist/index.cjs253.js +1 -1
- package/dist/index.cjs259.js +1 -1
- package/dist/index.cjs264.js +1 -1
- package/dist/index.cjs28.js +1 -1
- package/dist/index.cjs29.js +1 -1
- package/dist/index.cjs31.js +1 -1
- package/dist/index.cjs33.js +1 -1
- package/dist/index.cjs34.js +1 -1
- package/dist/index.cjs38.js +1 -1
- package/dist/index.cjs68.js +1 -1
- package/dist/index.cjs70.js +1 -1
- package/dist/index.cjs77.js +1 -1
- package/dist/index.cjs77.js.map +1 -1
- package/dist/index.cjs78.js +1 -1
- package/dist/index.cjs78.js.map +1 -1
- package/dist/index.cjs79.js +1 -1
- package/dist/index.cjs79.js.map +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs80.js +1 -1
- package/dist/index.cjs80.js.map +1 -1
- package/dist/index.cjs81.js +1 -1
- package/dist/index.cjs81.js.map +1 -1
- package/dist/index.es14.js +2 -2
- package/dist/index.es15.js +4 -4
- package/dist/index.es16.js +3 -3
- package/dist/index.es17.js +3 -3
- package/dist/index.es18.js +1 -1
- package/dist/index.es186.js +144 -239
- package/dist/index.es186.js.map +1 -1
- package/dist/index.es187.js +6 -42
- package/dist/index.es187.js.map +1 -1
- package/dist/index.es188.js +5 -3
- package/dist/index.es188.js.map +1 -1
- package/dist/index.es189.js +3 -13
- package/dist/index.es189.js.map +1 -1
- package/dist/index.es19.js +1 -1
- package/dist/index.es190.js +3 -13
- package/dist/index.es190.js.map +1 -1
- package/dist/index.es191.js +33 -28
- package/dist/index.es191.js.map +1 -1
- package/dist/index.es192.js +3 -16
- package/dist/index.es192.js.map +1 -1
- package/dist/index.es193.js +22 -4
- package/dist/index.es193.js.map +1 -1
- package/dist/index.es194.js +2 -150
- package/dist/index.es194.js.map +1 -1
- package/dist/index.es195.js +3 -9
- package/dist/index.es195.js.map +1 -1
- package/dist/index.es196.js +2 -7
- package/dist/index.es196.js.map +1 -1
- package/dist/index.es197.js +33 -3
- package/dist/index.es197.js.map +1 -1
- package/dist/index.es198.js +14 -2
- package/dist/index.es198.js.map +1 -1
- package/dist/index.es199.js +13 -35
- package/dist/index.es199.js.map +1 -1
- package/dist/index.es20.js +1 -1
- package/dist/index.es200.js +11 -3
- package/dist/index.es200.js.map +1 -1
- package/dist/index.es201.js +242 -22
- package/dist/index.es201.js.map +1 -1
- package/dist/index.es202.js +45 -2
- package/dist/index.es202.js.map +1 -1
- package/dist/index.es203.js +5 -3
- package/dist/index.es203.js.map +1 -1
- package/dist/index.es204.js +13 -2
- package/dist/index.es204.js.map +1 -1
- package/dist/index.es205.js +10 -30
- package/dist/index.es205.js.map +1 -1
- package/dist/index.es206.js +31 -13
- package/dist/index.es206.js.map +1 -1
- package/dist/index.es207.js +13 -13
- package/dist/index.es207.js.map +1 -1
- package/dist/index.es208.js +4 -8
- package/dist/index.es208.js.map +1 -1
- package/dist/index.es21.js +1 -1
- package/dist/index.es211.js +1 -1
- package/dist/index.es212.js +1 -1
- package/dist/index.es213.js +1 -1
- package/dist/index.es22.js +1 -1
- package/dist/index.es23.js +1 -1
- package/dist/index.es231.js +1 -1
- package/dist/index.es236.js +7506 -20
- package/dist/index.es236.js.map +1 -1
- package/dist/index.es237.js +2 -23
- package/dist/index.es237.js.map +1 -1
- package/dist/index.es238.js +3 -7507
- package/dist/index.es238.js.map +1 -1
- package/dist/index.es239.js +8 -2
- package/dist/index.es239.js.map +1 -1
- package/dist/index.es24.js +1 -1
- package/dist/index.es240.js +21 -3
- package/dist/index.es240.js.map +1 -1
- package/dist/index.es241.js +22 -5
- package/dist/index.es241.js.map +1 -1
- package/dist/index.es242.js +4 -6
- package/dist/index.es242.js.map +1 -1
- package/dist/index.es244.js +1 -1
- package/dist/index.es247.js +1 -1
- package/dist/index.es253.js +2 -2
- package/dist/index.es259.js +1 -1
- package/dist/index.es264.js +2 -2
- package/dist/index.es28.js +2 -2
- package/dist/index.es29.js +2 -2
- package/dist/index.es31.js +1 -1
- package/dist/index.es33.js +2 -2
- package/dist/index.es34.js +2 -2
- package/dist/index.es38.js +1 -1
- package/dist/index.es68.js +1 -1
- package/dist/index.es70.js +12 -12
- package/dist/index.es77.js +104 -1991
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +10 -6
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +1993 -2
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es8.js +43 -47
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es80.js +5 -105
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +2 -10
- package/dist/index.es81.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MapDraw.js +6 -21
- package/types/components/MapDraw.js.flow +6 -21
package/dist/index.es8.js.map
CHANGED
|
@@ -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, {\n FullscreenControl,\n type MapboxMap,\n NavigationControl\n} from 'react-map-gl/maplibre';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\nimport GeocodingControl from './GeocodingControl';\nimport MapUtils from '../utils/Map';\n\nimport '@maptiler/geocoding-control/style.css';\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(() => {\n console.log(\"fired callback\");\n console.log(drawRef.current.getAll());\n props.onChange(drawRef.current.getAll());\n }, [props.onChange]);\n\n /**\n * Adds the selected geometry to the map.\n *\n * @type {(function(evt: *): void)|*}\n */\n const onSelection = useCallback((evt) => {\n console.log(evt);\n const { detail } = evt;\n if (isValid(detail)) {\n console.log(\"valid\");\n console.log(detail);\n // Add the geometry to the map\n console.log(\"before add\");\n console.log(drawRef.current.getAll());\n drawRef.current.add(detail.geometry);\n console.log(\"after add\");\n console.log(drawRef.current.getAll());\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 } else {\n console.log(\"invalid\");\n console.log(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 key={props.geocoding}\n marker={false}\n pickedResultStyle={props.geocoding === 'polygon' ? 'full-geometry' : 'marker-only'}\n position='top-left'\n onSelection={onSelection}\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","evt","mapStyleUrl","useMemo","style","useEffect","bbox","MapUtils","_","geometry","feature","jsxs","Map","maplibregl","jsx","DrawControl","GeocodingControl","NavigationControl","FullscreenControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BAA,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,CAAC,WAAW,cAAc;AACrC,GAMMC,IAAU,CAACC,MAAiB;AAChC,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAUC,EAAA,GACVC,IAASD,EAAA,GAUTE,IAAUC,EAAY,CAACC,MAAW;AACtC,QAAI,CAACA;AACH,aAAO;AAGT,UAAM,EAAE,UAAU,EAAE,MAAAC,EAAA,MAAWD;AAE/B,WAAQT,EAAM,cAAc,WAAWU,MAASZ,EAAc,SACxDE,EAAM,cAAc,aAAaF,EAAc,QAAQ,SAASY,CAAI;AAAA,EAC5E,GAAG,CAACV,EAAM,SAAS,CAAC,GAOdW,IAAWH,EAAY,MAAM;AACjC,YAAQ,IAAI,gBAAgB,GAC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;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, {\n FullscreenControl,\n type MapboxMap,\n NavigationControl\n} from 'react-map-gl/maplibre';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\nimport GeocodingControl from './GeocodingControl';\nimport MapUtils from '../utils/Map';\n\nimport '@maptiler/geocoding-control/style.css';\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({feature: *}): void)|*}\n */\n const onSelection = useCallback(({ feature }) => {\n if (isValid(feature)) {\n // Add the geometry to the map\n drawRef.current.add(feature.geometry);\n\n // Trigger the onChange prop\n onChange();\n\n // Call the onGeocoding selection callback\n if (props.onGeocodingSelection) {\n props.onGeocodingSelection(feature);\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 key={props.geocoding}\n marker={false}\n pickedResultStyle={props.geocoding === 'polygon' ? 'full-geometry' : 'marker-only'}\n position='top-left'\n onSelection={onSelection}\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","feature","mapStyleUrl","useMemo","style","useEffect","bbox","MapUtils","_","geometry","jsxs","Map","maplibregl","jsx","DrawControl","GeocodingControl","NavigationControl","FullscreenControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BAA,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,CAAC,WAAW,cAAc;AACrC,GAMMC,IAAU,CAACC,MAAiB;AAChC,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAUC,EAAA,GACVC,IAASD,EAAA,GAUTE,IAAUC,EAAY,CAACC,MAAW;AACtC,QAAI,CAACA;AACH,aAAO;AAGT,UAAM,EAAE,UAAU,EAAE,MAAAC,EAAA,MAAWD;AAE/B,WAAQT,EAAM,cAAc,WAAWU,MAASZ,EAAc,SACxDE,EAAM,cAAc,aAAaF,EAAc,QAAQ,SAASY,CAAI;AAAA,EAC5E,GAAG,CAACV,EAAM,SAAS,CAAC,GAOdW,IAAWH,EAAY,MAAMR,EAAM,SAASI,EAAQ,QAAQ,OAAA,CAAQ,GAAG,CAACJ,EAAM,QAAQ,CAAC,GAOvFY,IAAcJ,EAAY,CAAC,EAAE,SAAAK,QAAc;AAC/C,IAAIN,EAAQM,CAAO,MAEjBT,EAAQ,QAAQ,IAAIS,EAAQ,QAAQ,GAGpCF,EAAA,GAGIX,EAAM,wBACRA,EAAM,qBAAqBa,CAAO;AA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B;AAAA,YACxB,UAAUO;AAAA,YACV,UAAUA;AAAA,YACV,UAAUA;AAAA,YACV,UAAS;AAAA,UAAA;AAAA,QAAA;AAAA,QAETX,EAAM,aACNyB,gBAAAA,EAAAA;AAAAA,UAACE;AAAA,UAAA;AAAA,YACC,QAAQ3B,EAAM;AAAA,YAEd,QAAQ;AAAA,YACR,mBAAmBA,EAAM,cAAc,YAAY,kBAAkB;AAAA,YACrE,UAAS;AAAA,YACT,aAAAY;AAAA,YACA,mBAAmB;AAAA,UAAA;AAAA,UALdZ,EAAM;AAAA,QAAA;AAAA,QAQbA,EAAM,cACNyB,gBAAAA,MAACG,GAAA,CAAA,CAAkB;AAAA,QAEnB5B,EAAM,cACNyB,gBAAAA,MAACI,GAAA,CAAA,CAAkB;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/dist/index.es80.js
CHANGED
|
@@ -1,109 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function v(t, e) {
|
|
5
|
-
if (t == null) return {};
|
|
6
|
-
var r = y(t, e), n, i;
|
|
7
|
-
if (Object.getOwnPropertySymbols) {
|
|
8
|
-
var o = Object.getOwnPropertySymbols(t);
|
|
9
|
-
for (i = 0; i < o.length; i++)
|
|
10
|
-
n = o[i], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(t, n) && (r[n] = t[n]);
|
|
11
|
-
}
|
|
12
|
-
return r;
|
|
13
|
-
}
|
|
14
|
-
function y(t, e) {
|
|
15
|
-
if (t == null) return {};
|
|
16
|
-
var r = {};
|
|
17
|
-
for (var n in t)
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
|
19
|
-
if (e.indexOf(n) >= 0) continue;
|
|
20
|
-
r[n] = t[n];
|
|
21
|
-
}
|
|
22
|
-
return r;
|
|
23
|
-
}
|
|
24
|
-
function c() {
|
|
25
|
-
return c = Object.assign ? Object.assign.bind() : function(t) {
|
|
26
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
27
|
-
var r = arguments[e];
|
|
28
|
-
for (var n in r)
|
|
29
|
-
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
}, c.apply(this, arguments);
|
|
33
|
-
}
|
|
34
|
-
function m(t, e) {
|
|
35
|
-
var r = Object.keys(t);
|
|
36
|
-
if (Object.getOwnPropertySymbols) {
|
|
37
|
-
var n = Object.getOwnPropertySymbols(t);
|
|
38
|
-
e && (n = n.filter(function(i) {
|
|
39
|
-
return Object.getOwnPropertyDescriptor(t, i).enumerable;
|
|
40
|
-
})), r.push.apply(r, n);
|
|
41
|
-
}
|
|
42
|
-
return r;
|
|
43
|
-
}
|
|
44
|
-
function u(t) {
|
|
45
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
46
|
-
var r = arguments[e] != null ? arguments[e] : {};
|
|
47
|
-
e % 2 ? m(Object(r), !0).forEach(function(n) {
|
|
48
|
-
j(t, n, r[n]);
|
|
49
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : m(Object(r)).forEach(function(n) {
|
|
50
|
-
Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
function j(t, e, r) {
|
|
56
|
-
return e = P(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
57
|
-
}
|
|
58
|
-
function P(t) {
|
|
59
|
-
var e = h(t, "string");
|
|
60
|
-
return typeof e == "symbol" ? e : e + "";
|
|
61
|
-
}
|
|
62
|
-
function h(t, e) {
|
|
63
|
-
if (typeof t != "object" || !t) return t;
|
|
64
|
-
var r = t[Symbol.toPrimitive];
|
|
65
|
-
if (r !== void 0) {
|
|
66
|
-
var n = r.call(t, e);
|
|
67
|
-
if (typeof n != "object") return n;
|
|
68
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
69
|
-
}
|
|
70
|
-
return (e === "string" ? String : Number)(t);
|
|
71
|
-
}
|
|
72
|
-
function p(t) {
|
|
73
|
-
return t && t.map((e, r) => /* @__PURE__ */ l.createElement(e.tag, u({
|
|
74
|
-
key: r
|
|
75
|
-
}, e.attr), p(e.child)));
|
|
76
|
-
}
|
|
77
|
-
function _(t) {
|
|
78
|
-
return (e) => /* @__PURE__ */ l.createElement(w, c({
|
|
79
|
-
attr: u({}, t.attr)
|
|
80
|
-
}, e), p(t.child));
|
|
81
|
-
}
|
|
82
|
-
function w(t) {
|
|
83
|
-
var e = (r) => {
|
|
84
|
-
var {
|
|
85
|
-
attr: n,
|
|
86
|
-
size: i,
|
|
87
|
-
title: o
|
|
88
|
-
} = t, b = v(t, g), f = i || r.size || "1em", a;
|
|
89
|
-
return r.className && (a = r.className), t.className && (a = (a ? a + " " : "") + t.className), /* @__PURE__ */ l.createElement("svg", c({
|
|
90
|
-
stroke: "currentColor",
|
|
91
|
-
fill: "currentColor",
|
|
92
|
-
strokeWidth: "0"
|
|
93
|
-
}, r.attr, n, b, {
|
|
94
|
-
className: a,
|
|
95
|
-
style: u(u({
|
|
96
|
-
color: t.color || r.color
|
|
97
|
-
}, r.style), t.style),
|
|
98
|
-
height: f,
|
|
99
|
-
width: f,
|
|
100
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
101
|
-
}), o && /* @__PURE__ */ l.createElement("title", null, o), t.children);
|
|
102
|
-
};
|
|
103
|
-
return s !== void 0 ? /* @__PURE__ */ l.createElement(s.Consumer, null, (r) => e(r)) : e(O);
|
|
1
|
+
var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2
|
+
function l(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
104
4
|
}
|
|
105
5
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
6
|
+
o as commonjsGlobal,
|
|
7
|
+
l as getDefaultExportFromCjs
|
|
108
8
|
};
|
|
109
9
|
//# sourceMappingURL=index.es80.js.map
|
package/dist/index.es80.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es80.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.es80.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/index.es81.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
var a = { exports: {} };
|
|
9
2
|
export {
|
|
10
|
-
|
|
11
|
-
d as IconContext
|
|
3
|
+
a as __module
|
|
12
4
|
};
|
|
13
5
|
//# sourceMappingURL=index.es81.js.map
|
package/dist/index.es81.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es81.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.es81.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/package.json
CHANGED
|
@@ -151,40 +151,25 @@ const MapDraw = (props: Props) => {
|
|
|
151
151
|
*
|
|
152
152
|
* @type {(function(): void)|*}
|
|
153
153
|
*/
|
|
154
|
-
const onChange = useCallback(() =>
|
|
155
|
-
console.log("fired callback");
|
|
156
|
-
console.log(drawRef.current.getAll());
|
|
157
|
-
props.onChange(drawRef.current.getAll());
|
|
158
|
-
}, [props.onChange]);
|
|
154
|
+
const onChange = useCallback(() => props.onChange(drawRef.current.getAll()), [props.onChange]);
|
|
159
155
|
|
|
160
156
|
/**
|
|
161
157
|
* Adds the selected geometry to the map.
|
|
162
158
|
*
|
|
163
|
-
* @type {(function(
|
|
159
|
+
* @type {(function({feature: *}): void)|*}
|
|
164
160
|
*/
|
|
165
|
-
const onSelection = useCallback((
|
|
166
|
-
|
|
167
|
-
const { detail } = evt;
|
|
168
|
-
if (isValid(detail)) {
|
|
169
|
-
console.log("valid");
|
|
170
|
-
console.log(detail);
|
|
161
|
+
const onSelection = useCallback(({ feature }) => {
|
|
162
|
+
if (isValid(feature)) {
|
|
171
163
|
// Add the geometry to the map
|
|
172
|
-
|
|
173
|
-
console.log(drawRef.current.getAll());
|
|
174
|
-
drawRef.current.add(detail.geometry);
|
|
175
|
-
console.log("after add");
|
|
176
|
-
console.log(drawRef.current.getAll());
|
|
164
|
+
drawRef.current.add(feature.geometry);
|
|
177
165
|
|
|
178
166
|
// Trigger the onChange prop
|
|
179
167
|
onChange();
|
|
180
168
|
|
|
181
169
|
// Call the onGeocoding selection callback
|
|
182
170
|
if (props.onGeocodingSelection) {
|
|
183
|
-
props.onGeocodingSelection(
|
|
171
|
+
props.onGeocodingSelection(feature);
|
|
184
172
|
}
|
|
185
|
-
} else {
|
|
186
|
-
console.log("invalid");
|
|
187
|
-
console.log(detail);
|
|
188
173
|
}
|
|
189
174
|
}, [isValid, onChange, props.onGeocodingSelection]);
|
|
190
175
|
|
|
@@ -151,40 +151,25 @@ const MapDraw = (props: Props) => {
|
|
|
151
151
|
*
|
|
152
152
|
* @type {(function(): void)|*}
|
|
153
153
|
*/
|
|
154
|
-
const onChange = useCallback(() =>
|
|
155
|
-
console.log("fired callback");
|
|
156
|
-
console.log(drawRef.current.getAll());
|
|
157
|
-
props.onChange(drawRef.current.getAll());
|
|
158
|
-
}, [props.onChange]);
|
|
154
|
+
const onChange = useCallback(() => props.onChange(drawRef.current.getAll()), [props.onChange]);
|
|
159
155
|
|
|
160
156
|
/**
|
|
161
157
|
* Adds the selected geometry to the map.
|
|
162
158
|
*
|
|
163
|
-
* @type {(function(
|
|
159
|
+
* @type {(function({feature: *}): void)|*}
|
|
164
160
|
*/
|
|
165
|
-
const onSelection = useCallback((
|
|
166
|
-
|
|
167
|
-
const { detail } = evt;
|
|
168
|
-
if (isValid(detail)) {
|
|
169
|
-
console.log("valid");
|
|
170
|
-
console.log(detail);
|
|
161
|
+
const onSelection = useCallback(({ feature }) => {
|
|
162
|
+
if (isValid(feature)) {
|
|
171
163
|
// Add the geometry to the map
|
|
172
|
-
|
|
173
|
-
console.log(drawRef.current.getAll());
|
|
174
|
-
drawRef.current.add(detail.geometry);
|
|
175
|
-
console.log("after add");
|
|
176
|
-
console.log(drawRef.current.getAll());
|
|
164
|
+
drawRef.current.add(feature.geometry);
|
|
177
165
|
|
|
178
166
|
// Trigger the onChange prop
|
|
179
167
|
onChange();
|
|
180
168
|
|
|
181
169
|
// Call the onGeocoding selection callback
|
|
182
170
|
if (props.onGeocodingSelection) {
|
|
183
|
-
props.onGeocodingSelection(
|
|
171
|
+
props.onGeocodingSelection(feature);
|
|
184
172
|
}
|
|
185
|
-
} else {
|
|
186
|
-
console.log("invalid");
|
|
187
|
-
console.log(detail);
|
|
188
173
|
}
|
|
189
174
|
}, [isValid, onChange, props.onGeocodingSelection]);
|
|
190
175
|
|