@performant-software/geospatial 1.1.3 → 1.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{DrawControl:()=>u,GeoJsonLayer:()=>v,LayerMenu:()=>I,MapControl:()=>A,MapDraw:()=>q,RasterLayer:()=>U});const r=require("@mapbox/mapbox-gl-draw");var n=e.n(r);const o=require("react");var a=e.n(o);const i=require("react-map-gl");var l=e.n(i);const u=(0,o.forwardRef)((function(e,t){var r=(0,i.useControl)((function(){return new(n())(e)}),(function(t){var r=t.map;r.on("draw.create",e.onCreate),r.on("draw.update",e.onUpdate),r.on("draw.delete",e.onDelete)}),(function(t){var r=t.map;r.off("draw.create",e.onCreate),r.off("draw.update",e.onUpdate),r.off("draw.delete",e.onDelete)}),{position:e.position});return(0,o.useImperativeHandle)(t,(function(){return r}),[r]),null})),c=require("underscore");var f=e.n(c);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var m="#CC3333",p="#990000",y={"fill-color":m,"fill-opacity":.2},d={"line-color":p,"line-opacity":.6},b={"circle-radius":["interpolate",["linear"],["number",["get","point_count"],1],0,4,10,14],"circle-stroke-width":1,"circle-color":m,"circle-stroke-color":p};const v=function(e){var t,r,n=(t=(0,o.useState)(e.data),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw o}}return a}}(t,r)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=n[0],u=n[1],c=(0,o.useCallback)((function(e,t){return f().defaults(e,t)}),[]),m=(0,o.useMemo)((function(){return c(e.fillStyle,y)}),[c,e.fillStyle]),p=(0,o.useMemo)((function(){return c(e.lineStyle,d)}),[c,e.lineStyle]),v=(0,o.useMemo)((function(){return c(e.pointStyle,b)}),[c,e.pointStyle]);return(0,o.useEffect)((function(){e.url&&fetch(e.url).then((function(e){return e.json()})).then((function(e){return u(e)}))}),[e.url]),a().createElement(i.Source,{data:l,type:"geojson"},a().createElement(i.Layer,{filter:["!=","$type","Point"],paint:m,type:"fill"}),a().createElement(i.Layer,{filter:["!=","$type","Point"],paint:p,type:"line"}),a().createElement(i.Layer,{filter:["==","$type","Point"],paint:v,type:"circle"}))},h=require("react-icons/bs"),g=require("react-icons/io5"),w=require("maplibre-gl");var S=e.n(w);const O=require("react-dom");function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function C(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var j=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._map=null,this._redraw=t}var t,r;return t=e,(r=[{key:"onAdd",value:function(e){return this._map=e,e.on("move",this._redraw),this._container=document.createElement("div"),this._container.className="maplibregl-ctrl-group maplibregl-ctrl",this._redraw(),this._container}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("move",this._redraw),this._map=null}},{key:"getMap",value:function(){return this._map}},{key:"getElement",value:function(){return this._container}}])&&C(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();const A=function(e){var t,r,n=(t=(0,o.useState)(0),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw o}}return a}}(t,r)||function(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1],a=(0,o.useCallback)((function(){return n((function(e){return e+1}))}),[]),l=(0,i.useControl)((function(){return new j(a)}),{position:e.position}),u=l.getMap(),c=o.Children.map(f().compact(o.Children.toArray(e.children)),(function(e){return(0,o.cloneElement)(e,{map:u})}));return(0,o.useEffect)((function(){e.mapRef&&(e.mapRef.current=u)}),[u,e.mapRef]),u&&(0,O.createPortal)(c,l.getElement())};function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw o}}return a}}(e,t)||P(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){if(e){if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=function(e){var t=_((0,o.useState)(0),2),r=t[0],n=t[1],i=_((0,o.useState)(),2),l=i[0],u=i[1],c=_((0,o.useState)(!1),2),s=c[0],m=c[1],p=(0,o.useRef)(),y=(0,o.useCallback)((function(t){return e.names&&e.names.length>t&&e.names[t]}),[e.names]),d=(0,o.useCallback)((function(e){return f().includes(l,e)}),[l]),b=(0,o.useMemo)((function(){return o.Children.toArray(e.children)}),[e.children]),v=(0,o.useMemo)((function(){return f().filter(b,(function(e,t){return d(t)}))}),[b,d]),w=(0,o.useCallback)((function(e){var t,r;t=d(e)?f().without(l,e):[].concat(function(e){if(Array.isArray(e))return k(e)}(r=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||P(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[e]),u(t)}),[d,l]);return(0,o.useEffect)((function(){u(f().times(b.length,(function(e){return e})))}),[]),(0,o.useEffect)((function(){var e=p.current;if(e&&e._canvas){var t=p.current._canvas.offsetHeight;n(void 0===t?0:t)}}),[p.current]),f().isEmpty(b)?null:a().createElement(a().Fragment,null,a().createElement(A,{mapRef:p,position:e.position},a().createElement("button",{className:"mapbox-gl-draw_ctrl-draw-btn layer-button",onClick:function(){return m((function(e){return!e}))},type:"button"},a().createElement(h.BsStack,{size:"1.25em"})),s&&a().createElement("div",{className:"layer-menu",style:{maxHeight:"calc(".concat(r,"px - ").concat(30,"px)")}},a().createElement("div",{className:"menu"},f().map(b,(function(e,t){return a().createElement("div",{"aria-selected":d(t),className:"option",role:"option",onClick:function(){return w(t)},onKeyDown:function(){return w(t)},tabIndex:t},a().createElement("div",{className:"checkmark-container"},d(t)&&a().createElement(g.IoCheckmarkOutline,{size:"1em"})),y(t))}))))),v)};x.defaultProps={position:"top-left"};const I=x,M=require("@turf/turf");function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function z(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}n().constants.classes.CONTROL_BASE="maplibregl-ctrl",n().constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",n().constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var T=function(e){var t=D((0,o.useState)(!1),2),r=t[0],n=t[1],i=(0,o.useRef)(),c=(0,o.useRef)(),s=(0,o.useCallback)((function(){e.onChange(i.current.getAll())}),[e.onChange]),m=(0,o.useMemo)((function(){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({height:500,width:"100%"},e.style||{})}),[e.style]);return(0,o.useEffect)((function(){if(r&&e.data){var t=(0,M.bbox)(e.data),n=(0,M.bboxPolygon)(t),o=(0,M.buffer)(n,e.buffer,{units:"miles"}),a=(0,M.bbox)(o);if(f().every(a,f().isFinite)){var l=D(a,4),u=[[l[0],l[1]],[l[2],l[3]]];c.current.fitBounds(u,{duration:e.zoomDuration})}"GeometryCollection"===e.data.type?f().each(e.data.geometries,(function(e){i.current.add((0,M.feature)(e))})):i.current.add(e.data)}}),[r,e.data]),a().createElement(l(),{attributionControl:!1,onLoad:function(){return n(!0)},mapLib:S(),ref:c,style:m,mapStyle:e.mapStyle},a().createElement(u,{ref:i,controls:{line_string:!0,point:!0,polygon:!0,trash:!0},displayControlsDefault:!1,onCreate:s,onUpdate:s,onDelete:s,position:"bottom-left"}),e.children)};T.defaultProps={buffer:2,zoomDuration:1e3};const q=T;var N=function(e){return a().createElement(i.Source,{tileSize:e.tileSize,tiles:[e.url],type:"raster"},a().createElement(i.Layer,{type:"raster",paint:{"raster-opacity":e.opacity},minzoom:e.minzoom,maxzoom:e.maxzoom}))};N.defaultProps={maxzoom:22,minzoom:0,opacity:.7,tileSize:256};const U=N;module.exports=t})();
1
+ (()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{DrawControl:()=>u,GeoJsonLayer:()=>v,LayerMenu:()=>L,LocationMarker:()=>q,Map:()=>D,MapControl:()=>_,MapDraw:()=>G,RasterLayer:()=>J});const r=require("@mapbox/mapbox-gl-draw");var n=e.n(r);const o=require("react");var a=e.n(o);const i=require("react-map-gl");var l=e.n(i);const u=(0,o.forwardRef)((function(e,t){var r=(0,i.useControl)((function(){return new(n())(e)}),(function(t){var r=t.map;r.on("draw.create",e.onCreate),r.on("draw.update",e.onUpdate),r.on("draw.delete",e.onDelete)}),(function(t){var r=t.map;r.off("draw.create",e.onCreate),r.off("draw.update",e.onUpdate),r.off("draw.delete",e.onDelete)}),{position:e.position});return(0,o.useImperativeHandle)(t,(function(){return r}),[r]),null})),c=require("underscore");var f=e.n(c);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y="#CC3333",p="#990000",m={"fill-color":y,"fill-opacity":.2},b={"line-color":p,"line-opacity":.6},d={"circle-radius":["interpolate",["linear"],["number",["get","point_count"],1],0,4,10,14],"circle-stroke-width":1,"circle-color":y,"circle-stroke-color":p};const v=function(e){var t,r,n=(t=(0,o.useState)(e.data),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,r)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=n[0],u=n[1],c=(0,o.useCallback)((function(e,t){return f().defaults(e,t)}),[]),y=(0,o.useMemo)((function(){return c(e.fillStyle,m)}),[c,e.fillStyle]),p=(0,o.useMemo)((function(){return c(e.lineStyle,b)}),[c,e.lineStyle]),v=(0,o.useMemo)((function(){return c(e.pointStyle,d)}),[c,e.pointStyle]);return(0,o.useEffect)((function(){e.url&&fetch(e.url).then((function(e){return e.json()})).then((function(e){return u(e)}))}),[e.url]),a().createElement(i.Source,{data:l,type:"geojson"},a().createElement(i.Layer,{filter:["!=","$type","Point"],paint:y,type:"fill"}),a().createElement(i.Layer,{filter:["!=","$type","Point"],paint:p,type:"line"}),a().createElement(i.Layer,{filter:["==","$type","Point"],paint:v,type:"circle"}))},h=require("react-icons/bs"),g=require("react-icons/io5"),S=require("maplibre-gl");var w=e.n(S);const O=require("react-dom");function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function C(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,A(n.key),n)}}function A(e){var t=function(e,t){if("object"!=E(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==E(t)?t:String(t)}var P=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._map=null,this._container=void 0,this._redraw=void 0,this._redraw=t}var t,r;return t=e,(r=[{key:"onAdd",value:function(e){return this._map=e,e.on("move",this._redraw),this._container=document.createElement("div"),this._container.className="maplibregl-ctrl-group maplibregl-ctrl",this._redraw(),this._container}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("move",this._redraw),this._map=null}},{key:"getMap",value:function(){return this._map}},{key:"getElement",value:function(){return this._container}}])&&C(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();const _=function(e){var t,r,n=(t=(0,o.useState)(0),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(t,r)||function(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1],a=(0,o.useCallback)((function(){return n((function(e){return e+1}))}),[]),l=(0,i.useControl)((function(){return new P(a)}),{position:e.position}),u=l.getMap(),c=o.Children.map(f().compact(o.Children.toArray(e.children)),(function(e){return(0,o.cloneElement)(e,{map:u})}));return(0,o.useEffect)((function(){e.mapRef&&(e.mapRef.current=u)}),[u,e.mapRef]),u&&(0,O.createPortal)(c,l.getElement())};function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||M(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,t){if(e){if("string"==typeof e)return x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var I=function(e){var t=k((0,o.useState)(0),2),r=t[0],n=t[1],i=k((0,o.useState)(),2),l=i[0],u=i[1],c=k((0,o.useState)(!1),2),s=c[0],y=c[1],p=(0,o.useRef)(),m=(0,o.useCallback)((function(t){return e.names&&e.names.length>t&&e.names[t]}),[e.names]),b=(0,o.useCallback)((function(e){return f().includes(l,e)}),[l]),d=(0,o.useMemo)((function(){return o.Children.toArray(e.children)}),[e.children]),v=(0,o.useMemo)((function(){return f().filter(d,(function(e,t){return b(t)}))}),[d,b]),S=(0,o.useCallback)((function(e){var t,r;t=b(e)?f().without(l,e):[].concat(function(e){if(Array.isArray(e))return x(e)}(r=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||M(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[e]),u(t)}),[b,l]);return(0,o.useEffect)((function(){u(f().times(d.length,(function(e){return e})))}),[]),(0,o.useEffect)((function(){var e=p.current;if(e&&e._canvas){var t=p.current._canvas.offsetHeight;n(void 0===t?0:t)}}),[p.current]),f().isEmpty(d)?null:a().createElement(a().Fragment,null,a().createElement(_,{mapRef:p,position:e.position},a().createElement("button",{className:"mapbox-gl-draw_ctrl-draw-btn layer-button",onClick:function(){return y((function(e){return!e}))},type:"button"},a().createElement(h.BsStack,{size:"1.25em"})),s&&a().createElement("div",{className:"layer-menu",style:{maxHeight:"calc(".concat(r,"px - ").concat(30,"px)")}},a().createElement("div",{className:"menu"},f().map(d,(function(e,t){return a().createElement("div",{"aria-selected":b(t),className:"option",role:"option",onClick:function(){return S(t)},onKeyDown:function(){return S(t)},tabIndex:t},a().createElement("div",{className:"checkmark-container"},b(t)&&a().createElement(g.IoCheckmarkOutline,{size:"1em"})),m(t))}))))),v)};I.defaultProps={position:"top-left"};const L=I,R=require("@peripleo/maplibre"),z=require("@turf/turf"),D={getBoundingBox:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=(0,z.bbox)(e),o=(0,z.bboxPolygon)(n);return t=r?(0,z.buffer)(o,r,{units:"miles"}):o,(0,z.bbox)(t)}};var T=function(e){var t=(0,R.useMap)();return(0,o.useEffect)((function(){if(t&&e.data){var r=D.getBoundingBox(e.data,e.buffer);t.fitBounds(r)}}),[e.buffer,e.data]),a().createElement(a().Fragment,null,a().createElement(R.PulsingMarkerLayer,{id:"current",data:e.data}),a().createElement(R.MixedGeoJSONLayer,{id:"current",data:e.data,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle,pointStyle:e.pointStyle}))};T.defaultProps={buffer:2,fillStyle:{type:"fill",paint:{"fill-color":"#ff623b","fill-opacity":.2}},pointStyle:{type:"circle",paint:{"circle-radius":["interpolate",["linear"],["number",["get","point_count"],1],0,4,10,14],"circle-stroke-width":1,"circle-color":["case",["boolean",["feature-state","hover"],!1],"#3b62ff","#ff623b"],"circle-stroke-color":"#8d260c"}},strokeStyle:{type:"line",paint:{"line-color":"#ff623b","line-opacity":.6}}};const q=T;function B(e){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(e)}function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return $(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}n().constants.classes.CONTROL_BASE="maplibregl-ctrl",n().constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",n().constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var F=function(e){var t=U((0,o.useState)(!1),2),r=t[0],n=t[1],i=(0,o.useRef)(),c=(0,o.useRef)(),s=(0,o.useCallback)((function(){e.onChange(i.current.getAll())}),[e.onChange]),y=(0,o.useMemo)((function(){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){var n,o,a,i;n=e,o=t,a=r[t],i=function(e,t){if("object"!=B(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o),(o="symbol"==B(i)?i:String(i))in n?Object.defineProperty(n,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[o]=a})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({height:500,width:"100%"},e.style||{})}),[e.style]);return(0,o.useEffect)((function(){if(r&&e.data){var t=D.getBoundingBox(e.data,e.buffer);if(f().every(t,f().isFinite)){var n=U(t,4),o=[[n[0],n[1]],[n[2],n[3]]];c.current.fitBounds(o,{duration:e.zoomDuration})}"GeometryCollection"===e.data.type?f().each(e.data.geometries,(function(e){i.current.add((0,z.feature)(e))})):i.current.add(e.data)}}),[r,e.data]),a().createElement(l(),{attributionControl:!1,onLoad:function(){return n(!0)},mapLib:w(),ref:c,style:y,mapStyle:e.mapStyle},a().createElement(u,{ref:i,controls:{line_string:!0,point:!0,polygon:!0,trash:!0},displayControlsDefault:!1,onCreate:s,onUpdate:s,onDelete:s,position:"bottom-left"}),e.children)};F.defaultProps={buffer:2,zoomDuration:1e3};const G=F;var H=function(e){return a().createElement(i.Source,{tileSize:e.tileSize,tiles:[e.url],type:"raster"},a().createElement(i.Layer,{type:"raster",paint:{"raster-opacity":e.opacity},minzoom:e.minzoom,maxzoom:e.maxzoom}))};H.defaultProps={maxzoom:22,minzoom:0,opacity:.7,tileSize:256};const J=H;module.exports=t})();
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,2HCL9D,MAAM,EAA+BC,QAAQ,0B,aCA7C,MAAM,EAA+BA,QAAQ,S,aCA7C,MAAM,EAA+BA,QAAQ,gB,aC0C7C,SA7BoBC,EAAAA,EAAAA,aAAW,SAACC,EAAcC,GAI5C,IAAMC,GAAUC,EAAAA,EAAAA,aACd,kBAAM,IAAIC,IAAJ,CAAeJ,EAAM,IAC3B,YAA8B,IAA3BK,EAAG,EAAHA,IACDA,EAAIC,GAAG,cAAeN,EAAMO,UAC5BF,EAAIC,GAAG,cAAeN,EA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,EAAK,EAC7BuB,OAAQC,IACRrH,IAAK2D,EACLrC,MAAOA,EACPgG,SAAUvH,EAAMuH,UAEhB,kBAAC,EAAW,CACVtH,IAAKC,EACLsH,SAAU,CACRC,aAAa,EACbC,OAAO,EACPrB,SAAS,EACTsB,OAAO,GAETC,wBAAwB,EACxBrH,SAAUwF,EACVvF,SAAUuF,EACVtF,SAAUsF,EACVpF,SAAS,gBAETX,EAAMwD,SAGd,EAEAoC,EAAQD,aAAe,CACrBa,OAnGqB,EAoGrBM,aAnGyB,KAsG3B,UC/JA,IAAMe,EAAc,SAAC7H,GAAY,OAC/B,kBAAC,EAAAoC,OAAM,CACL0F,SAAU9H,EAAM8H,SAChBC,MAAO,CAAC/H,EAAM+B,KACdM,KAAK,UAEL,kBAAC,EAAAC,MAAK,CACJD,KAAK,SACLG,MAAO,CACL,iBAAkBxC,EAAMgI,SAE1BC,QAASjI,EAAMiI,QACfC,QAASlI,EAAMkI,UAEV,EAGXL,EAAYlC,aAAe,CACzBuC,QAAS,GACTD,QAAS,EACTD,QAAS,GACTF,SAAU,KAGZ,U","sources":["webpack://@performant-software/geospatial/webpack/bootstrap","webpack://@performant-software/geospatial/webpack/runtime/compat get default export","webpack://@performant-software/geospatial/webpack/runtime/define property getters","webpack://@performant-software/geospatial/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/geospatial/webpack/runtime/make namespace object","webpack://@performant-software/geospatial/external commonjs \"@mapbox/mapbox-gl-draw\"","webpack://@performant-software/geospatial/external commonjs2 \"react\"","webpack://@performant-software/geospatial/external commonjs \"react-map-gl\"","webpack://@performant-software/geospatial/./src/components/DrawControl.js","webpack://@performant-software/geospatial/external commonjs \"underscore\"","webpack://@performant-software/geospatial/./src/components/GeoJsonLayer.js","webpack://@performant-software/geospatial/external commonjs \"react-icons/bs\"","webpack://@performant-software/geospatial/external commonjs \"react-icons/io5\"","webpack://@performant-software/geospatial/external commonjs \"maplibre-gl\"","webpack://@performant-software/geospatial/external commonjs2 \"react-dom\"","webpack://@performant-software/geospatial/./src/components/MapControl.js","webpack://@performant-software/geospatial/./src/components/LayerMenu.js","webpack://@performant-software/geospatial/external commonjs \"@turf/turf\"","webpack://@performant-software/geospatial/./src/components/MapDraw.js","webpack://@performant-software/geospatial/./src/components/RasterLayer.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mapbox/mapbox-gl-draw\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-map-gl\");","// @flow\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport { forwardRef, useImperativeHandle } from 'react';\nimport { useControl, type ControlPosition, type MapRef } from 'react-map-gl';\n\ntype Props = {\n position?: ControlPosition;\n onCreate?: (evt: { features: Array<any> }) => void;\n onUpdate?: (evt: { features: Array<any>, action: string }) => void;\n onDelete?: (evt: { features: Array<any> }) => void;\n};\n\nconst DrawControl = forwardRef((props: Props, ref) => {\n /**\n * Creates the drawer ref using MapboxDraw.\n */\n const drawRef = useControl(\n () => new MapboxDraw(props),\n ({ map }: { map: MapRef }) => {\n map.on('draw.create', props.onCreate);\n map.on('draw.update', props.onUpdate);\n map.on('draw.delete', props.onDelete);\n },\n ({ map }: { map: MapRef }) => {\n map.off('draw.create', props.onCreate);\n map.off('draw.update', props.onUpdate);\n map.off('draw.delete', props.onDelete);\n },\n {\n position: props.position\n }\n );\n\n /**\n * Exposes the ref for the MapboxDraw object.\n */\n useImperativeHandle(ref, () => drawRef, [drawRef]);\n\n return null;\n});\n\nexport default DrawControl;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","// @flow\n\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { Layer, Source } from 'react-map-gl';\nimport _ from 'underscore';\n\ntype Props = {\n data?: { [key: string]: any },\n fillStyle?: { [key: string]: any },\n lineStyle?: { [key: string]: any },\n pointStyle?: { [key: string]: any },\n url?: string\n};\n\nconst DEFAULT_COLOR = '#CC3333';\nconst HIGHLIGHT_COLOR = '#990000';\n\nconst DEFAULT_FILL_STYLES = {\n 'fill-color': DEFAULT_COLOR,\n 'fill-opacity': 0.2\n};\n\nconst DEFAULT_LINE_STYLES = {\n 'line-color': HIGHLIGHT_COLOR,\n 'line-opacity': 0.6\n};\n\nconst DEFAULT_POINT_STYLES = {\n 'circle-radius': [\n 'interpolate',\n ['linear'],\n ['number', ['get', 'point_count'], 1],\n 0, 4,\n 10, 14\n ],\n 'circle-stroke-width': 1,\n 'circle-color': DEFAULT_COLOR,\n 'circle-stroke-color': HIGHLIGHT_COLOR\n};\n\nconst GeoJsonLayer = (props: Props) => {\n const [data, setData] = useState(props.data);\n\n /**\n * Returns the layer style for the passed style and default.\n *\n * @type {function(*, *): *}\n */\n const getLayerStyles = useCallback((style, defaultStyle) => _.defaults(style, defaultStyle), []);\n\n /**\n * Sets the fill layer style.\n *\n * @type {*}\n */\n const fillStyle = useMemo(() => (\n getLayerStyles(props.fillStyle, DEFAULT_FILL_STYLES)\n ), [getLayerStyles, props.fillStyle]);\n\n /**\n * Sets the line layer style.\n *\n * @type {*}\n */\n const lineStyle = useMemo(() => (\n getLayerStyles(props.lineStyle, DEFAULT_LINE_STYLES)\n ), [getLayerStyles, props.lineStyle]);\n\n /**\n * Sets the point layer style.\n *\n * @type {*}\n */\n const pointStyle = useMemo(() => (\n getLayerStyles(props.pointStyle, DEFAULT_POINT_STYLES)\n ), [getLayerStyles, props.pointStyle]);\n\n /**\n * If the data is passed as a URL, fetches the passed URL and sets the response on the state.\n */\n useEffect(() => {\n if (props.url) {\n fetch(props.url)\n .then((response) => response.json())\n .then((json) => setData(json));\n }\n }, [props.url]);\n\n return (\n <Source\n data={data}\n type='geojson'\n >\n <Layer\n filter={['!=', '$type', 'Point']}\n paint={fillStyle}\n type='fill'\n />\n <Layer\n filter={['!=', '$type', 'Point']}\n paint={lineStyle}\n type='line'\n />\n <Layer\n filter={['==', '$type', 'Point']}\n paint={pointStyle}\n type='circle'\n />\n </Source>\n );\n};\n\nexport default GeoJsonLayer;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-icons/bs\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-icons/io5\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"maplibre-gl\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-dom\");","// @flow\n\nimport { IControl } from 'maplibre-gl';\nimport {\n Children,\n cloneElement,\n useCallback,\n useEffect,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { MapboxMap, useControl } from 'react-map-gl';\nimport _ from 'underscore';\n\n/**\n * Class to implement the IControl interface to allow custom controls to be drawn on the map.\n */\nclass IControlImpl implements IControl {\n _map: MapboxMap = null;\n _container: HTMLElement;\n _redraw: () => void;\n\n /**\n * Constructs a new IControlImpl object.\n *\n * @param redraw\n */\n constructor(redraw: () => void) {\n this._redraw = redraw;\n }\n\n /**\n * Creates the container when the component is added to the passed map.\n *\n * @param map\n *\n * @returns {HTMLElement}\n */\n onAdd(map) {\n this._map = map;\n map.on('move', this._redraw);\n\n this._container = document.createElement('div');\n this._container.className = 'maplibregl-ctrl-group maplibregl-ctrl';\n this._redraw();\n return this._container;\n }\n\n /**\n * Removes the container when the component is removed from the map.\n */\n onRemove() {\n this._container.remove();\n this._map.off('move', this._redraw);\n this._map = null;\n }\n\n /**\n * Returns the map instance.\n *\n * @returns {mapboxgl.Map}\n */\n getMap() {\n return this._map;\n }\n\n /**\n * Returns the container instance.\n *\n * @returns {HTMLElement}\n */\n getElement() {\n return this._container;\n }\n}\n\nconst MapControl = (props) => {\n const [, setVersion] = useState(0);\n\n /**\n * Forces the component to re-render on map move.\n *\n * @type {function(): void}\n */\n const forceUpdate = useCallback(() => setVersion((v) => v + 1), []);\n\n /**\n * Creates the map control.\n *\n * @type {IControlImpl}\n */\n const ctrl = useControl(() => new IControlImpl(forceUpdate), { position: props.position });\n\n /**\n * Sets the map instance.\n *\n * @type {mapboxgl.Map}\n */\n const map = ctrl.getMap();\n\n /**\n * Creates the list of children to be added to the map instance.\n *\n * @type {Array<$NonMaybeType<*>>}\n */\n const children = Children.map(_.compact(Children.toArray(props.children)), (child) => cloneElement(child, { map }));\n\n /**\n * Sets the map ref.\n */\n useEffect(() => {\n if (props.mapRef) {\n // eslint-disable-next-line no-param-reassign\n props.mapRef.current = map;\n }\n }, [map, props.mapRef]);\n\n return map && createPortal(children, ctrl.getElement());\n};\n\nexport default MapControl;\n","// @flow\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useMemo, useRef,\n useState\n} from 'react';\nimport { BsStack } from 'react-icons/bs';\nimport { IoCheckmarkOutline } from 'react-icons/io5';\nimport _ from 'underscore';\nimport MapControl from './MapControl';\nimport './LayerMenu.css';\n\ntype Props = {\n children: Node,\n names: Array<string>,\n position: 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right'\n};\n\nconst MENU_PADDING = 30;\n\nconst LayerMenu = (props: Props) => {\n const [canvasHeight, setCanvasHeight] = useState(0);\n const [visible, setVisible] = useState();\n const [menuOpen, setMenuOpen] = useState(false);\n\n const mapRef = useRef();\n\n /**\n * Returns the name of the layer at the passed index.\n *\n * @type {unknown}\n */\n const getLayerName = useCallback((index) => (\n props.names && props.names.length > index && props.names[index]\n ), [props.names]);\n\n /**\n * Returns true if the child element at the passed index is visible.\n *\n * @type {function(*): *}\n */\n const isVisible = useCallback((index) => _.includes(visible, index), [visible]);\n\n /**\n * Returns a memoized array of the child elements.\n *\n * @type {Array<$NonMaybeType<unknown>>}\n */\n const children = useMemo(() => Children.toArray(props.children), [props.children]);\n\n /**\n * Returns a memoized array of visible child elements.\n */\n const visibleChildren = useMemo(() => _.filter(children, (child, index) => isVisible(index)), [children, isVisible]);\n\n /**\n * Toggles the visibility for the child element at the passed index.\n *\n * @type {(function(*): void)|*}\n */\n const toggleVisibility = useCallback((index) => {\n let value;\n\n if (isVisible(index)) {\n value = _.without(visible, index);\n } else {\n value = [...visible, index];\n }\n\n setVisible(value);\n }, [isVisible, visible]);\n\n /**\n * Sets all of the child elements to be visible when the component mounts.\n */\n useEffect(() => {\n setVisible(_.times(children.length, (index) => index));\n }, []);\n\n /**\n * Sets the map canvas height.\n */\n useEffect(() => {\n const { current: instance } = mapRef;\n\n if (instance && instance._canvas) {\n const { offsetHeight = 0 } = mapRef.current._canvas;\n setCanvasHeight(offsetHeight);\n }\n }, [mapRef.current]);\n\n if (_.isEmpty(children)) {\n return null;\n }\n\n return (\n <>\n <MapControl\n mapRef={mapRef}\n position={props.position}\n >\n <button\n className='mapbox-gl-draw_ctrl-draw-btn layer-button'\n onClick={() => setMenuOpen((prevMenuOpen) => !prevMenuOpen)}\n type='button'\n >\n <BsStack\n size='1.25em'\n />\n </button>\n { menuOpen && (\n <div\n className='layer-menu'\n style={{\n maxHeight: `calc(${canvasHeight}px - ${MENU_PADDING}px)`\n }}\n >\n <div\n className='menu'\n >\n { _.map(children, (child, index) => (\n <div\n aria-selected={isVisible(index)}\n className='option'\n role='option'\n onClick={() => toggleVisibility(index)}\n onKeyDown={() => toggleVisibility(index)}\n tabIndex={index}\n >\n <div\n className='checkmark-container'\n >\n { isVisible(index) && (\n <IoCheckmarkOutline\n size='1em'\n />\n )}\n </div>\n { getLayerName(index) }\n </div>\n ))}\n </div>\n </div>\n )}\n </MapControl>\n { visibleChildren }\n </>\n );\n};\n\nLayerMenu.defaultProps = {\n position: 'top-left'\n};\n\nexport default LayerMenu;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@turf/turf\");","// @flow\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport {\n bbox,\n bboxPolygon,\n buffer,\n feature,\n type FeatureCollection,\n type GeometryCollection\n} 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, { MapRef } from 'react-map-gl';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\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 * 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 * 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 * 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};\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<MapRef>();\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 props.onChange(drawRef.current.getAll());\n }, [props.onChange]);\n\n /**\n * Sets the 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 // Convert the GeoJSON into a bounding box\n const box = bbox(props.data);\n\n // Convert the bounding box to a polygon\n const polygon = bboxPolygon(box);\n\n // Create a buffer around the polygon\n const polygonBuffer = buffer(polygon, props.buffer, { units: 'miles' });\n\n // Convert the buffer to a bounding box\n const boundingBox = bbox(polygonBuffer);\n\n // Sets the bounding box for the current geometry.\n if (_.every(boundingBox, _.isFinite)) {\n const [minLng, minLat, maxLng, maxLat] = boundingBox;\n const bounds = [[minLng, minLat], [maxLng, maxLat]];\n\n mapRef.current.fitBounds(bounds, { 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={props.mapStyle}\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.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\n zoomDuration: DEFAULT_ZOOM_DELAY\n};\n\nexport default MapDraw;\n","// @flow\n\nimport React from 'react';\nimport { Layer, Source } from 'react-map-gl';\n\ntype Props = {\n maxzoom?: number,\n minzoom?: number,\n opacity?: number,\n tileSize?: number,\n url?: string,\n};\n\nconst RasterLayer = (props: Props) => (\n <Source\n tileSize={props.tileSize}\n tiles={[props.url]}\n type='raster'\n >\n <Layer\n type='raster'\n paint={{\n 'raster-opacity': props.opacity\n }}\n minzoom={props.minzoom}\n maxzoom={props.maxzoom}\n />\n </Source>\n);\n\nRasterLayer.defaultProps = {\n maxzoom: 22,\n minzoom: 0,\n opacity: 0.7,\n tileSize: 256\n};\n\nexport default RasterLayer;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","forwardRef","props","ref","drawRef","useControl","MapboxDraw","map","on","onCreate","onUpdate","onDelete","off","position","useImperativeHandle","DEFAULT_COLOR","HIGHLIGHT_COLOR","DEFAULT_FILL_STYLES","DEFAULT_LINE_STYLES","DEFAULT_POINT_STYLES","useState","data","setData","getLayerStyles","useCallback","style","defaultStyle","_","fillStyle","useMemo","lineStyle","pointStyle","useEffect","url","fetch","then","response","json","Source","type","Layer","filter","paint","IControlImpl","redraw","_map","this","_redraw","_container","document","createElement","className","remove","setVersion","forceUpdate","v","ctrl","getMap","children","Children","child","cloneElement","mapRef","current","createPortal","getElement","LayerMenu","canvasHeight","setCanvasHeight","visible","setVisible","menuOpen","setMenuOpen","useRef","getLayerName","index","names","length","isVisible","visibleChildren","toggleVisibility","instance","_canvas","offsetHeight","onClick","prevMenuOpen","BsStack","size","maxHeight","role","onKeyDown","tabIndex","IoCheckmarkOutline","defaultProps","MapDraw","loaded","setLoaded","onChange","getAll","height","width","box","bbox","polygon","bboxPolygon","polygonBuffer","buffer","units","boundingBox","bounds","fitBounds","duration","zoomDuration","geometries","geometry","add","feature","attributionControl","onLoad","mapLib","maplibregl","mapStyle","controls","line_string","point","trash","displayControlsDefault","RasterLayer","tileSize","tiles","opacity","minzoom","maxzoom"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,0JCL9D,MAAM,EAA+BC,QAAQ,0B,aCA7C,MAAM,EAA+BA,QAAQ,S,aCA7C,MAAM,EAA+BA,QAAQ,gB,aC0C7C,SA7BoBC,EAAAA,EAAAA,aAAW,SAACC,EAAcC,GAI5C,IAAMC,GAAUC,EAAAA,EAAAA,aACd,kBAAM,IAAIC,IAAJ,CAAeJ,EAAM,IAC3B,SAAAK,GAA8B,IAA3BC,EAAGD,EAAHC,IACDA,EAAIC,GAAG,cAAeP,EAAMQ,UAC5BF,EAAIC,GAAG,cAAeP,EAAMS,UAC5BH,EAAIC,GAAG,cAAeP,EAAMU,SAC9B,IACA,SAAAC,GAA8B,IAA3BL,EAAGK,EAAHL,IACDA,EAAIM,IAAI,cAAeZ,EAAMQ,UAC7BF,EAAIM,I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AAKmB,KACbb,IAAAA,KAAO5B,EAAMsB,KAAKuH,YAAY,SAACpC,GAC7BvG,EAAQiE,QAAQ2E,KAAIC,EAAAA,EAAAA,SAAQtC,GAC9B,IAEAvG,EAAQiE,QAAQ2E,IAAI9I,EAAMsB,KAE9B,CACF,GAAG,CAAC4G,EAAQlI,EAAMsB,OAGhBiB,IAAAA,cAACyG,IAAG,CACFC,oBAAoB,EACpBC,OAAQ,kBAAMf,GAAU,EAAK,EAC7BgB,OAAQC,IACRnJ,IAAKiE,EACLxC,MAAOA,EACP2H,SAAUrJ,EAAMqJ,UAEhB9G,IAAAA,cAAC+G,EAAW,CACVrJ,IAAKC,EACLqJ,SAAU,CACRC,aAAa,EACbC,OAAO,EACPzC,SAAS,EACT0C,OAAO,GAETC,wBAAwB,EACxBnJ,SAAU4H,EACV3H,SAAU2H,EACV1H,SAAU0H,EACVvH,SAAS,gBAETb,EAAM6D,SAGd,EAEAoE,EAAQ1B,aAAe,CACrBW,OA1FqB,EA2FrB0B,aA1FyB,KA6F3B,UChJA,IAAMgB,EAAc,SAAC5J,GAAY,OAC/BuC,IAAAA,cAACC,EAAAA,OAAM,CACLqH,SAAU7J,EAAM6J,SAChBC,MAAO,CAAC9J,EAAMkC,KACdO,KAAK,UAELF,IAAAA,cAACG,EAAAA,MAAK,CACJD,KAAK,SACLG,MAAO,CACL,iBAAkB5C,EAAM+J,SAE1BC,QAAShK,EAAMgK,QACfC,QAASjK,EAAMiK,UAEV,EAGXL,EAAYrD,aAAe,CACzB0D,QAAS,GACTD,QAAS,EACTD,QAAS,GACTF,SAAU,KAGZ,U","sources":["webpack://@performant-software/geospatial/webpack/bootstrap","webpack://@performant-software/geospatial/webpack/runtime/compat get default export","webpack://@performant-software/geospatial/webpack/runtime/define property getters","webpack://@performant-software/geospatial/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/geospatial/webpack/runtime/make namespace object","webpack://@performant-software/geospatial/external commonjs \"@mapbox/mapbox-gl-draw\"","webpack://@performant-software/geospatial/external commonjs2 \"react\"","webpack://@performant-software/geospatial/external commonjs \"react-map-gl\"","webpack://@performant-software/geospatial/./src/components/DrawControl.js","webpack://@performant-software/geospatial/external commonjs \"underscore\"","webpack://@performant-software/geospatial/./src/components/GeoJsonLayer.js","webpack://@performant-software/geospatial/external commonjs \"react-icons/bs\"","webpack://@performant-software/geospatial/external commonjs \"react-icons/io5\"","webpack://@performant-software/geospatial/external commonjs \"maplibre-gl\"","webpack://@performant-software/geospatial/external commonjs2 \"react-dom\"","webpack://@performant-software/geospatial/./src/components/MapControl.js","webpack://@performant-software/geospatial/./src/components/LayerMenu.js","webpack://@performant-software/geospatial/external commonjs \"@peripleo/maplibre\"","webpack://@performant-software/geospatial/external commonjs \"@turf/turf\"","webpack://@performant-software/geospatial/./src/utils/Map.js","webpack://@performant-software/geospatial/./src/components/LocationMarker.js","webpack://@performant-software/geospatial/./src/utils/MapStyles.js","webpack://@performant-software/geospatial/./src/components/MapDraw.js","webpack://@performant-software/geospatial/./src/components/RasterLayer.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mapbox/mapbox-gl-draw\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-map-gl\");","// @flow\n\nimport MapboxDraw from '@mapbox/mapbox-gl-draw';\nimport { forwardRef, useImperativeHandle } from 'react';\nimport { useControl, type ControlPosition, type MapRef } from 'react-map-gl';\n\ntype Props = {\n position?: ControlPosition;\n onCreate?: (evt: { features: Array<any> }) => void;\n onUpdate?: (evt: { features: Array<any>, action: string }) => void;\n onDelete?: (evt: { features: Array<any> }) => void;\n};\n\nconst DrawControl = forwardRef((props: Props, ref) => {\n /**\n * Creates the drawer ref using MapboxDraw.\n */\n const drawRef = useControl(\n () => new MapboxDraw(props),\n ({ map }: { map: MapRef }) => {\n map.on('draw.create', props.onCreate);\n map.on('draw.update', props.onUpdate);\n map.on('draw.delete', props.onDelete);\n },\n ({ map }: { map: MapRef }) => {\n map.off('draw.create', props.onCreate);\n map.off('draw.update', props.onUpdate);\n map.off('draw.delete', props.onDelete);\n },\n {\n position: props.position\n }\n );\n\n /**\n * Exposes the ref for the MapboxDraw object.\n */\n useImperativeHandle(ref, () => drawRef, [drawRef]);\n\n return null;\n});\n\nexport default DrawControl;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","// @flow\n\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { Layer, Source } from 'react-map-gl';\nimport _ from 'underscore';\n\ntype Props = {\n data?: { [key: string]: any },\n fillStyle?: { [key: string]: any },\n lineStyle?: { [key: string]: any },\n pointStyle?: { [key: string]: any },\n url?: string\n};\n\nconst DEFAULT_COLOR = '#CC3333';\nconst HIGHLIGHT_COLOR = '#990000';\n\nconst DEFAULT_FILL_STYLES = {\n 'fill-color': DEFAULT_COLOR,\n 'fill-opacity': 0.2\n};\n\nconst DEFAULT_LINE_STYLES = {\n 'line-color': HIGHLIGHT_COLOR,\n 'line-opacity': 0.6\n};\n\nconst DEFAULT_POINT_STYLES = {\n 'circle-radius': [\n 'interpolate',\n ['linear'],\n ['number', ['get', 'point_count'], 1],\n 0, 4,\n 10, 14\n ],\n 'circle-stroke-width': 1,\n 'circle-color': DEFAULT_COLOR,\n 'circle-stroke-color': HIGHLIGHT_COLOR\n};\n\nconst GeoJsonLayer = (props: Props) => {\n const [data, setData] = useState(props.data);\n\n /**\n * Returns the layer style for the passed style and default.\n *\n * @type {function(*, *): *}\n */\n const getLayerStyles = useCallback((style, defaultStyle) => _.defaults(style, defaultStyle), []);\n\n /**\n * Sets the fill layer style.\n *\n * @type {*}\n */\n const fillStyle = useMemo(() => (\n getLayerStyles(props.fillStyle, DEFAULT_FILL_STYLES)\n ), [getLayerStyles, props.fillStyle]);\n\n /**\n * Sets the line layer style.\n *\n * @type {*}\n */\n const lineStyle = useMemo(() => (\n getLayerStyles(props.lineStyle, DEFAULT_LINE_STYLES)\n ), [getLayerStyles, props.lineStyle]);\n\n /**\n * Sets the point layer style.\n *\n * @type {*}\n */\n const pointStyle = useMemo(() => (\n getLayerStyles(props.pointStyle, DEFAULT_POINT_STYLES)\n ), [getLayerStyles, props.pointStyle]);\n\n /**\n * If the data is passed as a URL, fetches the passed URL and sets the response on the state.\n */\n useEffect(() => {\n if (props.url) {\n fetch(props.url)\n .then((response) => response.json())\n .then((json) => setData(json));\n }\n }, [props.url]);\n\n return (\n <Source\n data={data}\n type='geojson'\n >\n <Layer\n filter={['!=', '$type', 'Point']}\n paint={fillStyle}\n type='fill'\n />\n <Layer\n filter={['!=', '$type', 'Point']}\n paint={lineStyle}\n type='line'\n />\n <Layer\n filter={['==', '$type', 'Point']}\n paint={pointStyle}\n type='circle'\n />\n </Source>\n );\n};\n\nexport default GeoJsonLayer;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-icons/bs\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-icons/io5\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"maplibre-gl\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react-dom\");","// @flow\n\nimport { IControl } from 'maplibre-gl';\nimport {\n Children,\n cloneElement,\n useCallback,\n useEffect,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { MapboxMap, useControl } from 'react-map-gl';\nimport _ from 'underscore';\n\n/**\n * Class to implement the IControl interface to allow custom controls to be drawn on the map.\n */\nclass IControlImpl implements IControl {\n _map: MapboxMap = null;\n _container: HTMLElement;\n _redraw: () => void;\n\n /**\n * Constructs a new IControlImpl object.\n *\n * @param redraw\n */\n constructor(redraw: () => void) {\n this._redraw = redraw;\n }\n\n /**\n * Creates the container when the component is added to the passed map.\n *\n * @param map\n *\n * @returns {HTMLElement}\n */\n onAdd(map) {\n this._map = map;\n map.on('move', this._redraw);\n\n this._container = document.createElement('div');\n this._container.className = 'maplibregl-ctrl-group maplibregl-ctrl';\n this._redraw();\n return this._container;\n }\n\n /**\n * Removes the container when the component is removed from the map.\n */\n onRemove() {\n this._container.remove();\n this._map.off('move', this._redraw);\n this._map = null;\n }\n\n /**\n * Returns the map instance.\n *\n * @returns {mapboxgl.Map}\n */\n getMap() {\n return this._map;\n }\n\n /**\n * Returns the container instance.\n *\n * @returns {HTMLElement}\n */\n getElement() {\n return this._container;\n }\n}\n\nconst MapControl = (props) => {\n const [, setVersion] = useState(0);\n\n /**\n * Forces the component to re-render on map move.\n *\n * @type {function(): void}\n */\n const forceUpdate = useCallback(() => setVersion((v) => v + 1), []);\n\n /**\n * Creates the map control.\n *\n * @type {IControlImpl}\n */\n const ctrl = useControl(() => new IControlImpl(forceUpdate), { position: props.position });\n\n /**\n * Sets the map instance.\n *\n * @type {mapboxgl.Map}\n */\n const map = ctrl.getMap();\n\n /**\n * Creates the list of children to be added to the map instance.\n *\n * @type {Array<$NonMaybeType<*>>}\n */\n const children = Children.map(_.compact(Children.toArray(props.children)), (child) => cloneElement(child, { map }));\n\n /**\n * Sets the map ref.\n */\n useEffect(() => {\n if (props.mapRef) {\n // eslint-disable-next-line no-param-reassign\n props.mapRef.current = map;\n }\n }, [map, props.mapRef]);\n\n return map && createPortal(children, ctrl.getElement());\n};\n\nexport default MapControl;\n","// @flow\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useMemo, useRef,\n useState\n} from 'react';\nimport { BsStack } from 'react-icons/bs';\nimport { IoCheckmarkOutline } from 'react-icons/io5';\nimport _ from 'underscore';\nimport MapControl from './MapControl';\nimport './LayerMenu.css';\n\ntype Props = {\n children: Node,\n names: Array<string>,\n position: 'top-left' | 'bottom-left' | 'top-right' | 'bottom-right'\n};\n\nconst MENU_PADDING = 30;\n\nconst LayerMenu = (props: Props) => {\n const [canvasHeight, setCanvasHeight] = useState(0);\n const [visible, setVisible] = useState();\n const [menuOpen, setMenuOpen] = useState(false);\n\n const mapRef = useRef();\n\n /**\n * Returns the name of the layer at the passed index.\n *\n * @type {unknown}\n */\n const getLayerName = useCallback((index) => (\n props.names && props.names.length > index && props.names[index]\n ), [props.names]);\n\n /**\n * Returns true if the child element at the passed index is visible.\n *\n * @type {function(*): *}\n */\n const isVisible = useCallback((index) => _.includes(visible, index), [visible]);\n\n /**\n * Returns a memoized array of the child elements.\n *\n * @type {Array<$NonMaybeType<unknown>>}\n */\n const children = useMemo(() => Children.toArray(props.children), [props.children]);\n\n /**\n * Returns a memoized array of visible child elements.\n */\n const visibleChildren = useMemo(() => _.filter(children, (child, index) => isVisible(index)), [children, isVisible]);\n\n /**\n * Toggles the visibility for the child element at the passed index.\n *\n * @type {(function(*): void)|*}\n */\n const toggleVisibility = useCallback((index) => {\n let value;\n\n if (isVisible(index)) {\n value = _.without(visible, index);\n } else {\n value = [...visible, index];\n }\n\n setVisible(value);\n }, [isVisible, visible]);\n\n /**\n * Sets all of the child elements to be visible when the component mounts.\n */\n useEffect(() => {\n setVisible(_.times(children.length, (index) => index));\n }, []);\n\n /**\n * Sets the map canvas height.\n */\n useEffect(() => {\n const { current: instance } = mapRef;\n\n if (instance && instance._canvas) {\n const { offsetHeight = 0 } = mapRef.current._canvas;\n setCanvasHeight(offsetHeight);\n }\n }, [mapRef.current]);\n\n if (_.isEmpty(children)) {\n return null;\n }\n\n return (\n <>\n <MapControl\n mapRef={mapRef}\n position={props.position}\n >\n <button\n className='mapbox-gl-draw_ctrl-draw-btn layer-button'\n onClick={() => setMenuOpen((prevMenuOpen) => !prevMenuOpen)}\n type='button'\n >\n <BsStack\n size='1.25em'\n />\n </button>\n { menuOpen && (\n <div\n className='layer-menu'\n style={{\n maxHeight: `calc(${canvasHeight}px - ${MENU_PADDING}px)`\n }}\n >\n <div\n className='menu'\n >\n { _.map(children, (child, index) => (\n <div\n aria-selected={isVisible(index)}\n className='option'\n role='option'\n onClick={() => toggleVisibility(index)}\n onKeyDown={() => toggleVisibility(index)}\n tabIndex={index}\n >\n <div\n className='checkmark-container'\n >\n { isVisible(index) && (\n <IoCheckmarkOutline\n size='1em'\n />\n )}\n </div>\n { getLayerName(index) }\n </div>\n ))}\n </div>\n </div>\n )}\n </MapControl>\n { visibleChildren }\n </>\n );\n};\n\nLayerMenu.defaultProps = {\n position: 'top-left'\n};\n\nexport default LayerMenu;\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@peripleo/maplibre\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@turf/turf\");","// @flow\n\nimport { bbox, bboxPolygon, buffer } from '@turf/turf';\n\n/**\n * Returns a bounding box for the passed geometry (with optional buffer).\n *\n * @param geometry\n * @param bufferDistance\n *\n * @returns {BBox}\n */\nconst getBoundingBox = (geometry, bufferDistance = null) => {\n // Convert the GeoJSON into a bounding box\n const box = bbox(geometry);\n\n // Convert the bounding box to a polygon\n const polygon = bboxPolygon(box);\n\n // Create a buffer around the polygon (if a distance is provided)\n let polygonBuffer;\n\n if (bufferDistance) {\n polygonBuffer = buffer(polygon, bufferDistance, { units: 'miles' });\n } else {\n polygonBuffer = polygon;\n }\n\n // Convert the buffer to a bounding box\n return bbox(polygonBuffer);\n};\n\nexport default {\n getBoundingBox\n};\n","// @flow\n\nimport React, { useEffect } from 'react';\nimport { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';\nimport { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';\nimport MapUtils from '../utils/Map';\n\ntype Props = {\n /**\n * The number of miles to buffer the GeoJSON data.\n */\n buffer: number,\n\n /**\n * The GeoJSON data representing the location.\n */\n data: { [key: string]: any },\n\n /**\n * GeoJSON layer fill style.\n */\n fillStyle?: { [key: string]: any },\n\n /**\n * GeoJSON layer point style.\n */\n pointStyle?: { [key: string]: any },\n\n /**\n * GeoJSON layer stroke style\n */\n strokeStyle?: { [key: string]: any }\n};\n\nconst DEFAULT_BUFFER = 2;\n\nconst LocationMarker = (props: Props) => {\n const map = useMap();\n\n /**\n * Sets the bounding box on the map.\n */\n useEffect(() => {\n if (map && props.data) {\n const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);\n map.fitBounds(boundingBox);\n }\n }, [props.buffer, props.data]);\n\n return (\n <>\n <PulsingMarkerLayer\n id='current'\n data={props.data}\n />\n <MixedGeoJSONLayer\n id='current'\n data={props.data}\n fillStyle={props.fillStyle}\n strokeStyle={props.strokeStyle}\n pointStyle={props.pointStyle}\n />\n </>\n );\n};\n\nLocationMarker.defaultProps = {\n buffer: DEFAULT_BUFFER,\n fillStyle: DEFAULT_FILL_STYLE,\n pointStyle: DEFAULT_POINT_STYLE,\n strokeStyle: DEFAULT_STROKE_STYLE\n};\n\nexport default LocationMarker;\n","// @flow\n\nexport const DEFAULT_POINT_STYLE = {\n type: 'circle',\n paint: {\n 'circle-radius': [\n 'interpolate',\n ['linear'],\n ['number', ['get', 'point_count'], 1],\n 0, 4,\n 10, 14\n ],\n 'circle-stroke-width': 1,\n 'circle-color': [\n 'case',\n ['boolean', ['feature-state', 'hover'], false],\n '#3b62ff',\n '#ff623b'\n ],\n 'circle-stroke-color': '#8d260c'\n }\n};\n\nexport const DEFAULT_FILL_STYLE = {\n type: 'fill',\n paint: {\n 'fill-color': '#ff623b',\n 'fill-opacity': 0.2\n }\n};\n\nexport const DEFAULT_STROKE_STYLE = {\n type: 'line',\n paint: {\n 'line-color': '#ff623b',\n 'line-opacity': 0.6\n }\n};\n","// @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, { MapRef } from 'react-map-gl';\nimport _ from 'underscore';\nimport DrawControl from './DrawControl';\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 * 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 * 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 * 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};\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<MapRef>();\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 props.onChange(drawRef.current.getAll());\n }, [props.onChange]);\n\n /**\n * Sets the 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 // Get the bounding box for the passed data\n const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);\n\n // Sets the bounding box for the current geometry\n if (_.every(boundingBox, _.isFinite)) {\n const [minLng, minLat, maxLng, maxLat] = boundingBox;\n const bounds = [[minLng, minLat], [maxLng, maxLat]];\n\n mapRef.current.fitBounds(bounds, { 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={props.mapStyle}\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.children }\n </Map>\n );\n};\n\nMapDraw.defaultProps = {\n buffer: DEFAULT_BUFFER,\n zoomDuration: DEFAULT_ZOOM_DELAY\n};\n\nexport default MapDraw;\n","// @flow\n\nimport React from 'react';\nimport { Layer, Source } from 'react-map-gl';\n\ntype Props = {\n maxzoom?: number,\n minzoom?: number,\n opacity?: number,\n tileSize?: number,\n url?: string,\n};\n\nconst RasterLayer = (props: Props) => (\n <Source\n tileSize={props.tileSize}\n tiles={[props.url]}\n type='raster'\n >\n <Layer\n type='raster'\n paint={{\n 'raster-opacity': props.opacity\n }}\n minzoom={props.minzoom}\n maxzoom={props.maxzoom}\n />\n </Source>\n);\n\nRasterLayer.defaultProps = {\n maxzoom: 22,\n minzoom: 0,\n opacity: 0.7,\n tileSize: 256\n};\n\nexport default RasterLayer;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","forwardRef","props","ref","drawRef","useControl","MapboxDraw","_ref","map","on","onCreate","onUpdate","onDelete","_ref2","off","position","useImperativeHandle","DEFAULT_COLOR","HIGHLIGHT_COLOR","DEFAULT_FILL_STYLES","DEFAULT_LINE_STYLES","DEFAULT_POINT_STYLES","_useState2","useState","data","setData","getLayerStyles","useCallback","style","defaultStyle","_","fillStyle","useMemo","lineStyle","pointStyle","useEffect","url","fetch","then","response","json","React","Source","type","Layer","filter","paint","IControlImpl","redraw","_classCallCheck","_map","_container","_redraw","this","document","createElement","className","remove","setVersion","forceUpdate","v","ctrl","getMap","children","Children","toArray","child","cloneElement","mapRef","current","createPortal","getElement","LayerMenu","_slicedToArray","canvasHeight","setCanvasHeight","_useState4","visible","setVisible","_useState6","menuOpen","setMenuOpen","useRef","getLayerName","index","names","length","isVisible","visibleChildren","toggleVisibility","concat","instance","_canvas","_mapRef$current$_canv","offsetHeight","MapControl","onClick","prevMenuOpen","BsStack","size","maxHeight","role","onKeyDown","tabIndex","IoCheckmarkOutline","defaultProps","getBoundingBox","geometry","polygonBuffer","bufferDistance","arguments","undefined","box","bbox","polygon","bboxPolygon","buffer","units","LocationMarker","useMap","boundingBox","MapUtils","fitBounds","PulsingMarkerLayer","id","MixedGeoJSONLayer","strokeStyle","classes","CONTROL_BASE","CONTROL_PREFIX","CONTROL_GROUP","MapDraw","loaded","setLoaded","onChange","getAll","_objectSpread","height","width","_boundingBox","bounds","duration","zoomDuration","geometries","add","feature","Map","attributionControl","onLoad","mapLib","maplibregl","mapStyle","DrawControl","controls","line_string","point","trash","displayControlsDefault","RasterLayer","tileSize","tiles","opacity","minzoom","maxzoom"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/geospatial",
3
- "version": "1.1.3",
3
+ "version": "1.2.0-beta.0",
4
4
  "description": "TODO: ADD",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -10,7 +10,13 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@mapbox/mapbox-gl-draw": "^1.4.3",
13
+ "@peripleo/maplibre": "^0.3.2",
14
+ "@peripleo/peripleo": "^0.3.2",
15
+ "@radix-ui/react-accordion": "^1.1.2",
16
+ "@radix-ui/react-dialog": "^1.0.5",
17
+ "@samvera/clover-iiif": "^2.3.2",
13
18
  "@turf/turf": "^6.5.0",
19
+ "lucide-react": "^0.320.0",
14
20
  "mapbox-gl": "npm:empty-npm-package@1.0.0",
15
21
  "maplibre-gl": "^3.6.2",
16
22
  "react-icons": "^5.0.1",
@@ -0,0 +1,74 @@
1
+ // @flow
2
+
3
+ import React, { useEffect } from 'react';
4
+ import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
5
+ import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
6
+ import MapUtils from '../utils/Map';
7
+
8
+ type Props = {
9
+ /**
10
+ * The number of miles to buffer the GeoJSON data.
11
+ */
12
+ buffer: number,
13
+
14
+ /**
15
+ * The GeoJSON data representing the location.
16
+ */
17
+ data: { [key: string]: any },
18
+
19
+ /**
20
+ * GeoJSON layer fill style.
21
+ */
22
+ fillStyle?: { [key: string]: any },
23
+
24
+ /**
25
+ * GeoJSON layer point style.
26
+ */
27
+ pointStyle?: { [key: string]: any },
28
+
29
+ /**
30
+ * GeoJSON layer stroke style
31
+ */
32
+ strokeStyle?: { [key: string]: any }
33
+ };
34
+
35
+ const DEFAULT_BUFFER = 2;
36
+
37
+ const LocationMarker = (props: Props) => {
38
+ const map = useMap();
39
+
40
+ /**
41
+ * Sets the bounding box on the map.
42
+ */
43
+ useEffect(() => {
44
+ if (map && props.data) {
45
+ const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
46
+ map.fitBounds(boundingBox);
47
+ }
48
+ }, [props.buffer, props.data]);
49
+
50
+ return (
51
+ <>
52
+ <PulsingMarkerLayer
53
+ id='current'
54
+ data={props.data}
55
+ />
56
+ <MixedGeoJSONLayer
57
+ id='current'
58
+ data={props.data}
59
+ fillStyle={props.fillStyle}
60
+ strokeStyle={props.strokeStyle}
61
+ pointStyle={props.pointStyle}
62
+ />
63
+ </>
64
+ );
65
+ };
66
+
67
+ LocationMarker.defaultProps = {
68
+ buffer: DEFAULT_BUFFER,
69
+ fillStyle: DEFAULT_FILL_STYLE,
70
+ pointStyle: DEFAULT_POINT_STYLE,
71
+ strokeStyle: DEFAULT_STROKE_STYLE
72
+ };
73
+
74
+ export default LocationMarker;
@@ -1,14 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import MapboxDraw from '@mapbox/mapbox-gl-draw';
4
- import {
5
- bbox,
6
- bboxPolygon,
7
- buffer,
8
- feature,
9
- type FeatureCollection,
10
- type GeometryCollection
11
- } from '@turf/turf';
4
+ import { feature, type FeatureCollection, type GeometryCollection } from '@turf/turf';
12
5
  import maplibregl from 'maplibre-gl';
13
6
  import React, {
14
7
  useCallback,
@@ -21,6 +14,7 @@ import React, {
21
14
  import Map, { MapRef } from 'react-map-gl';
22
15
  import _ from 'underscore';
23
16
  import DrawControl from './DrawControl';
17
+ import MapUtils from '../utils/Map';
24
18
  import './MapDraw.css';
25
19
 
26
20
  // Override the MapboxDraw components to use MapLibre styles
@@ -106,19 +100,10 @@ const MapDraw = (props: Props) => {
106
100
  */
107
101
  useEffect(() => {
108
102
  if (loaded && props.data) {
109
- // Convert the GeoJSON into a bounding box
110
- const box = bbox(props.data);
103
+ // Get the bounding box for the passed data
104
+ const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
111
105
 
112
- // Convert the bounding box to a polygon
113
- const polygon = bboxPolygon(box);
114
-
115
- // Create a buffer around the polygon
116
- const polygonBuffer = buffer(polygon, props.buffer, { units: 'miles' });
117
-
118
- // Convert the buffer to a bounding box
119
- const boundingBox = bbox(polygonBuffer);
120
-
121
- // Sets the bounding box for the current geometry.
106
+ // Sets the bounding box for the current geometry
122
107
  if (_.every(boundingBox, _.isFinite)) {
123
108
  const [minLng, minLat, maxLng, maxLat] = boundingBox;
124
109
  const bounds = [[minLng, minLat], [maxLng, maxLat]];
package/src/index.js CHANGED
@@ -4,6 +4,10 @@
4
4
  export { default as DrawControl } from './components/DrawControl';
5
5
  export { default as GeoJsonLayer } from './components/GeoJsonLayer';
6
6
  export { default as LayerMenu } from './components/LayerMenu';
7
+ export { default as LocationMarker } from './components/LocationMarker';
7
8
  export { default as MapControl } from './components/MapControl';
8
9
  export { default as MapDraw } from './components/MapDraw';
9
10
  export { default as RasterLayer } from './components/RasterLayer';
11
+
12
+ // Utils
13
+ export { default as Map } from './utils/Map';
@@ -0,0 +1,35 @@
1
+ // @flow
2
+
3
+ import { bbox, bboxPolygon, buffer } from '@turf/turf';
4
+
5
+ /**
6
+ * Returns a bounding box for the passed geometry (with optional buffer).
7
+ *
8
+ * @param geometry
9
+ * @param bufferDistance
10
+ *
11
+ * @returns {BBox}
12
+ */
13
+ const getBoundingBox = (geometry, bufferDistance = null) => {
14
+ // Convert the GeoJSON into a bounding box
15
+ const box = bbox(geometry);
16
+
17
+ // Convert the bounding box to a polygon
18
+ const polygon = bboxPolygon(box);
19
+
20
+ // Create a buffer around the polygon (if a distance is provided)
21
+ let polygonBuffer;
22
+
23
+ if (bufferDistance) {
24
+ polygonBuffer = buffer(polygon, bufferDistance, { units: 'miles' });
25
+ } else {
26
+ polygonBuffer = polygon;
27
+ }
28
+
29
+ // Convert the buffer to a bounding box
30
+ return bbox(polygonBuffer);
31
+ };
32
+
33
+ export default {
34
+ getBoundingBox
35
+ };
@@ -0,0 +1,38 @@
1
+ // @flow
2
+
3
+ export const DEFAULT_POINT_STYLE = {
4
+ type: 'circle',
5
+ paint: {
6
+ 'circle-radius': [
7
+ 'interpolate',
8
+ ['linear'],
9
+ ['number', ['get', 'point_count'], 1],
10
+ 0, 4,
11
+ 10, 14
12
+ ],
13
+ 'circle-stroke-width': 1,
14
+ 'circle-color': [
15
+ 'case',
16
+ ['boolean', ['feature-state', 'hover'], false],
17
+ '#3b62ff',
18
+ '#ff623b'
19
+ ],
20
+ 'circle-stroke-color': '#8d260c'
21
+ }
22
+ };
23
+
24
+ export const DEFAULT_FILL_STYLE = {
25
+ type: 'fill',
26
+ paint: {
27
+ 'fill-color': '#ff623b',
28
+ 'fill-opacity': 0.2
29
+ }
30
+ };
31
+
32
+ export const DEFAULT_STROKE_STYLE = {
33
+ type: 'line',
34
+ paint: {
35
+ 'line-color': '#ff623b',
36
+ 'line-opacity': 0.6
37
+ }
38
+ };
@@ -1,80 +1,64 @@
1
+ // @flow
2
+
1
3
  import React, { useEffect, useState } from 'react';
2
4
  import type { FeatureCollection } from '@peripleo/peripleo';
3
- import { Peripleo, Controls } from '@peripleo/peripleo';
4
- import { Map, MixedGeoJSONLayer, PulsingMarkerLayer, Zoom } from '@peripleo/maplibre';
5
- import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from './CoreDataPlaceStyles';
6
-
7
- type CoreDataPlaceProps = {
8
- mapStyle: string | object;
9
- placeURI: string;
10
- fillStyle?: object;
11
- pointStyle?: object;
12
- strokeStyle?: object;
13
- };
14
-
15
- export const CoreDataPlace = (props: CoreDataPlaceProps) => {
16
-
17
- return (
18
- <Peripleo>
19
- <Map style={props.mapStyle}>
20
- <Controls position="topright">
21
- <Zoom />
22
- </Controls>
23
-
24
- <CoreDataPlaceLayer
25
- uri={props.placeURI}
26
- fillStyle={props.fillStyle}
27
- pointStyle={props.pointStyle}
28
- strokeStyle={props.strokeStyle} />
29
- </Map>
30
- </Peripleo>
31
- )
5
+ import { MixedGeoJSONLayer, PulsingMarkerLayer } from '@peripleo/maplibre';
6
+ import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
7
+ import './CoreDataPlace.css';
32
8
 
9
+ type Props = {
10
+ url: string,
11
+ fillStyle?: { [key: string]: any },
12
+ pointStyle?: { [key: string]: any },
13
+ strokeStyle?: { [key: string]: any }
33
14
  };
34
15
 
35
- type CoreDataPlaceLayerProps = {
36
- uri: string;
37
- fillStyle?: object;
38
- pointStyle?: object;
39
- strokeStyle?: object;
40
- };
41
-
42
- export const CoreDataPlaceLayer = (props: CoreDataPlaceLayerProps) => {
43
-
16
+ const CoreDataPlace = (props: Props) => {
44
17
  const [place, setPlace] = useState<FeatureCollection | undefined>(undefined);
45
18
 
19
+ /**
20
+ * Fetch the place record from the passed URI.
21
+ */
46
22
  useEffect(() => {
47
- fetch(props.uri)
48
- .then(res => res.json())
49
- .then(data => {
50
- const place = {
23
+ fetch(props.url)
24
+ .then((res) => res.json())
25
+ .then((data) => setPlace({
26
+ type: 'FeatureCollection',
27
+ features: [{
51
28
  ...data,
52
29
  properties: {
53
30
  ...data.properties,
54
31
  record_id: data.record_id
55
32
  }
56
- };
33
+ }]
34
+ }));
35
+ }, [props.url]);
57
36
 
58
- setPlace({
59
- type: 'FeatureCollection',
60
- features: [place]
61
- });
62
- });
63
- }, [props.uri])
37
+ if (!place) {
38
+ return null;
39
+ }
64
40
 
65
- return place && (
41
+ return (
66
42
  <>
67
- <PulsingMarkerLayer
68
- id="current"
69
- data={place} />
70
-
43
+ <PulsingMarkerLayer
44
+ id='current'
45
+ data={place}
46
+ />
71
47
  <MixedGeoJSONLayer
72
- id={props.uri}
73
- data={place}
74
- fillStyle={props.fillStyle || DEFAULT_FILL_STYLE}
75
- strokeStyle={props.strokeStyle || DEFAULT_STROKE_STYLE}
76
- pointStyle={props.pointStyle || DEFAULT_POINT_STYLE} />
48
+ id={props.url}
49
+ data={place}
50
+ fillStyle={props.fillStyle}
51
+ strokeStyle={props.strokeStyle}
52
+ pointStyle={props.pointStyle}
53
+ />
77
54
  </>
78
- )
55
+ );
56
+ };
79
57
 
58
+ CoreDataPlace.defaultProps = {
59
+ fillStyle: DEFAULT_FILL_STYLE,
60
+ pointStyle: DEFAULT_POINT_STYLE,
61
+ strokeStyle: DEFAULT_STROKE_STYLE
80
62
  };
63
+
64
+ export default CoreDataPlace;
@@ -0,0 +1,74 @@
1
+ // @flow
2
+
3
+ import React, { useEffect } from 'react';
4
+ import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
5
+ import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
6
+ import MapUtils from '../utils/Map';
7
+
8
+ type Props = {
9
+ /**
10
+ * The number of miles to buffer the GeoJSON data.
11
+ */
12
+ buffer: number,
13
+
14
+ /**
15
+ * The GeoJSON data representing the location.
16
+ */
17
+ data: { [key: string]: any },
18
+
19
+ /**
20
+ * GeoJSON layer fill style.
21
+ */
22
+ fillStyle?: { [key: string]: any },
23
+
24
+ /**
25
+ * GeoJSON layer point style.
26
+ */
27
+ pointStyle?: { [key: string]: any },
28
+
29
+ /**
30
+ * GeoJSON layer stroke style
31
+ */
32
+ strokeStyle?: { [key: string]: any }
33
+ };
34
+
35
+ const DEFAULT_BUFFER = 2;
36
+
37
+ const LocationMarker = (props: Props) => {
38
+ const map = useMap();
39
+
40
+ /**
41
+ * Sets the bounding box on the map.
42
+ */
43
+ useEffect(() => {
44
+ if (map && props.data) {
45
+ const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
46
+ map.fitBounds(boundingBox);
47
+ }
48
+ }, [props.buffer, props.data]);
49
+
50
+ return (
51
+ <>
52
+ <PulsingMarkerLayer
53
+ id='current'
54
+ data={props.data}
55
+ />
56
+ <MixedGeoJSONLayer
57
+ id='current'
58
+ data={props.data}
59
+ fillStyle={props.fillStyle}
60
+ strokeStyle={props.strokeStyle}
61
+ pointStyle={props.pointStyle}
62
+ />
63
+ </>
64
+ );
65
+ };
66
+
67
+ LocationMarker.defaultProps = {
68
+ buffer: DEFAULT_BUFFER,
69
+ fillStyle: DEFAULT_FILL_STYLE,
70
+ pointStyle: DEFAULT_POINT_STYLE,
71
+ strokeStyle: DEFAULT_STROKE_STYLE
72
+ };
73
+
74
+ export default LocationMarker;
@@ -1,14 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import MapboxDraw from '@mapbox/mapbox-gl-draw';
4
- import {
5
- bbox,
6
- bboxPolygon,
7
- buffer,
8
- feature,
9
- type FeatureCollection,
10
- type GeometryCollection
11
- } from '@turf/turf';
4
+ import { feature, type FeatureCollection, type GeometryCollection } from '@turf/turf';
12
5
  import maplibregl from 'maplibre-gl';
13
6
  import React, {
14
7
  useCallback,
@@ -21,6 +14,7 @@ import React, {
21
14
  import Map, { MapRef } from 'react-map-gl';
22
15
  import _ from 'underscore';
23
16
  import DrawControl from './DrawControl';
17
+ import MapUtils from '../utils/Map';
24
18
  import './MapDraw.css';
25
19
 
26
20
  // Override the MapboxDraw components to use MapLibre styles
@@ -106,19 +100,10 @@ const MapDraw = (props: Props) => {
106
100
  */
107
101
  useEffect(() => {
108
102
  if (loaded && props.data) {
109
- // Convert the GeoJSON into a bounding box
110
- const box = bbox(props.data);
103
+ // Get the bounding box for the passed data
104
+ const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
111
105
 
112
- // Convert the bounding box to a polygon
113
- const polygon = bboxPolygon(box);
114
-
115
- // Create a buffer around the polygon
116
- const polygonBuffer = buffer(polygon, props.buffer, { units: 'miles' });
117
-
118
- // Convert the buffer to a bounding box
119
- const boundingBox = bbox(polygonBuffer);
120
-
121
- // Sets the bounding box for the current geometry.
106
+ // Sets the bounding box for the current geometry
122
107
  if (_.every(boundingBox, _.isFinite)) {
123
108
  const [minLng, minLat, maxLng, maxLat] = boundingBox;
124
109
  const bounds = [[minLng, minLat], [maxLng, maxLat]];
@@ -4,6 +4,10 @@
4
4
  export { default as DrawControl } from './components/DrawControl';
5
5
  export { default as GeoJsonLayer } from './components/GeoJsonLayer';
6
6
  export { default as LayerMenu } from './components/LayerMenu';
7
+ export { default as LocationMarker } from './components/LocationMarker';
7
8
  export { default as MapControl } from './components/MapControl';
8
9
  export { default as MapDraw } from './components/MapDraw';
9
10
  export { default as RasterLayer } from './components/RasterLayer';
11
+
12
+ // Utils
13
+ export { default as Map } from './utils/Map';
@@ -0,0 +1,35 @@
1
+ // @flow
2
+
3
+ import { bbox, bboxPolygon, buffer } from '@turf/turf';
4
+
5
+ /**
6
+ * Returns a bounding box for the passed geometry (with optional buffer).
7
+ *
8
+ * @param geometry
9
+ * @param bufferDistance
10
+ *
11
+ * @returns {BBox}
12
+ */
13
+ const getBoundingBox = (geometry, bufferDistance = null) => {
14
+ // Convert the GeoJSON into a bounding box
15
+ const box = bbox(geometry);
16
+
17
+ // Convert the bounding box to a polygon
18
+ const polygon = bboxPolygon(box);
19
+
20
+ // Create a buffer around the polygon (if a distance is provided)
21
+ let polygonBuffer;
22
+
23
+ if (bufferDistance) {
24
+ polygonBuffer = buffer(polygon, bufferDistance, { units: 'miles' });
25
+ } else {
26
+ polygonBuffer = polygon;
27
+ }
28
+
29
+ // Convert the buffer to a bounding box
30
+ return bbox(polygonBuffer);
31
+ };
32
+
33
+ export default {
34
+ getBoundingBox
35
+ };
@@ -0,0 +1,38 @@
1
+ // @flow
2
+
3
+ export const DEFAULT_POINT_STYLE = {
4
+ type: 'circle',
5
+ paint: {
6
+ 'circle-radius': [
7
+ 'interpolate',
8
+ ['linear'],
9
+ ['number', ['get', 'point_count'], 1],
10
+ 0, 4,
11
+ 10, 14
12
+ ],
13
+ 'circle-stroke-width': 1,
14
+ 'circle-color': [
15
+ 'case',
16
+ ['boolean', ['feature-state', 'hover'], false],
17
+ '#3b62ff',
18
+ '#ff623b'
19
+ ],
20
+ 'circle-stroke-color': '#8d260c'
21
+ }
22
+ };
23
+
24
+ export const DEFAULT_FILL_STYLE = {
25
+ type: 'fill',
26
+ paint: {
27
+ 'fill-color': '#ff623b',
28
+ 'fill-opacity': 0.2
29
+ }
30
+ };
31
+
32
+ export const DEFAULT_STROKE_STYLE = {
33
+ type: 'line',
34
+ paint: {
35
+ 'line-color': '#ff623b',
36
+ 'line-opacity': 0.6
37
+ }
38
+ };