mapicgc-gl-js 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/mapicgc-gl.css +23 -1
- package/dist/mapicgc-gl.js +1 -1
- package/dist/mapicgc-gl.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Biblioteca de mapes ICGC. Envoltori de MaplibreGL
|
|
4
4
|
|
|
5
5
|
<br>
|
|
6
|
-
Versió 0.0.
|
|
6
|
+
Versió 0.0.5
|
|
7
7
|
|
|
8
8
|
<br>
|
|
9
9
|
### Documentació:
|
|
@@ -23,10 +23,9 @@ Versió 0.0.4
|
|
|
23
23
|
2. Afegir les següents línies de codi JS i CSS a l'encapçalament del teu HTML:
|
|
24
24
|
|
|
25
25
|
```html
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
<script src="https://www.unpkg.com/@watergis/maplibre-gl-export@3.0.1/dist/maplibre-gl-export.umd.js"></script>
|
|
28
28
|
|
|
29
|
-
<link rel="stylesheet" href="https://autogitlab.icgc.local/geostarters/icgc/mapicgc/mapicgc-gl-js/-/blob/master/dist/mapicgc-gl.css" />
|
|
30
29
|
<link href="https://www.unpkg.com/@watergis/maplibre-gl-export@3.0.1/dist/maplibre-gl-export.css" rel="stylesheet" />
|
|
31
30
|
```
|
|
32
31
|
|
|
@@ -44,7 +43,6 @@ Versió 0.0.4
|
|
|
44
43
|
- Fons de mapes: Topogràfic, Orto, Híbrid, Gris, Fosc
|
|
45
44
|
|
|
46
45
|
- Afegir capes GeoJson i WMS
|
|
47
|
-
- Cercador
|
|
48
46
|
|
|
49
47
|
- Markers
|
|
50
48
|
|
package/dist/mapicgc-gl.css
CHANGED
|
@@ -923,4 +923,26 @@ h4::selection {
|
|
|
923
923
|
.selection {
|
|
924
924
|
margin-top: 15vh;
|
|
925
925
|
}
|
|
926
|
-
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
.coordControl {
|
|
929
|
+
display: block;
|
|
930
|
+
position: absolute;
|
|
931
|
+
bottom: 0;
|
|
932
|
+
height: 17px;
|
|
933
|
+
margin: 0 auto;
|
|
934
|
+
padding: 2px;
|
|
935
|
+
padding-bottom: 1.5px;
|
|
936
|
+
left: 45%;
|
|
937
|
+
border: none;
|
|
938
|
+
border-radius: 3px;
|
|
939
|
+
font-size: 12px;
|
|
940
|
+
text-align: center;
|
|
941
|
+
color: #222;
|
|
942
|
+
background: hsla(0, 0%, 100%, 0.849);
|
|
943
|
+
}
|
|
944
|
+
@media (max-width: 700px) {
|
|
945
|
+
.coordControl{
|
|
946
|
+
display: none;
|
|
947
|
+
}
|
|
948
|
+
}
|
package/dist/mapicgc-gl.js
CHANGED
|
@@ -53,7 +53,7 @@ return maplibregl$1;
|
|
|
53
53
|
},{}],3:[function(_dereq_,module,exports){
|
|
54
54
|
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Map",{enumerable:!0,get:function(){return _Map.default}});var _Map=_interopRequireDefault(_dereq_("./map/Map"));
|
|
55
55
|
},{"./map/Map":4}],4:[function(_dereq_,module,exports){
|
|
56
|
-
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){"@babel/helpers - typeof";return(_typeof="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)}function _regeneratorRuntime(){function e(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}function t(e,t,r,o){var a=t&&t.prototype instanceof n?t:n,i=Object.create(a.prototype),c=new p(o||[]);return v(i,"_invoke",{value:l(e,r,c)}),i}function r(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}function n(){}function o(){}function a(){}function i(t){["next","throw","return"].forEach(function(r){e(t,r,function(e){return this._invoke(r,e)})})}function c(e,t){function n(o,a,i,c){var l=r(e[o],e,a);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==_typeof(s)&&g.call(s,"__await")?t.resolve(s.__await).then(function(e){n("next",e,i,c)},function(e){n("throw",e,i,c)}):t.resolve(s).then(function(e){u.value=e,i(u)},function(e){return n("throw",e,i,c)})}c(l.arg)}var o;v(this,"_invoke",{value:function(e,r){function a(){return new t(function(t,o){n(e,r,t,o)})}return o=o?o.then(a,a):a()}})}function l(e,t,n){var o=C;return function(a,i){if(o===L)throw new Error("Generator is already running");if(o===S){if("throw"===a)throw i;return{value:y,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var l=u(c,n);if(l){if(l===k)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===C)throw o=S,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=L;var s=r(e,t,n);if("normal"===s.type){if(o=n.done?S:E,s.arg===k)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=S,n.method="throw",n.arg=s.arg)}}}function u(e,t){var n=t.method,o=e.iterator[n];if(o===y)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=y,u(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),k;var a=r(o,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,k;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=y),t.delegate=null,k):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,k)}function s(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function f(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function p(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(s,this),this.reset(!0)}function d(e){if(e||""===e){var t=e[w];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(g.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=y,t.done=!0,t};return n.next=n}}throw new TypeError(_typeof(e)+" is not iterable")}_regeneratorRuntime=function(){return h};var y,h={},m=Object.prototype,g=m.hasOwnProperty,v=Object.defineProperty||function(e,t,r){e[t]=r.value},b="function"==typeof Symbol?Symbol:{},w=b.iterator||"@@iterator",_=b.asyncIterator||"@@asyncIterator",x=b.toStringTag||"@@toStringTag";try{e({},"")}catch(t){e=function(e,t,r){return e[t]=r}}h.wrap=t;var C="suspendedStart",E="suspendedYield",L="executing",S="completed",k={},I={};e(I,w,function(){return this});var G=Object.getPrototypeOf,P=G&&G(G(d([])));P&&P!==m&&g.call(P,w)&&(I=P);var T=a.prototype=n.prototype=Object.create(I);return o.prototype=a,v(T,"constructor",{value:a,configurable:!0}),v(a,"constructor",{value:o,configurable:!0}),o.displayName=e(a,x,"GeneratorFunction"),h.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===o||"GeneratorFunction"===(t.displayName||t.name))},h.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,e(t,x,"GeneratorFunction")),t.prototype=Object.create(T),t},h.awrap=function(e){return{__await:e}},i(c.prototype),e(c.prototype,_,function(){return this}),h.AsyncIterator=c,h.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new c(t(e,r,n,o),a);return h.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},i(T),e(T,x,"Generator"),e(T,w,function(){return this}),e(T,"toString",function(){return"[object Generator]"}),h.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},h.values=d,p.prototype={constructor:p,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=y,this.done=!1,this.delegate=null,this.method="next",this.arg=y,this.tryEntries.forEach(f),!e)for(var t in this)"t"===t.charAt(0)&&g.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=y)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function t(t,n){return a.type="throw",a.arg=e,r.next=t,n&&(r.method="next",r.arg=y),!!n}if(this.done)throw e;for(var r=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var i=g.call(o,"catchLoc"),c=g.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&g.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,k):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),k},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),f(r),k}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;f(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:d(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=y),k}},h}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){function a(e){asyncGeneratorStep(c,n,o,a,i,"next",e)}function i(e){asyncGeneratorStep(c,n,o,a,i,"throw",e)}var c=e.apply(t,r);a(void 0)})}}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}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 a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(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 _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _asyncIterator(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _maplibreGl=_interopRequireDefault(_dereq_("maplibre-gl")),_config=_interopRequireDefault(_dereq_("../config.js")),Map=exports.default=function(){function e(t){var r=this;_classCallCheck(this,e);var n=Object.getOwnPropertyNames(t);if(n&&n.forEach(function(e){t[e]="style"===e?r._dealStyleMaps(t[e]):t[e]}),t)for(var o in _config.default.mapOptions)t.hasOwnProperty(o)||(t[o]=_config.default.mapOptions[o]);else t=_config.default.mapOptions;t.maxZoom=18,t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new _maplibreGl.default.Map(t)}return _createClass(e,[{key:"setCenter",value:function(e){try{this.map.setCenter(e)}catch(e){console.error("Error setting center: ".concat(e.message))}}},{key:"addLayer",value:function(e){try{this.map.addLayer(e)}catch(e){console.error("Error adding layer: ".concat(e.message))}}},{key:"addLayerGeoJSON",value:function(e){var t=this;try{this.map.on("load",function(){t.map.addSource("".concat(e.id,"-sourceIcgcMap"),{type:"geojson",data:e.data}),t.map.addLayer({id:"".concat(e.id,"-layerIcgcMap"),type:e.layerType,source:"".concat(e.id,"-sourceIcgcMap"),layout:e.layout,paint:e.paint})})}catch(e){console.error("Error adding GeoJSON layer: ".concat(e.message))}}},{key:"addLayerWMS",value:function(e){var t=this;try{this.map.on("load",function(){t.map.addSource("".concat(e.id,"-sourceIcgcMap"),{type:"raster",tiles:[e.tiles],tileSize:256}),t.map.addLayer({id:"".concat(e.id,"-layerIcgcMap"),type:"raster",source:"".concat(e.id,"-sourceIcgcMap"),paint:{}})})}catch(e){console.error("Error adding WMS layer: ".concat(e.message))}}},{key:"removeLayer",value:function(e){try{this.map.removeLayer(e)}catch(e){console.error("Error removing layer: ".concat(e.message))}}},{key:"addLogo",value:function(e){try{var t=document.createElement("img");t.src=e.url,t.style.height="62px";var r=document.getElementById("logos"),n=document.createElement("a");n.id=e.id,n.href=e.href,n.target="_blank",n.style.position="relative",n.style.bottom="1px",n.appendChild(t),r.appendChild(n)}catch(e){console.error("Error adding logo: ".concat(e.message))}}},{key:"addBasemaps",value:function(e){var t=this;try{var r=function(e){t.map.setStyle(e.url)},n=document.getElementById("basemap-group");this.map.on("load",function(){e.forEach(function(e){var t=document.createElement("div");t.className="basemap-item",t.title=e.label,t.style.backgroundImage="url('".concat(e.image,"')"),n.appendChild(t),t.addEventListener("click",function(){return r(e)})})})}catch(e){console.error("Error adding basemaps: ".concat(e.message))}}},{key:"addExportControl",value:function(){try{this.map.addControl(new MaplibreExportControl.MaplibreExportControl({PageSize:MaplibreExportControl.Size.A4,PageOrientation:MaplibreExportControl.PageOrientation.Landscape,Format:MaplibreExportControl.Format.PNG,DPI:MaplibreExportControl.DPI[300],Crosshair:!0,PrintableArea:!0,Local:"en"}),"top-right")}catch(e){console.error("Error adding export control: ".concat(e.message))}}},{key:"addMarker",value:function(e){try{var t,r;return void 0===e.text?t=new _maplibreGl.default.Marker(e.options).setLngLat(e.coord).addTo(this.map):(r=new _maplibreGl.default.Popup({offset:e.textOffset}).setText(e.text),t=(new _maplibreGl.default.Marker).setLngLat(e.coord).setPopup(r).addTo(this.map)),t}catch(e){return console.error("Error adding marker: ".concat(e.message)),null}}},{key:"addPopup",value:function(e){try{return(new _maplibreGl.default.Popup).setLngLat(e.coord).setHTML(e.text).addTo(this.map)}catch(e){return console.error("Error adding popup: ".concat(e.message)),null}}},{key:"addFullScreen",value:function(){try{this.map.addControl(new _maplibreGl.default.FullscreenControl)}catch(e){console.error("Error adding fullscreen control: ".concat(e.message))}}},{key:"addLayerTree",value:function(e){var t=this;try{var r=e.features,n=document.getElementById("filter-group");this.map.on("load",function(){for(var o,a=t.map.getStyle().layers,i=0;i<a.length;i++)if("symbol"===a[i].type){o=a[i].id;break}t.map.addSource("".concat(e.id,"-source"),{type:e.type,data:r}),r.features.forEach(function(r){var a=r.properties.icon,i="poi-".concat(a);if(!t.map.getLayer(i)){t.map.addLayer({id:i,type:"circle",source:"".concat(e.id,"-source"),paint:{"circle-radius":6,"circle-color":"#B42222"},filter:["==","icon",a]},o);var c=document.createElement("input");c.type="checkbox",c.id=i,c.checked=!0,n.appendChild(c);var l=document.createElement("label");l.setAttribute("for",i),l.textContent=a,n.appendChild(l),c.addEventListener("change",function(e){t.map.setLayoutProperty(i,"visibility",e.target.checked?"visible":"none")})}})})}catch(e){console.error("Error adding layer tree: ".concat(e.message))}}},{key:"createNavigationControl",value:function(e){try{return new _maplibreGl.default.NavigationControl(e)}catch(e){return console.error("Error creating navigation control: ".concat(e.message)),null}}},{key:"addNavigationControl",value:function(e){try{var t=this.createNavigationControl(e);t&&this.map.addControl(t)}catch(e){console.error("Error adding navigation control: ".concat(e.message))}}},{key:"addAttributionControl",value:function(e){try{this.map.addControl(new _maplibreGl.default.AttributionControl(e.options),e.position)}catch(e){console.error("Error adding attribution control: ".concat(e.message))}}},{key:"_dealStyleMaps",value:function(e){try{var t,r=_createForOfIteratorHelper(_config.default.baseStyles);try{for(r.s();!(t=r.n()).done;){var n=t.value;if(n.name===e)return n.url}}catch(e){r.e(e)}finally{r.f()}return _config.default.baseStyles[0].url}catch(e){return console.error("Error dealing with map styles: ".concat(e.message)),null}}},{key:"addImageLayerICGC",value:function(e,t){try{var r,n,o;if(e.includes("orto")||e.includes("geol")||e.includes("relleu")){if(e.includes("orto"))if(void 0!==t){r=e+t;var a=_config.default.ortoLayersICGC.find(function(e){return e.key===r});a||console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",r,"font-weight: bold; font-style: italic;"),n=a.text,o="ortofoto_color_"+n;var i={id:r,tiles:"https://geoserveis.icgc.cat/servei/catalunya/orto-territorial/wms?&bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&STYLES=&srs=EPSG:3857&transparent=true&width=256&height=256&layers=".concat(o)};this.addLayerWMS(i)}else{var c={id:e+"Actual",tiles:"https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.png"};this.addLayerWMS(c)}if(e.includes("relleu")){var l={id:e+"Actual",tiles:"https://tilemaps.icgc.cat/mapfactory/wmts/relleu/CAT3857/{z}/{x}/{y}.png"};this.addLayerWMS(l)}if(e.includes("geol")){var u={id:e+"Actual",tiles:"https://tilemaps.icgc.cat/mapfactory/wmts/geologia/MON3857NW/{z}/{x}/{y}.png"};this.addLayerWMS(u)}}else console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",e,"font-weight: bold; font-style: italic;")}catch(e){console.error("Error adding ICGC image layer: ".concat(e.message))}}},{key:"addFGBLayerICGC",value:function(){function e(e,r){return t.apply(this,arguments)}var t=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){var n,o,a,i=this;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=_config.default.vectorLayersICGC.find(function(e){return e.key.includes(t)}),n||console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",t,"font-weight: bold; font-style: italic;"),o=n.url,e.next=6,fetch(o);case 6:a=e.sent,this.map.on("load",_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,r,o,c,l,u,s,f;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t={type:"FeatureCollection",features:[]},r=!1,o=!1,e.prev=3,l=_asyncIterator(flatgeobuf.deserialize(a.body));case 5:return e.next=7,l.next();case 7:if(!(r=!(u=e.sent).done)){e.next=13;break}s=u.value,t.features.push(s);case 10:r=!1,e.next=5;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),o=!0,c=e.t0;case 19:if(e.prev=19,e.prev=20,!r||null==l.return){e.next=24;break}return e.next=24,l.return();case 24:if(e.prev=24,!o){e.next=27;break}throw c;case 27:return e.finish(24);case 28:return e.finish(19);case 29:f=n.name+"-source",i.map.addSource(f,{type:"geojson",data:t}),i.map.addLayer({id:n.name+"-fill",type:"fill",source:f,paint:{"fill-color":"#0000FF","fill-opacity":0}}),i.map.addLayer({id:n.name+"-line",type:"line",source:f,paint:{"line-color":"#FFFFFF","line-opacity":.49,"line-width":1}});case 33:case"end":return e.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}))),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.error("Error adding ICGC vector layer: ".concat(e.t0.message));case 13:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"addTerrainICGC",value:function(e){var t=this;this.map.on("load",function(){try{var r=_config.default.urlTerrainICGC.find(function(t){return t.name===e}),n=r.url;t.map.addSource("terrainICGC-src",{type:"raster-dem",tiles:[n],tileSize:512,maxzoom:16}),t.map.setTerrain({source:"terrainMapZen",exaggeration:1.5}),t.map.setTerrain({source:"terrainICGC-src",exaggeration:1.5}),t.map.addControl(new _maplibreGl.default.TerrainControl({source:"terrainICGC-src",exaggeration:1.5}))}catch(e){console.error("Error adding 3D terrain: ".concat(e.message))}})}}]),e}();
|
|
56
|
+
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){"@babel/helpers - typeof";return(_typeof="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)}function _regeneratorRuntime(){function e(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}function t(e,t,r,n){var a=t&&t.prototype instanceof o?t:o,i=Object.create(a.prototype),c=new d(n||[]);return v(i,"_invoke",{value:l(e,r,c)}),i}function r(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}function o(){}function n(){}function a(){}function i(t){["next","throw","return"].forEach(function(r){e(t,r,function(e){return this._invoke(r,e)})})}function c(e,t){function o(n,a,i,c){var l=r(e[n],e,a);if("throw"!==l.type){var s=l.arg,u=s.value;return u&&"object"==_typeof(u)&&g.call(u,"__await")?t.resolve(u.__await).then(function(e){o("next",e,i,c)},function(e){o("throw",e,i,c)}):t.resolve(u).then(function(e){s.value=e,i(s)},function(e){return o("throw",e,i,c)})}c(l.arg)}var n;v(this,"_invoke",{value:function(e,r){function a(){return new t(function(t,n){o(e,r,t,n)})}return n=n?n.then(a,a):a()}})}function l(e,t,o){var n=E;return function(a,i){if(n===x)throw new Error("Generator is already running");if(n===k){if("throw"===a)throw i;return{value:y,done:!0}}for(o.method=a,o.arg=i;;){var c=o.delegate;if(c){var l=s(c,o);if(l){if(l===S)continue;return l}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(n===E)throw n=k,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);n=x;var u=r(e,t,o);if("normal"===u.type){if(n=o.done?k:L,u.arg===S)continue;return{value:u.arg,done:o.done}}"throw"===u.type&&(n=k,o.method="throw",o.arg=u.arg)}}}function s(e,t){var o=t.method,n=e.iterator[o];if(n===y)return t.delegate=null,"throw"===o&&e.iterator.return&&(t.method="return",t.arg=y,s(e,t),"throw"===t.method)||"return"!==o&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+o+"' method")),S;var a=r(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,S;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=y),t.delegate=null,S):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S)}function u(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function f(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function d(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(u,this),this.reset(!0)}function p(e){if(e||""===e){var t=e[w];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(g.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=y,t.done=!0,t};return o.next=o}}throw new TypeError(_typeof(e)+" is not iterable")}_regeneratorRuntime=function(){return h};var y,h={},m=Object.prototype,g=m.hasOwnProperty,v=Object.defineProperty||function(e,t,r){e[t]=r.value},b="function"==typeof Symbol?Symbol:{},w=b.iterator||"@@iterator",_=b.asyncIterator||"@@asyncIterator",C=b.toStringTag||"@@toStringTag";try{e({},"")}catch(t){e=function(e,t,r){return e[t]=r}}h.wrap=t;var E="suspendedStart",L="suspendedYield",x="executing",k="completed",S={},G={};e(G,w,function(){return this});var I=Object.getPrototypeOf,P=I&&I(I(p([])));P&&P!==m&&g.call(P,w)&&(G=P);var T=a.prototype=o.prototype=Object.create(G);return n.prototype=a,v(T,"constructor",{value:a,configurable:!0}),v(a,"constructor",{value:n,configurable:!0}),n.displayName=e(a,C,"GeneratorFunction"),h.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===n||"GeneratorFunction"===(t.displayName||t.name))},h.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,a):(t.__proto__=a,e(t,C,"GeneratorFunction")),t.prototype=Object.create(T),t},h.awrap=function(e){return{__await:e}},i(c.prototype),e(c.prototype,_,function(){return this}),h.AsyncIterator=c,h.async=function(e,r,o,n,a){void 0===a&&(a=Promise);var i=new c(t(e,r,o,n),a);return h.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},i(T),e(T,C,"Generator"),e(T,w,function(){return this}),e(T,"toString",function(){return"[object Generator]"}),h.keys=function(e){var t=Object(e),r=[];for(var o in t)r.push(o);return r.reverse(),function e(){for(;r.length;){var o=r.pop();if(o in t)return e.value=o,e.done=!1,e}return e.done=!0,e}},h.values=p,d.prototype={constructor:d,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=y,this.done=!1,this.delegate=null,this.method="next",this.arg=y,this.tryEntries.forEach(f),!e)for(var t in this)"t"===t.charAt(0)&&g.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=y)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function t(t,o){return a.type="throw",a.arg=e,r.next=t,o&&(r.method="next",r.arg=y),!!o}if(this.done)throw e;for(var r=this,o=this.tryEntries.length-1;o>=0;--o){var n=this.tryEntries[o],a=n.completion;if("root"===n.tryLoc)return t("end");if(n.tryLoc<=this.prev){var i=g.call(n,"catchLoc"),c=g.call(n,"finallyLoc");if(i&&c){if(this.prev<n.catchLoc)return t(n.catchLoc,!0);if(this.prev<n.finallyLoc)return t(n.finallyLoc)}else if(i){if(this.prev<n.catchLoc)return t(n.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<n.finallyLoc)return t(n.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&g.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var n=o;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var a=n?n.completion:{};return a.type=e,a.arg=t,n?(this.method="next",this.next=n.finallyLoc,S):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),f(r),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var o=r.completion;if("throw"===o.type){var n=o.arg;f(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:p(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=y),S}},h}function asyncGeneratorStep(e,t,r,o,n,a,i){try{var c=e[a](i),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(o,n)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(o,n){function a(e){asyncGeneratorStep(c,o,n,a,i,"next",e)}function i(e){asyncGeneratorStep(c,o,n,a,i,"throw",e)}var c=e.apply(t,r);a(void 0)})}}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,n=function(){};return{s:n,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}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 a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _asyncIterator(e){var t,r,o,n=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,o=Symbol.iterator);n--;){if(r&&null!=(t=e[r]))return t.call(e);if(o&&null!=(t=e[o]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",o="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _maplibreGl=_interopRequireDefault(_dereq_("maplibre-gl")),_config=_interopRequireDefault(_dereq_("../config.js")),Map=exports.default=function(){function e(t){var r=this;_classCallCheck(this,e);var o=Object.getOwnPropertyNames(t);if(o&&o.forEach(function(e){t[e]="style"===e?r._dealStyleMaps(t[e]):t[e]}),t)for(var n in _config.default.mapOptions)t.hasOwnProperty(n)||(t[n]=_config.default.mapOptions[n]);else t=_config.default.mapOptions;t.maxZoom=18,t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new _maplibreGl.default.Map(t)}return _createClass(e,[{key:"on",value:function(e,t){try{this.map.on(e,t)}catch(e){console.error("Error adding event listener: ".concat(e.message))}}},{key:"getSource",value:function(e){try{this.map.getSource(e)}catch(e){console.error("Error getting source: ".concat(e.message))}}},{key:"addSource",value:function(e){try{this.map.addSource(e)}catch(e){console.error("Error adding source: ".concat(e.message))}}},{key:"getLayer",value:function(e){try{this.map.getLayer(e)}catch(e){console.error("Error getting layer: ".concat(e.message))}}},{key:"jumpTo",value:function(e){try{this.map.jumpTo(e)}catch(t){console.error("Error jumping to ".concat(e,": ").concat(t.message))}}},{key:"setLayoutProperty",value:function(e){try{this.map.setLayoutProperty(e)}catch(e){console.error("Error setting layout property: ".concat(e.message))}}},{key:"addControl",value:function(e){try{this.map.addControl(e)}catch(e){console.error("Error adding control: ".concat(e.message))}}},{key:"getZoom",value:function(){try{return this.map.getZoom()}catch(e){console.error("Error getting zoom level: ".concat(e.message))}}},{key:"addMouseCoordControl",value:function(){try{this.map.on("mousemove",function(e){var t=e.lngLat.lat,r=e.lngLat.lng,o="Lon/Lat (WGS 84) Lon: "+r.toFixed(6)+" Lat: "+t.toFixed(6),n=document.getElementById("divInfo"),a=document.createElement("div");a.className="coordControl",a.innerHTML=o+" - ZL: "+map.getZoom().toFixed(1),n.appendChild(a)})}catch(e){console.error("Error adding mouse coordinate control: ".concat(e.message))}}},{key:"addGeolocateControl",value:function(e){try{void 0===e?this.map.addControl(new _maplibreGl.default.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0})):this.map.addControl(new _maplibreGl.default.GeolocateControl(e))}catch(e){console.error("Error adding geolocate control: ".concat(e.message))}}},{key:"getBounds",value:function(){try{return this.map.getBounds()}catch(e){console.error("Error getting bounds: ".concat(e.message))}}},{key:"getCanvas",value:function(){try{return this.map.getCanvas()}catch(e){console.error("Error getting canvas: ".concat(e.message))}}},{key:"setCenter",value:function(e){try{return this.map.setCenter(e)}catch(e){console.error("Error setting center: ".concat(e.message))}}},{key:"addLayer",value:function(e){try{this.map.addLayer(e)}catch(e){console.error("Error adding layer: ".concat(e.message))}}},{key:"addLayerGeoJSON",value:function(e){var t=this;try{this.map.on("load",function(){t.map.addSource("".concat(e.id,"-sourceIcgcMap"),{type:"geojson",data:e.data}),t.map.addLayer({id:"".concat(e.id,"-layerIcgcMap"),type:e.layerType,source:"".concat(e.id,"-sourceIcgcMap"),layout:e.layout,paint:e.paint})})}catch(e){console.error("Error adding GeoJSON layer: ".concat(e.message))}}},{key:"addLayerWMS",value:function(e){var t=this;try{this.map.on("load",function(){t.map.addSource("".concat(e.id,"-sourceIcgcMap"),{type:"raster",tiles:[e.tiles],tileSize:256}),t.map.addLayer({id:"".concat(e.id,"-layerIcgcMap"),type:"raster",source:"".concat(e.id,"-sourceIcgcMap"),paint:{}})})}catch(e){console.error("Error adding WMS layer: ".concat(e.message))}}},{key:"removeLayer",value:function(e){try{this.map.removeLayer(e)}catch(e){console.error("Error removing layer: ".concat(e.message))}}},{key:"removeSource",value:function(e){try{this.map.removeSource(e)}catch(e){console.error("Error removing source: ".concat(e.message))}}},{key:"addLogo",value:function(e){try{var t=document.createElement("img");t.src=e.url,t.style.height="62px";var r=document.getElementById("logos"),o=document.createElement("a");o.id=e.id,o.href=e.href,o.target="_blank",o.style.position="relative",o.style.bottom="1px",o.appendChild(t),r.appendChild(o)}catch(e){console.error("Error adding logo: ".concat(e.message))}}},{key:"addBasemaps",value:function(e){var t=this;try{var r=function(e){t.map.setStyle(e.url)},o=document.getElementById("basemap-group");this.map.on("load",function(){e.forEach(function(e){var t=document.createElement("div");t.className="basemap-item",t.title=e.label,t.style.backgroundImage="url('".concat(e.image,"')"),o.appendChild(t),t.addEventListener("click",function(){return r(e)})})})}catch(e){console.error("Error adding basemaps: ".concat(e.message))}}},{key:"addExportControl",value:function(){try{this.map.addControl(new MaplibreExportControl.MaplibreExportControl({PageSize:MaplibreExportControl.Size.A4,PageOrientation:MaplibreExportControl.PageOrientation.Landscape,Format:MaplibreExportControl.Format.PNG,DPI:MaplibreExportControl.DPI[300],Crosshair:!0,PrintableArea:!0,Local:"en"}),"top-right")}catch(e){console.error("Error adding export control: ".concat(e.message))}}},{key:"addMarker",value:function(e){try{var t,r;return void 0===e.text?t=new _maplibreGl.default.Marker(e.options).setLngLat(e.coord).addTo(this.map):(r=new _maplibreGl.default.Popup({offset:e.textOffset}).setText(e.text),t=(new _maplibreGl.default.Marker).setLngLat(e.coord).setPopup(r).addTo(this.map)),t}catch(e){return console.error("Error adding marker: ".concat(e.message)),null}}},{key:"addPopup",value:function(e){try{return(new _maplibreGl.default.Popup).setLngLat(e.coord).setHTML(e.text).addTo(this.map)}catch(e){return console.error("Error adding popup: ".concat(e.message)),null}}},{key:"addFullScreen",value:function(){try{this.map.addControl(new _maplibreGl.default.FullscreenControl)}catch(e){console.error("Error adding fullscreen control: ".concat(e.message))}}},{key:"addLayerTree",value:function(e){var t=this;try{var r=e.features,o=document.getElementById("filter-group");this.map.on("load",function(){for(var n,a=t.map.getStyle().layers,i=0;i<a.length;i++)if("symbol"===a[i].type){n=a[i].id;break}t.map.addSource("".concat(e.id,"-source"),{type:e.type,data:r}),r.features.forEach(function(r){var a=r.properties.icon,i="poi-".concat(a);if(!t.map.getLayer(i)){t.map.addLayer({id:i,type:"circle",source:"".concat(e.id,"-source"),paint:{"circle-radius":6,"circle-color":"#B42222"},filter:["==","icon",a]},n);var c=document.createElement("input");c.type="checkbox",c.id=i,c.checked=!0,o.appendChild(c);var l=document.createElement("label");l.setAttribute("for",i),l.textContent=a,o.appendChild(l),c.addEventListener("change",function(e){t.map.setLayoutProperty(i,"visibility",e.target.checked?"visible":"none")})}})})}catch(e){console.error("Error adding layer tree: ".concat(e.message))}}},{key:"createNavigationControl",value:function(e){try{return new _maplibreGl.default.NavigationControl(e)}catch(e){return console.error("Error creating navigation control: ".concat(e.message)),null}}},{key:"addNavigationControl",value:function(e){try{var t=this.createNavigationControl(e);t&&this.map.addControl(t)}catch(e){console.error("Error adding navigation control: ".concat(e.message))}}},{key:"addAttributionControl",value:function(e){try{this.map.addControl(new _maplibreGl.default.AttributionControl(e.options),e.position)}catch(e){console.error("Error adding attribution control: ".concat(e.message))}}},{key:"_dealStyleMaps",value:function(e){try{var t,r=_createForOfIteratorHelper(_config.default.baseStyles);try{for(r.s();!(t=r.n()).done;){var o=t.value;if(o.name===e)return o.url}}catch(e){r.e(e)}finally{r.f()}return _config.default.baseStyles[0].url}catch(e){return console.error("Error dealing with map styles: ".concat(e.message)),null}}},{key:"addImageLayerICGC",value:function(e,t){try{var r,o,n;if(e.includes("orto")||e.includes("geol")||e.includes("relleu")){if(e.includes("orto"))if(void 0!==t){r=e+t;var a=_config.default.ortoLayersICGC.find(function(e){return e.key===r});a||console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",r,"font-weight: bold; font-style: italic;"),o=a.text,n="ortofoto_color_"+o;var i={id:r,tiles:"https://geoserveis.icgc.cat/servei/catalunya/orto-territorial/wms?&bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&STYLES=&srs=EPSG:3857&transparent=true&width=256&height=256&layers=".concat(n)};this.addLayerWMS(i)}else{var c={id:e+"Actual",tiles:"https://geoserveis.icgc.cat/icc_mapesmultibase/noutm/wmts/orto/GRID3857/{z}/{x}/{y}.png"};this.addLayerWMS(c)}if(e.includes("relleu")){var l={id:e+"Actual",tiles:"https://tilemaps.icgc.cat/mapfactory/wmts/relleu/CAT3857/{z}/{x}/{y}.png"};this.addLayerWMS(l)}if(e.includes("geol")){var s={id:e+"Actual",tiles:"https://tilemaps.icgc.cat/mapfactory/wmts/geologia/MON3857NW/{z}/{x}/{y}.png"};this.addLayerWMS(s)}}else console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",e,"font-weight: bold; font-style: italic;")}catch(e){console.error("Error adding ICGC image layer: ".concat(e.message))}}},{key:"addFGBLayerICGC",value:function(){function e(e,r){return t.apply(this,arguments)}var t=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){var o,n,a,i=this;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,o=_config.default.vectorLayersICGC.find(function(e){return e.key.includes(t)}),o||console.log("❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.","font-weight: bold; font-style: italic;","font-weight: normal; font-style: normal; color: red;",t,"font-weight: bold; font-style: italic;"),n=o.url,e.next=6,fetch(n);case 6:a=e.sent,this.map.on("load",_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,r,n,c,l,s,u,f;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t={type:"FeatureCollection",features:[]},r=!1,n=!1,e.prev=3,l=_asyncIterator(flatgeobuf.deserialize(a.body));case 5:return e.next=7,l.next();case 7:if(!(r=!(s=e.sent).done)){e.next=13;break}u=s.value,t.features.push(u);case 10:r=!1,e.next=5;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),n=!0,c=e.t0;case 19:if(e.prev=19,e.prev=20,!r||null==l.return){e.next=24;break}return e.next=24,l.return();case 24:if(e.prev=24,!n){e.next=27;break}throw c;case 27:return e.finish(24);case 28:return e.finish(19);case 29:f=o.name+"-source",i.map.addSource(f,{type:"geojson",data:t}),i.map.addLayer({id:o.name+"-fill",type:"fill",source:f,paint:{"fill-color":"#0000FF","fill-opacity":0}}),i.map.addLayer({id:o.name+"-line",type:"line",source:f,paint:{"line-color":"#FFFFFF","line-opacity":.49,"line-width":1}});case 33:case"end":return e.stop()}},e,null,[[3,15,19,29],[20,,24,28]])}))),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.error("Error adding ICGC vector layer: ".concat(e.t0.message));case 13:case"end":return e.stop()}},e,this,[[0,10]])}));return e}()},{key:"addTerrainICGC",value:function(e){var t=this;this.map.on("load",function(){try{var r=_config.default.urlTerrainICGC.find(function(t){return t.name===e}),o=r.url;t.map.addSource("terrainICGC-src",{type:"raster-dem",tiles:[o],tileSize:512,maxzoom:16}),t.map.setTerrain({source:"terrainMapZen",exaggeration:1.5}),t.map.setTerrain({source:"terrainICGC-src",exaggeration:1.5}),t.map.addControl(new _maplibreGl.default.TerrainControl({source:"terrainICGC-src",exaggeration:1.5}))}catch(e){console.error("Error adding 3D terrain: ".concat(e.message))}})}}]),e}();
|
|
57
57
|
},{"../config.js":2,"maplibre-gl":1}]},{},[3])(3)
|
|
58
58
|
});
|
|
59
59
|
|