@defra/interactive-map 0.0.54-alpha → 0.0.55-alpha
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/assets/templates/add-polygons.njk +1 -1
- package/assets/templates/add-symbols.njk +4 -4
- package/assets/templates/draw-tools.njk +7 -7
- package/assets/templates/marker-panel.njk +5 -5
- package/assets/templates/place-marker.njk +8 -8
- package/assets/templates/search-control.njk +1 -1
- package/assets/templates/select-feature.njk +7 -7
- package/assets/templates/style-switcher.njk +4 -4
- package/assets/templates/toggle-marker-label.njk +3 -3
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/im-core.js.LICENSE.txt +0 -30
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.LICENSE.txt +0 -20
- package/docs/api.md +3 -13
- package/docs/building-a-plugin.md +2 -2
- package/docs/examples/add-marker-with-panel.mdx +46 -44
- package/docs/examples/add-polygons.mdx +100 -98
- package/docs/examples/add-symbols.mdx +75 -73
- package/docs/examples/basic-map.mdx +16 -14
- package/docs/examples/button-map.mdx +16 -14
- package/docs/examples/draw-tools.mdx +119 -117
- package/docs/examples/place-marker.mdx +51 -49
- package/docs/examples/search-control.mdx +22 -20
- package/docs/examples/select-feature.mdx +107 -105
- package/docs/examples/style-switcher.mdx +47 -45
- package/docs/examples/toggle-marker-label.mdx +30 -28
- package/docs/getting-started.md +26 -24
- package/docs/plugins/draw.md +10 -10
- package/docs/plugins/interact.md +9 -9
- package/docs/plugins/plugin-descriptor.md +1 -1
- package/docs/plugins/search.md +3 -3
- package/docusaurus.config.cjs +23 -0
- package/package.json +3 -7
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/index.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/esm/index.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/index.js +1 -1
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/esm/index.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/index.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/layerAdapter.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/adapters/maplibre/styles.js +3 -2
- package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/menu/dist/esm/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/umd/index.js +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/esm/index.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/src/index.js +27 -4
- package/providers/beta/openlayers/src/index.test.js +47 -0
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
- package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +41 -12
- package/providers/maplibre/src/index.test.js +43 -12
- package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
- package/providers/maplibre/src/utils/spatial.js +22 -12
- package/providers/maplibre/src/utils/spatial.test.js +6 -6
- package/providers/maplibre/src/utils/workerUrl.js +15 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
- package/rollup.esm.mjs +38 -1
- package/src/InteractiveMap/InteractiveMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.test.js +9 -2
- package/src/InteractiveMap/domStateManager.js +21 -1
- package/src/InteractiveMap/domStateManager.test.js +48 -1
- package/src/InteractiveMap/polyfills.js +4 -3
- package/src/InteractiveMap/polyfills.test.js +12 -0
- package/src/types.js +3 -5
- package/webpack.dev.mjs +2 -0
- package/webpack.umd.mjs +28 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[657],{790(e,s,i){i.r(s),i.d(s,{manifest:()
|
|
1
|
+
"use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[657],{790:function(e,s,i){i.r(s),i.d(s,{manifest:function(){return m}});var t=i(738),a="app:ready",l=i(287),n={small:1,medium:1.5,large:2},m={InitComponent:function(e){var s=e.pluginConfig,i=e.services.eventBus,n=function(){i.emit("map:initmapstyles",s.mapStyles)};return(0,t.useEffect)(function(){return i.on(a,n),function(){return i.off(a,n)}},[]),(0,l.jsx)(l.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:function(e){var s=e.mapState,i=e.pluginConfig,t=e.services,a=e.mapProvider,m=s.mapStyle,c=s.mapSize,r=i.mapStyles,p=t.eventBus,d=a.capabilities.supportsMapSizes;return(0,l.jsxs)("div",{className:"im-c-map-styles",children:[(0,l.jsx)("div",{className:"im-c-map-styles__group",children:(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:r.filter(function(e){return e.url}).map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===m.id,onClick:function(){return s=e,void p.emit("map:setstyle",s);var s},children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsx)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id)})})}),d&&(0,l.jsxs)("div",{className:"im-c-map-styles__group",children:[(0,l.jsx)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button",onClick:function(){return s=e,p.emit("map:setsize",s),void p.emit("map:setpixelratio",window.devicePixelRatio*n[s]);var s},"aria-pressed":e===c,children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[(0,l.jsx)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,l.jsx)("g",{style:{transform:"scale(".concat(n[e],")"),transformOrigin:"8px 52px"},children:(0,l.jsx)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e)})})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.mapStylesPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return"im-map-styles-plugin.js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.mapStylesPlugin:",o.l=function(r,n,i,a){if(t[r])t[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==e+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",e+i),u.src=r),t[r]=[n];var s=function(e,n){u.onerror=u.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var a=o.p+o.u(e),u=new Error;o.l(a,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+e+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,a=r[0],u=r[1],c=r[2],f=0;if(a.some(function(e){return 0!==t[e]})){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(e&&e(r);f<a.length;f++)i=a[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function a(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,p=Object.create(a.prototype);return u(p,"_invoke",function(r,n,o){var i,a,u,f=0,p=o||[],l=!1,s={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,a=0,u=t,s.n=r,c}};function d(r,n){for(a=r,u=n,e=0;!l&&f&&!o&&e<p.length;e++){var o,i=p[e],d=s.p,y=i[2];r>3?(o=y===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,s.n=y,a=0))}if(o||r>1)return c;throw l=!0,n}return function(o,p,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,y),a=p,u=y;(e=a<2?t:u)||!l;){i||(a?a<3?(a>1&&(s.n=-1),d(a,u)):s.n=u:s.v=u);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(l=s.n<0)?u:r.call(n,s))!==c)break}catch(e){i=t,a=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,o,i),!0),p}var c={};function f(){}function p(){}function l(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(u(e={},n,function(){return this}),e),d=l.prototype=f.prototype=Object.create(s);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=l,u(d,"constructor",l),u(l,"constructor",p),p.displayName="GeneratorFunction",u(l,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:y}})()}function u(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}u=function(t,e,r,n){function i(e,r){u(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},u(t,e,r,n)}function c(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function f(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:"mapStyles",manifest:r.manifest,mapStyles:r.mapStyles,load:(t=a().m(function t(){var e;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(657).then(o.bind(o,790));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)})},function(){return e.apply(this,arguments)}),handlesMapStyle:!0,api:{}}}return o.d(i,{default:function(){return f}}),i.default}()});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as r,useMemo as
|
|
1
|
+
import{useRef as r,useMemo as t}from"preact/compat";import{jsx as a,jsxs as l}from"preact/jsx-runtime";const e={small:1,medium:1.5,large:2},i={metric:[{threshold:1,abbr:"m",abbrPlural:"m",unit:"metre",unitPlural:"metres",factor:1},{threshold:1e3,abbr:"km",abbrPlural:"km",unit:"kilometre",unitPlural:"kilometres",factor:.001}],imperial:[{threshold:1609.344,abbr:"mi",abbrPlural:"mi",unit:"mile",unitPlural:"miles",factor:1/1609.344},{threshold:.9144,abbr:"yd",abbrPlural:"yds",unit:"yard",unitPlural:"yards",factor:1/.9144},{threshold:.3048,abbr:"ft",abbrPlural:"ft",unit:"foot",unitPlural:"feet",factor:1/.3048}]},b=r=>{const t=Math.pow(10,Math.floor(Math.log10(r))),a=r/t;let l;return l=a>=10?10:a>=5?5:a>=3?3:a>=2?2:1,l*t};const n={controls:[{id:"scaleBar",label:"Scale bar",mobile:{slot:"right-bottom"},tablet:{slot:"right-bottom"},desktop:{slot:"right-bottom"},render:function({mapState:n,pluginConfig:o}){const{resolution:u,mapSize:s}=n,c=r(null),m=t(()=>{if(!u)return{width:0,label:"",abbr:"",unit:""};return((r,t,a,l)=>{const n=r/e[l],o=n*t,u=i[a];for(const{abbr:r,abbrPlural:a,unit:l,unitPlural:e,factor:i}of u){const u=b(o*i);if(u>=1&&u<1e3){const b=u/i/n;if(b<=t)return{label:u,abbr:u>1?a:r,width:b,unit:u>1?e:l}}}const s=u[u.length-1],c=o*s.factor,m=b(c),d=m>1?s.abbrPlural:s.abbr,h=m>1?s.abbrPlural:s.abbr;return{label:m,abbr:d,width:m/s.factor/n,unit:h}})(u/1,120,o.units,s)},[u,s,o.units]);return a("div",{className:"im-c-scale-bar",ref:c,style:{width:`${m.width}px`},children:l("span",{className:"im-c-scale-bar__label",children:[a("span",{className:"im-u-visually-hidden",children:"Scale bar: "}),m.label,a("span",{"aria-hidden":"true",children:m.abbr}),a("span",{className:"im-u-visually-hidden",children:m.unit})]})})}}]};export{n as manifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/regenerator";function t(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=n.manifest,i=n.units;return{id:"scaleBar",manifest:a,units:void 0===i?"metric":i,load:(t=r(e.mark(function r(){var t;return e.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=1,import(/* webpackChunkName: "im-scale-bar-plugin" */ "./im-scale-bar-plugin.js");case 1:return t=r.sent.manifest,r.abrupt("return",t);case 2:case"end":return r.stop()}},r)})),function(){return t.apply(this,arguments)})}}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[996],{405(r,t,
|
|
1
|
+
"use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[996],{405:function(r,t,e){e.r(t),e.d(t,{manifest:function(){return b}});var a=e(738);function n(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,a=Array(t);e<t;e++)a[e]=r[e];return a}var l={small:1,medium:1.5,large:2},i={metric:[{threshold:1,abbr:"m",abbrPlural:"m",unit:"metre",unitPlural:"metres",factor:1},{threshold:1e3,abbr:"km",abbrPlural:"km",unit:"kilometre",unitPlural:"kilometres",factor:.001}],imperial:[{threshold:1609.344,abbr:"mi",abbrPlural:"mi",unit:"mile",unitPlural:"miles",factor:1/1609.344},{threshold:.9144,abbr:"yd",abbrPlural:"yds",unit:"yard",unitPlural:"yards",factor:1/.9144},{threshold:.3048,abbr:"ft",abbrPlural:"ft",unit:"foot",unitPlural:"feet",factor:1/.3048}]},o=function(r){var t=Math.pow(10,Math.floor(Math.log10(r))),e=r/t;return(e>=10?10:e>=5?5:e>=3?3:e>=2?2:1)*t},u=e(287),b={controls:[{id:"scaleBar",label:"Scale bar",mobile:{slot:"right-bottom"},tablet:{slot:"right-bottom"},desktop:{slot:"right-bottom"},render:function(r){var t=r.mapState,e=r.pluginConfig,b=t.resolution,s=t.mapSize,f=(0,a.useRef)(null),c=(0,a.useMemo)(function(){return b?function(r,t,e,a){var u,b=r/l[a],s=120*b,f=i[e],c=function(r,t){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=function(r,t){if(r){if("string"==typeof r)return n(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(r,t):void 0}}(r))||t&&r&&"number"==typeof r.length){e&&(r=e);var a=0,l=function(){};return{s:l,n:function(){return a>=r.length?{done:!0}:{done:!1,value:r[a++]}},e:function(r){throw r},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,u=!1;return{s:function(){e=e.call(r)},n:function(){var r=e.next();return o=r.done,r},e:function(r){u=!0,i=r},f:function(){try{o||null==e.return||e.return()}finally{if(u)throw i}}}}(f);try{for(c.s();!(u=c.n()).done;){var d=u.value,h=d.abbr,m=d.abbrPlural,y=d.unit,p=d.unitPlural,v=d.factor,g=o(s*v);if(g>=1&&g<1e3){var P=g/v/b;if(P<=120)return{label:g,abbr:g>1?m:h,width:P,unit:g>1?p:y}}}}catch(r){c.e(r)}finally{c.f()}var w=f[f.length-1],j=s*w.factor,k=o(j),S=k>1?w.abbrPlural:w.abbr,x=k>1?w.abbrPlural:w.abbr;return{label:k,abbr:S,width:k/w.factor/b,unit:x}}(b/1,0,e.units,s):{width:0,label:"",abbr:"",unit:""}},[b,s,e.units]);return(0,u.jsx)("div",{className:"im-c-scale-bar",ref:f,style:{width:"".concat(c.width,"px")},children:(0,u.jsxs)("span",{className:"im-c-scale-bar__label",children:[(0,u.jsx)("span",{className:"im-u-visually-hidden",children:"Scale bar: "}),c.label,(0,u.jsx)("span",{"aria-hidden":"true",children:c.abbr}),(0,u.jsx)("span",{className:"im-u-visually-hidden",children:c.unit})]})})}}]}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.scaleBarPlugin=t())}(this,()
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.scaleBarPlugin=t())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,t,r={738:function(e){e.exports=preactCompat},287:function(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(t,r){return o.f[r](e,t),t},[]))},o.u=function(e){return"im-scale-bar-plugin.js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="defra.scaleBarPlugin:",o.l=function(r,n,i,u){if(e[r])e[r].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),s=0;s<f.length;s++){var l=f[s];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){a=l;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",t+i),a.src=r),e[r]=[n];var p=function(t,n){a.onerror=a.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){var e={57:0};o.f.j=function(t,r){var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=e[t]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(t),a=new Error;o.l(u,function(r){if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+t,t)}};var t=function(t,r){var n,i,u=r[0],a=r[1],c=r[2],f=0;if(u.some(function(t){return 0!==e[t]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(t&&t(r);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var i={};function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,s=Object.create(u.prototype);return a(s,"_invoke",function(r,n,o){var i,u,a,f=0,s=o||[],l=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,a=e,p.n=r,c}};function d(r,n){for(u=r,a=n,t=0;!l&&f&&!o&&t<s.length;t++){var o,i=s[t],d=p.p,v=i[2];r>3?(o=v===n)&&(a=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,p.v=n,p.n=i[1]):d<v&&(o=r<3||i[0]>n||n>v)&&(i[4]=r,i[5]=n,p.n=v,u=0))}if(o||r>1)return c;throw l=!0,n}return function(o,s,v){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&d(s,v),u=s,a=v;(t=u<2?e:a)||!l;){i||(u?u<3?(u>1&&(p.n=-1),d(u,a)):p.n=a:p.v=a);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=p.n<0)?a:r.call(n,p))!==c)break}catch(t){i=e,u=1,a=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),s}var c={};function f(){}function s(){}function l(){}t=Object.getPrototypeOf;var p=[][n]?t(t([][n]())):(a(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(p);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=l,a(d,"constructor",l),a(l,"constructor",s),s.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:v}})()}function a(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}a=function(e,t,r,n){function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},a(e,t,r,n)}function c(e,t,r,n,o,i,u){try{var a=e[i](u),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function f(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.manifest,i=r.units;return{id:"scaleBar",manifest:n,units:void 0===i?"metric":i,load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(996).then(o.bind(o,405));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){c(i,n,o,u,a,"next",e)}function a(e){c(i,n,o,u,a,"throw",e)}u(void 0)})},function(){return t.apply(this,arguments)})}}return o.d(i,{default:function(){return f}}),i.default}()});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as e}from"preact/compat";import{jsx as
|
|
1
|
+
import{useEffect as e}from"preact/compat";import{jsx as o}from"preact/jsx-runtime";const t={PERMISSION_DENIED:"Location permission denied. Please enable it in your browser settings.",POSITION_UNAVAILABLE:"Location information is unavailable.",TIMEOUT:"The location request timed out. Please try again.",FALLBACK:"Unable to get your location."};const n={slot:"right-top",showLabel:!1},i={InitComponent:function({appConfig:o,appState:n,pluginState:i,mapState:a,mapProvider:l,buttonConfig:r}){const{useLocation:s}=r;return e(()=>{if(a.isMapReady)return function({appState:e,pluginState:o,mapProvider:n,useLocationButton:i}){const{dispatch:a,buttonRefs:l}=e,{dispatch:r}=o,s=e=>e&&"number"==typeof e.code&&t[e.code]||t.FALLBACK;i.onClick=()=>{navigator.geolocation.getCurrentPosition(e=>{const{latitude:o,longitude:t}=e.coords;try{n.setView({center:[t,o],zoom:12})}catch(e){console.log("Map provider failed to pan:",e)}},e=>{const o=s(e),t=l.current[i.id];r({type:"SET_ERROR_MESSAGE",payload:o}),a({type:"OPEN_PANEL",payload:{panelId:"useLocation",props:{triggeringElement:t}}})},{enableHighAccuracy:!0,maximumAge:0,timeout:1e4})};let c=null}({appState:n,pluginState:i,mapProvider:l,useLocationButton:s}),()=>{s.onClick=null}},[a.isMapReady]),null},reducer:{initialState:{errorMessage:null},actions:{SET_ERROR_MESSAGE:(e,o)=>({...e,errorMessage:o})}},buttons:[{id:"useLocation",group:{label:"Location",slotOrder:0},label:"Use your location",iconId:"locateFixed",keepFocus:!0,hiddenWhen:()=>!navigator.geolocation,mobile:n,tablet:n,desktop:n}],panels:[{id:"useLocation",label:"Problem getting your location",mobile:{slot:"banner",open:!1,dismissible:!0,modal:!0},tablet:{slot:"banner",open:!1,dismissible:!0,modal:!0},desktop:{slot:"banner",open:!1,dismissible:!0,modal:!0},render:({pluginState:e})=>{const{errorMessage:t}=e;return o("div",{className:"im-c-use-location",children:o("p",{children:t})})}}],icons:[{id:"locateFixed",svgContent:'<line x1="2" x2="5" y1="12" y2="12"/><line x1="19" x2="22" y1="12" y2="12"/><line x1="12" x2="12" y1="2" y2="5"/><line x1="12" x2="12" y1="19" y2="22"/><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="3"/>'}]};export{i as manifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/regenerator";function t(){return{id:"useLocation",load:(t=r(e.mark(function r(){var t;return e.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=1,import(/* webpackChunkName: "im-use-location-plugin" */ "./im-use-location-plugin.js");case 1:return t=r.sent.manifest,r.abrupt("return",t);case 2:case"end":return r.stop()}},r)})),function(){return t.apply(this,arguments)})};var t}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[419],{528(e,t,
|
|
1
|
+
"use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[419],{528:function(e,t,n){function o(e){return o="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},o(e)}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=function(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.r(t),n.d(t,{manifest:function(){return f}});var c={SET_ERROR_MESSAGE:function(e,t){return i(i({},e),{},{errorMessage:t})}},l=n(738),u={PERMISSION_DENIED:"Location permission denied. Please enable it in your browser settings.",POSITION_UNAVAILABLE:"Location information is unavailable.",TIMEOUT:"The location request timed out. Please try again.",FALLBACK:"Unable to get your location."},s=n(287),p={slot:"right-top",showLabel:!1},f={InitComponent:function(e){e.appConfig;var t=e.appState,n=e.pluginState,o=e.mapState,r=e.mapProvider,i=e.buttonConfig.useLocation;return(0,l.useEffect)(function(){if(o.isMapReady)return function(e){var t=e.appState,n=e.pluginState,o=e.mapProvider,r=e.useLocationButton,i=t.dispatch,a=t.buttonRefs,c=n.dispatch;r.onClick=function(){navigator.geolocation.getCurrentPosition(function(e){var t=e.coords,n=t.latitude,r=t.longitude;try{o.setView({center:[r,n],zoom:12})}catch(e){console.log("Map provider failed to pan:",e)}},function(e){var t=function(e){return e&&"number"==typeof e.code&&u[e.code]||u.FALLBACK}(e),n=a.current[r.id];c({type:"SET_ERROR_MESSAGE",payload:t}),i({type:"OPEN_PANEL",payload:{panelId:"useLocation",props:{triggeringElement:n}}})},{enableHighAccuracy:!0,maximumAge:0,timeout:1e4})}}({appState:t,pluginState:n,mapProvider:r,useLocationButton:i}),function(){i.onClick=null}},[o.isMapReady]),null},reducer:{initialState:{errorMessage:null},actions:c},buttons:[{id:"useLocation",group:{label:"Location",slotOrder:0},label:"Use your location",iconId:"locateFixed",keepFocus:!0,hiddenWhen:function(){return!navigator.geolocation},mobile:p,tablet:p,desktop:p}],panels:[{id:"useLocation",label:"Problem getting your location",mobile:{slot:"banner",open:!1,dismissible:!0,modal:!0},tablet:{slot:"banner",open:!1,dismissible:!0,modal:!0},desktop:{slot:"banner",open:!1,dismissible:!0,modal:!0},render:function(e){var t=e.pluginState.errorMessage;return(0,s.jsx)("div",{className:"im-c-use-location",children:(0,s.jsx)("p",{children:t})})}}],icons:[{id:"locateFixed",svgContent:'<line x1="2" x2="5" y1="12" y2="12"/><line x1="19" x2="22" y1="12" y2="12"/><line x1="12" x2="12" y1="2" y2="5"/><line x1="12" x2="12" y1="19" y2="22"/><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="3"/>'}]}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.useLocationPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return"im-use-location-plugin.js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.useLocationPlugin:",o.l=function(r,n,i,u){if(t[r])t[r].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var s=f[p];if(s.getAttribute("src")==r||s.getAttribute("data-webpack")==e+i){a=s;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",e+i),a.src=r),t[r]=[n];var l=function(e,n){a.onerror=a.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(l.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=l.bind(null,a.onerror),a.onload=l.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(e),a=new Error;o.l(u,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,u=r[0],a=r[1],c=r[2],f=0;if(u.some(function(e){return 0!==t[e]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(e&&e(r);f<u.length;f++)i=u[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function u(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return a(p,"_invoke",function(r,n,o){var i,u,a,f=0,p=o||[],s=!1,l={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,u=0,a=t,l.n=r,c}};function d(r,n){for(u=r,a=n,e=0;!s&&f&&!o&&e<p.length;e++){var o,i=p[e],d=l.p,b=i[2];r>3?(o=b===n)&&(a=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,l.v=n,l.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,l.n=b,u=0))}if(o||r>1)return c;throw s=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(s&&1===p&&d(p,b),u=p,a=b;(e=u<2?t:a)||!s;){i||(u?u<3?(u>1&&(l.n=-1),d(u,a)):l.n=a:l.v=a);try{if(f=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,a)))throw TypeError("iterator result is not an object");if(!e.done)return e;a=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=l.n<0)?a:r.call(n,l))!==c)break}catch(e){i=t,u=1,a=e}finally{f=1}}return{value:e,done:s}}}(r,o,i),!0),p}var c={};function f(){}function p(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(a(e={},n,function(){return this}),e),d=s.prototype=f.prototype=Object.create(l);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,a(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=s,a(d,"constructor",s),a(s,"constructor",p),p.displayName="GeneratorFunction",a(s,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function a(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}a=function(t,e,r,n){function i(e,r){a(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},a(t,e,r,n)}function c(t,e,r,n,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,o)}function f(){return{id:"useLocation",load:(t=u().m(function t(){var e;return u().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(419).then(o.bind(o,528));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function u(t){c(i,n,o,u,a,"next",t)}function a(t){c(i,n,o,u,a,"throw",t)}u(void 0)})},function(){return e.apply(this,arguments)})};var t,e}return o.d(i,{default:function(){return f}}),i.default}()});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@
|
|
1
|
+
import e from"@arcgis/core/layers/VectorTileLayer.js";import t from"@arcgis/core/layers/FeatureLayer.js";import i from"@arcgis/core/layers/GroupLayer.js";import{g as a,L as r}from"./layerAdapter.js";import{D as s,d as y,l}from"./im-datasets-plugin.js";import"preact/compat";import"preact/jsx-runtime";class o extends s{applyLayerPaintProperties(e){const{mapStyle:t}=y;return this.hasStroke&&(e["line-color"]=a(this.style.stroke,t.id)),this.hasFill&&(e["fill-color"]=a(this.style.fill,t.id)),e}get esriGroupId(){return void 0===this._datasetDefinition.esriGroupId?this.parent?.esriGroupId:this._datasetDefinition.esriGroupId}get useServerStyle(){return Boolean(this._datasetDefinition.esriUseServerStyle)}get renderer(){if("FeatureService"!==this.type)return;const e=this._datasetDefinition.style?.renderer||this.parent?.renderer;if(!e)return;const{mapStyle:t}=y,i=structuredClone(e);return i.symbol?.color&&(i.symbol.color=a(i.symbol.color,t.id)),i.symbol?.outline?.color&&(i.symbol.outline.color=a(i.symbol.outline.color,t.id)),i}}const p=e=>{if("baseLayer"===e.id)return-1/0;if(e.id.includes("ketchLayer"))return 1/0;const t="group"===e.type?e.layers?.items?.[0]?.id:e.id;return y._orderedDatasets.indexOf(t)};class n extends r{constructor(e){super(),this.ready=new Promise(e=>{this.resolveReady=e}),this._mapProvider=e,this._map=e.map,this._mapVisibilityLayers={},this._mapOpacityLayers={},this._groupLayers={}}createDataset(e){return new o(e)}async init(){const e=y.topLevelDatasets(),t=async e=>this._addLayers(e).then(()=>{const t=this._mapVisibilityLayers[e.id];e.sublayers?.forEach(e=>{"visible"===e.visibility&&this._applyStyleLayerPaintProperties(e,t)}),this.applyDatasetVisibility(e.id)});for(const i of e)"visible"===i.visibility&&await t(i);this._reorderLayers();for(const i of e)"visible"!==i.visibility&&await t(i);await this.onMapStyleChange(),await this.applyGlobalOpacity(),await Promise.all(e.map(e=>this.applyDatasetVisibility(e.id))),this._reorderLayers(),this.resolveReady()}_reorderLayers(){const e=this._map?.allLayers?.items;if(!e?.length)return;[...e.filter(e=>"group"!==e.parent?.type)].sort((e,t)=>p(e)-p(t)).forEach((e,t)=>this._map.reorder(e,t)),this._reorderGroupLayers()}_reorderGroupLayers(){Object.values(this._groupLayers).forEach(e=>{[...e?.allLayers?.items||[]].filter(Boolean).sort((e,t)=>p(e)-p(t)).forEach((t,i)=>e?.reorder?.(t,i))})}_addGroupLayer(e){if(!this._groupLayers[e]){const t=new i({id:e,opacity:1,visible:!0});this._groupLayers[e]=t,this._map.add(t)}return this._groupLayers[e]}async _addFeatureLayers(e){const i=new t({id:e.id,url:e.tiles,renderer:e.renderer,opacity:1,visible:!1});this._mapVisibilityLayers[e.id]=i,this._mapOpacityLayers[e.id]=i;try{return this._map.add(i),i.when()}catch(t){l.error(`Error adding FeatureLayer for dataset ${e.id}:`,t)}return null}async _addLayers(t){const{type:i,esriGroupId:a,tiles:r}=t;if(!r)return null;if("FeatureService"===i)return this._addFeatureLayers(t);const s=a?this._addGroupLayer(a):this._map,y=new e({id:t.id,url:t.tiles,opacity:1,visible:!1});return this._mapVisibilityLayers[t.id]=y,this._mapOpacityLayers[t.id]=a?s:y,s.add(y),y.when()}async addDataset(e){const t=y.getDataset(e);if(!t)return void l.warn(`addDataset called, but Dataset with id ${e} not found in registry`);await this._addLayers(t);const{parentId:i}=t,a=this._mapVisibilityLayers[i||e];this._reorderLayers(),this.applyDatasetOpacity(e),this._applyStyleLayerPaintProperties(t,a),this.applyDatasetVisibility(e)}async removeDataset(e){const t=y.getDataset(e);if(!t)return;const{esriGroupId:i}=t,a=this._mapVisibilityLayers[e],r=i?this._groupLayers[i]:null,s=r||this._map;a&&(s.remove(a),delete this._mapVisibilityLayers[e],delete this._mapOpacityLayers[e]),0===r?.layers.length&&(this._map.remove(r),delete this._groupLayers[i])}_applyRegistryDatasetVisibility(e){const{id:t,isSublayer:i,parentId:a}=e,r="visible"===e.visibility,s=this._mapVisibilityLayers[i?a:t];s&&(i?this._applyStyleLayerVisibility(e,s):(r&&e.sublayers.forEach(e=>this._applyStyleLayerVisibility(e,s)),s.visible=r))}async applyDatasetVisibility(e){const t=y.getDataset(e);t&&this._applyRegistryDatasetVisibility(t)}async applyGlobalVisibility(){y.forEachDataset(e=>this._applyRegistryDatasetVisibility(e))}async applyDatasetOpacity(e){const t=this._mapOpacityLayers[e],i=y.getDataset(e);t&&i&&(t.opacity=i.opacity)}async applyGlobalOpacity(){Object.entries(this._mapOpacityLayers).forEach(([e,t])=>{const i=y.getDataset(e);i&&(t.opacity=i.opacity)})}_applyStyleLayerVisibility(e,t){const{esriStyleLayerId:i}=e;i&&t&&this.ready.then(()=>{t.setStyleLayerVisibility(i,e.visibility)})}_applyStyleLayerPaintProperties(e,t){const{esriStyleLayerId:i,useServerStyle:a}=e;if(a||!i||!t)return;const r=t.getPaintProperties(i);r&&t.setPaintProperties(i,e.applyLayerPaintProperties(r))}async onMapStyleChange(){y.forEach(e=>{const{id:t,isSublayer:i,parent:a}=e,r=this._mapVisibilityLayers[i?a.id:t];r&&("FeatureService"===e.type?r.renderer=e.renderer:(this._applyStyleLayerVisibility(e,r),this._applyStyleLayerPaintProperties(e,r)))})}async onMapSizeChange(){}async applyFeatureFilter(...e){console.log("TODO: applyFeatureFilter",e)}async setData(...e){console.log("TODO: setData",e)}async applyStyle(...e){console.log("TODO: applyStyle",e)}}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{g as t}from"./layerAdapter.js";import{M as e,a as s}from"./mapboxStyleLayerAdapter.js";import{l as a,d as r}from"./im-datasets-plugin.js";import"preact/compat";import"preact/jsx-runtime";const i=(e,s,a,r,o,y)=>{const{map:l}=e,{sourceId:n,source:h}=s;h&&!l.getSource(n)&&l.addSource(n,h);const m=a.id;return((t,e,s,a,r)=>{const{map:i}=t,{hasSymbol:o,symbolLayerId:y}=e;if(!o||!a||!y||i.getLayer(y))return;const l=a.getSymbolDef(e.style);if(!l)return;const n=a.getSymbolImageId(e.style,s,"normal",r);n&&i.addLayer(e.getSymbolSource(n,t.getSymbolIconLayout(l)))})(e,s,a,r,y),((e,s,a,r,i=1)=>{const{hasFill:o,fillLayerId:y}=s;if(!o||!y||e.getLayer(y))return;const l=r.getPatternImageId(s.style,a,i),n=l?{"fill-pattern":l,"fill-opacity":s.opacity}:{"fill-color":t(s.style.fill,a),"fill-opacity":s.opacity};e.addLayer(s.getFillSource(n))})(l,s,m,o,y),((e,s,a)=>{const{hasStroke:r,strokeLayerId:i}=s;if(!r||e.getLayer(i))return;const o={"line-color":t(s.style.stroke,a),"line-width":s.style.strokeWidth,"line-opacity":s.opacity,...s.style.strokeDashArray?{"line-dasharray":s.style.strokeDashArray}:{}},y=s.getStrokeSource(o);e.addLayer(y)})(l,s,m),s.sublayers?.length?(s.sublayers.forEach(t=>{i(e,t,a,r,o,y)}),n):s.isSublayer?void 0:n};class o extends e{get fillLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasFill?this.id:null}get strokeLayerId(){return this.hasSublayers||this.hasSymbol?null:this.hasStroke?this.hasFill?`${this.id}-stroke`:this.id:null}get symbolLayerId(){return this.hasSublayers?null:this.hasSymbol?this.id:null}get leafLayerIds(){return[this.symbolLayerId,this.fillLayerId,this.strokeLayerId].filter(Boolean)}_geojsonIdStrategy(){return this.idProperty?{promoteId:this.idProperty}:this.generateIds?{generateId:!0}:(this.geojson?.features?.some(t=>"string"==typeof t.id)&&a.warn(`Dataset "${this.id}" has GeoJSON features with string native IDs. MapLibre only surfaces integer native feature IDs through queryRenderedFeatures. Use idProperty to promote a string property instead.`),{})}get source(){if(this.hasDynamicGeoJSON)return this.dynamicGeoJSON.source;if(this.tiles){const t={type:"vector",tiles:this.tiles,minzoom:this.minZoom||0,maxzoom:this.maxZoom||22};return this.idProperty&&this.sourceLayer&&(t.promoteId={[this.sourceLayer]:this.idProperty}),t}return this.geojson?{type:"geojson",data:this.geojson,...this._geojsonIdStrategy()}:null}getSymbolSource(t,e){return{id:this.symbolLayerId,type:"symbol",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility,"icon-image":t,...e,"icon-allow-overlap":!0},...this.filter?{filter:this.filter}:{}}}getFillSource(t){return{id:this.fillLayerId,type:"fill",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:t,...this.filter?{filter:this.filter}:{}}}getStrokeSource(t){return{id:this.strokeLayerId,type:"line",source:this.sourceId,"source-layer":this.sourceLayer,minzoom:this.minZoom,maxzoom:this.maxZoom,layout:{visibility:this.visibility},paint:t,...this.filter?{filter:this.filter}:{}}}}class y extends s{constructor(t,e,s){super(t,e,s),this._datasetSourceMap=new Map,window._datasetSourceMap=this._datasetSourceMap,this._symbolLayerIds=new Set}createDataset(t){return new o(t)}async init(){const{patternConfigs:t,symbolConfigs:e}=r.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(t,e),this._symbolLayerIds.clear(),r.forEachDataset(t=>this._addLayers(t)),await new Promise(t=>this._map.once("idle",t))}removeLayer(t){this._map.getLayer(t)&&this._map.removeLayer(t),this._symbolLayerIds.delete(t)}async addPatternsAndSymbolsToMap(t,e){const s=r.mapStyle,a=s.id;return Promise.all([this._mapProvider.addPatternsToMap(t,a,this._patternRegistry),this._mapProvider.addSymbolsToMap(e,s,this._symbolRegistry)])}destroy(){const t=new Set;r.forEachDataset(e=>{const s=e.sourceId;this._getLayersUsingSource(s).forEach(t=>this.removeLayer(t)),!t.has(s)&&this._map.getSource(s)&&(this._map.removeSource(s),t.add(s))}),this._datasetSourceMap.clear()}async onMapStyleChange(){await new Promise(t=>this._map.once("idle",t));const{patternConfigs:t,symbolConfigs:e}=r.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(t,e),this._symbolLayerIds.clear(),r.forEachDataset(t=>{this._addLayers(t),this._applyFeatureFilter(t)}),this.dynamicSources.forEach(t=>t.reapply())}async onMapSizeChange(){const{mapStyle:t}=r,e=this._pixelRatio,{patternConfigs:s,symbolConfigs:a}=r.getPatternAndSymbolConfigs();await this.addPatternsAndSymbolsToMap(s,a),this._pixelRatio===e&&r.forEach(s=>{const{fillLayerId:a,symbolLayerId:r}=s;if(r&&this._symbolLayerIds.has(r)&&this._map.getLayer(r)){const a=this._symbolRegistry.getSymbolImageId(s.style,t,"normal",e);return void(a&&this._map.setLayoutProperty(r,"icon-image",a))}if(a&&this._map.getLayer(a)){const r=this._patternRegistry.getPatternImageId(s.style,t.id,e);r&&this._map.setPaintProperty(a,"fill-pattern",r)}})}_registerPatternsAndSymbols(t){return this.addPatternsAndSymbolsToMap(t.patternConfigs,t.symbolConfigs)}removeDataset(t){const e=r.getDataset(t);if(!e)return;const{sourceId:s,layerIds:a}=e;a.forEach(t=>this.removeLayer(t));!r.topLevelDatasets().some(e=>e.id!==t&&e.sourceId===s)&&this._map.getSource(s)&&this._map.removeSource(s),this._datasetSourceMap.delete(t)}applyFeatureFilter(t){const e=r.getDataset(t);e&&this._applyFeatureFilter(e)}async applyStyle(t){const e=r.getDataset(t);e.layerIds.forEach(t=>this.removeLayer(t)),await this._registerPatternsAndSymbols(e),this._addLayers(e)}setData(t,e){const s=this._datasetSourceMap.get(t);if(!s)return;const a=this._map.getSource(s);a&&"function"==typeof a.setData&&a.setData(e)}_addLayers(t){const{mapStyle:e}=r,s=i(this._mapProvider,t,e,this._symbolRegistry,this._patternRegistry,this._pixelRatio);this._datasetSourceMap.set(t.id,s),this._maintainSymbolOrdering(t)}_getFirstSymbolLayerId(){const t=this._map.getStyle();if(!t?.layers)return null;const e=t.layers.find(t=>this._symbolLayerIds.has(t.id));return e?.id??null}_maintainSymbolOrdering(t){const e=(t=t.isSublayer?t.parent:t).layerIds.filter(t=>t&&this._map.getLayer(t));e.forEach(t=>{"symbol"===this._map.getLayer(t)?.type?this._symbolLayerIds.add(t):this._symbolLayerIds.delete(t)});const s=this._getFirstSymbolLayerId();s&&e.forEach(t=>{this._symbolLayerIds.has(t)||this._map.moveLayer(t,s)})}_setLayerVisibility(t,e){this._map.getLayer(t)&&this._map.setLayoutProperty(t,"visibility",e)}_applyFeatureFilter(t){t.getLayersWithFilters().forEach(({layerIds:t,filter:e})=>{t.forEach(t=>{this._map.getLayer(t)&&this._map.setFilter(t,e)})})}_setLayerOpacity(t,e){const s=this._map.getLayer(t);if(!s)return;const a={line:"line-opacity",symbol:"icon-opacity"}[s.type]||"fill-opacity";this._map.setPaintProperty(t,a,e)}_getLayersUsingSource(t){const e=this._map.getStyle();return e?.layers?e.layers.filter(e=>e.source===t).map(t=>t.id):[]}}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{M as t,a as e}from"./mapboxStyleLayerAdapter.js";import{d as s,l as r}from"./im-datasets-plugin.js";import{g as a}from"./layerAdapter.js";import i from"ol/source/Vector.js";import o from"ol/layer/Vector.js";import l from"ol/source/VectorTile.js";import y from"ol/layer/VectorTile.js";import h from"ol/format/GeoJSON.js";import n from"ol/format/MVT.js";import d from"ol/Feature.js";import c from"ol/tilegrid/TileGrid.js";import m from"ol/style/Style.js";import p from"ol/style/Stroke.js";import"preact/compat";import"preact/jsx-runtime";class u extends t{get leafLayerIds(){return this.hasSublayers?[]:this.hasFill||this.hasStroke||this.hasSymbol?[this.id]:[]}get source(){return this.hasDynamicGeoJSON?{type:"geojson",data:{type:"FeatureCollection",features:[]}}:this.tiles?{type:"vector",tiles:this.tiles,minzoom:this.minZoom||0,maxzoom:this.maxZoom||22}:this.geojson?{type:"geojson",data:this.geojson}:null}get idStrategy(){return this.hasDynamicGeoJSON?this.dynamicGeoJSON.idProperty||null:this.idProperty||null}get filter(){const t=super.filter;if(!this.sourceLayer)return t;const e=["==",["get","layer"],this.sourceLayer];return t?"all"===t[0]?[...t,e]:["all",t,e]:e}_wrapWithFilter(t){return this.filter?[{filter:this.filter,style:t}]:t}getSymbolMeta({pixelRatio:t,symbolRegistry:e}){if(!this.hasSymbol)return null;const r=e.getSymbolImageId(this.style,s.mapStyle,"normal",t);return r?{imageId:r,anchor:e.getSymbolDef(this.style).anchor,pixelRatio:t}:null}_symbolStyle(t){const e={},s=this.getSymbolMeta(t),r=s&&t.getSymbolDataUri(s.imageId);return r&&(e["icon-src"]=r,e["icon-anchor"]=s.anchor,e["icon-scale"]=1/t.pixelRatio),this._wrapWithFilter(e)}getFlatStyle(t){if(this.hasSymbol)return this._symbolStyle(t);const e=s.mapStyle?.id,r={};return this.hasFill&&!this.hasPattern&&(r["fill-color"]=a(this.style.fill,e)),this.hasStroke&&(r["stroke-color"]=a(this.style.stroke,e),r["stroke-width"]=this.style.strokeWidth,this.style.strokeDashArray&&(r["stroke-line-dash"]=this.style.strokeDashArray)),this._wrapWithFilter(r)}}const f=(t,e)=>{if(t.hasStroke)return new p({color:a(t.style.stroke,e),width:t.style.strokeWidth,lineDash:t.style.strokeDashArray})},g="EPSG:27700",_=new h({dataProjection:g,featureProjection:g}),S=1e-6,b=13e5,L=[0,0,b,b],I=new c({extent:L,origin:[L[0],L[3]],resolutions:Array.from({length:25},(t,e)=>(L[2]-L[0])/(256*2**e)),tileSize:256}),v=(t,e)=>{if(!e)return _.readFeatures(t);const s={...t,features:t.features.map(t=>({...t,id:t.properties?.[e]??t.id}))};return _.readFeatures(s)},D=t=>{const{source:e,id:s,idStrategy:a}=t;if(!e)return null;if("geojson"===e.type){const t=new i;return"string"==typeof e.data?((t,e,s,a)=>{fetch(e).then(t=>{if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}).then(e=>t.addFeatures(v(e,s))).catch(t=>r.warn(`OpenLayers datasets adapter: failed to fetch geojson for dataset "${a}" — ${t.message}`))})(t,e.data,a,s):e.data?.features?.length&&t.addFeatures(v(e.data,a)),t}if("vector"===e.type){const t=Array.isArray(e.tiles)?e.tiles:[e.tiles];return new l({format:new n({featureClass:d,idProperty:a||void 0}),urls:t,projection:g,tileGrid:I})}return r.warn(`OpenLayers datasets adapter: unsupported source type "${e.type}" (dataset "${s}")`),null},P=(t,e={})=>t.hasPattern?((t,{mapStyleId:e,pixelRatio:s,patternRegistry:r,getPatternFill:a,buildFilterEvaluator:i})=>{const o=r.getPatternImageId(t.style,e,s),l=o&&a(o),y=l?new m({fill:l,stroke:f(t,e)}):void 0,h=i(t.filter);return t=>{if(y&&(!h||h(t)))return y}})(t,e):t.getFlatStyle(e);class w extends e{constructor(t,e,s){super(t,e,s),this._sourcesById=new Map,this._layersById=new Map,this.createDataset=this.createDataset.bind(this)}createDataset(t){return new u(t)}get _styleContext(){return{mapStyleId:s.mapStyle?.id,pixelRatio:this._pixelRatio,patternRegistry:this._patternRegistry,symbolRegistry:this._symbolRegistry,getSymbolDataUri:t=>this._mapProvider.getSymbolDataUri(t),getPatternFill:t=>this._mapProvider.getPatternFill(t),buildFilterEvaluator:t=>this._mapProvider.buildFilterEvaluator(t)}}async init(){await Promise.all([this._registerPatterns(),this._registerSymbols()]),s.forEachDataset(t=>this._addLayers(t))}destroy(){this._layersById.forEach(t=>this._map.removeLayer(t)),this._layersById.clear(),this._sourcesById.clear()}async onMapStyleChange(){await Promise.all([this._registerPatterns(),this._registerSymbols()]),s.forEachDataset(t=>this._forEachLeafDataset(t,t=>{this._setLayerStyle(t)})),this._reapplyHighlights()}async onMapSizeChange(){const t=this._pixelRatio;await Promise.all([this._registerPatterns(),this._registerSymbols()]),this._pixelRatio===t&&(s.forEachDataset(t=>this._forEachLeafDataset(t,t=>{(t.hasPattern||t.hasSymbol)&&this._setLayerStyle(t)})),this._reapplyHighlights())}_reapplyHighlights(){this._mapProvider.reapplyHighlights()}_registerPatternsAndSymbols(t){return Promise.all([this._registerPatterns([t]),this._registerSymbols([t])])}removeDataset(t){const e=s.getDataset(t);if(!e)return;e.layerIds.forEach(t=>{const e=this._layersById.get(t);e&&(this._map.removeLayer(e),this._layersById.delete(t))});const{sourceId:r}=e;s.topLevelDatasets().some(e=>e.id!==t&&e.sourceId===r)||this._sourcesById.delete(r)}async applyStyle(t){const e=s.getDataset(t);e&&(await this._registerPatternsAndSymbols(e),this._forEachLeafDataset(e,t=>{this._layersById.has(t.id)?this._setLayerStyle(t):this._addLayers(t)}))}_setLayerOpacity(t,e){this._layersById.get(t)?.setOpacity(e)}_setLayerVisibility(t,e){this._layersById.get(t)?.setVisible("visible"===e)}applyFeatureFilter(t){const e=s.getDataset(t);e&&this._forEachLeafDataset(e,t=>{this._setLayerStyle(t)})}setData(t,e){const r=s.getDataset(t),a=r&&this._sourcesById.get(r.sourceId);a&&(a.clear(),e?.features?.length&&a.addFeatures(v(e,r.idStrategy)))}async _registerPatterns(t=s.topLevelDatasets()){const e=[];t.forEach(t=>this._forEachLeafDataset(t,t=>{t.hasPattern&&e.push(t.style)})),e.length&&await this._mapProvider.addPatternsToMap(e,s.mapStyle?.id,this._patternRegistry,this._pixelRatio)}async _registerSymbols(t=s.topLevelDatasets()){const e=[];t.forEach(t=>this._forEachLeafDataset(t,t=>{t.hasSymbol&&e.push(t.style)})),e.length&&await this._mapProvider.addSymbolsToMap(e,s.mapStyle,this._symbolRegistry,this._pixelRatio)}_setLayerStyle(t){const e=this._layersById.get(t.id);if(e)try{e.setStyle(P(t,this._styleContext)),t.hasSymbol&&e.set("symbolMeta",t.getSymbolMeta(this._styleContext))}catch(e){r.warn(`OpenLayers datasets adapter: failed to build a style for dataset "${t.id}" — ${e.message}`)}}_forEachLeafDataset(t,e){t.hasSublayers?t.sublayers.forEach(t=>this._forEachLeafDataset(t,e)):e(t)}_getOrCreateSource(t){const{sourceId:e}=t;if(this._sourcesById.has(e))return this._sourcesById.get(e);let s;try{s=D(t)}catch(e){return r.warn(`OpenLayers datasets adapter: failed to build a source for dataset "${t.id}" — ${e.message}`),null}return s&&this._sourcesById.set(e,s),s}_addLayers(t){if(t.hasSublayers)return this._getOrCreateSource(t),void t.sublayers.forEach(t=>this._addLayers(t));if(!t.leafLayerIds.length)return;const e=this._getOrCreateSource(t);if(!e)return;let s;try{s=((t,e,s)=>{const r=e instanceof l,a=new(r?y:o)({source:e,style:P(t,s),opacity:t.opacity,visible:"visible"===t.visibility,minZoom:(h=t.minZoom,void 0===h?void 0:h-S),maxZoom:(i=t.maxZoom,void 0===i?void 0:i-S),zIndex:t.hasSymbol?1:0,...r?{renderMode:"vector"}:{}});var i,h;return a.set("layerType",r?"vectorTile":"vector"),a.set("layerId",t.id),t.filter&&a.set("filter",t.filter),t.hasSymbol&&a.set("symbolMeta",t.getSymbolMeta(s)),a})(t,e,this._styleContext)}catch(e){return void r.warn(`OpenLayers datasets adapter: failed to build a style for dataset "${t.id}" — ${e.message}`)}this._map.addLayer(s),this._layersById.set(t.id,s)}}export{w as default};
|