From 8b9ed032af4f60b2abdf72e6fbcc39666b55faff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Wed, 27 Jul 2022 11:22:46 +0200 Subject: [PATCH] Release v0.2.14. --- dist/mapbox-gl-indoorequal.cjs.js | 14 ++++++++++++-- dist/mapbox-gl-indoorequal.esm.js | 14 ++++++++++++-- dist/mapbox-gl-indoorequal.umd.min.js | 2 +- package.json | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dist/mapbox-gl-indoorequal.cjs.js b/dist/mapbox-gl-indoorequal.cjs.js index e942dd2..397fb71 100644 --- a/dist/mapbox-gl-indoorequal.cjs.js +++ b/dist/mapbox-gl-indoorequal.cjs.js @@ -93,7 +93,12 @@ const commonPoi = { ] ], "text-anchor": "top", - "text-field": "{name:latin}\n{name:nonlatin}", + "text-field": [ + "concat", + ["get", "name:latin"], + "\n", + ["get", "name:nonlatin"], + ], "text-max-width": 9, "text-offset": [ 0, @@ -340,7 +345,12 @@ const layers = [ "all" ], "layout": { - "text-field": ["get", "name"], + "text-field": [ + "concat", + ["get", "name:latin"], + "\n", + ["get", "name:nonlatin"], + ], "text-max-width": 5, "text-size": 14 }, diff --git a/dist/mapbox-gl-indoorequal.esm.js b/dist/mapbox-gl-indoorequal.esm.js index cfb5c22..069e3ad 100644 --- a/dist/mapbox-gl-indoorequal.esm.js +++ b/dist/mapbox-gl-indoorequal.esm.js @@ -86,7 +86,12 @@ const commonPoi = { ] ], "text-anchor": "top", - "text-field": "{name:latin}\n{name:nonlatin}", + "text-field": [ + "concat", + ["get", "name:latin"], + "\n", + ["get", "name:nonlatin"], + ], "text-max-width": 9, "text-offset": [ 0, @@ -333,7 +338,12 @@ const layers = [ "all" ], "layout": { - "text-field": ["get", "name"], + "text-field": [ + "concat", + ["get", "name:latin"], + "\n", + ["get", "name:nonlatin"], + ], "text-max-width": 5, "text-size": 14 }, diff --git a/dist/mapbox-gl-indoorequal.umd.min.js b/dist/mapbox-gl-indoorequal.umd.min.js index db4564e..9c2ae3a 100644 --- a/dist/mapbox-gl-indoorequal.umd.min.js +++ b/dist/mapbox-gl-indoorequal.umd.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).IndoorEqual=t()}(this,(function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function t(t){for(var n=1;n=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function l(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n=0?i=setTimeout(s,t-c):(i=null,n||(l=e.apply(a,r),a=r=null))}null==t&&(t=100);var c=function(){a=this,r=arguments,o=Date.now();var c=n&&!i;return i||(i=setTimeout(s,t)),c&&(l=e.apply(a,r),a=r=null),l};return c.clear=function(){i&&(clearTimeout(i),i=null)},c.flush=function(){i&&(l=e.apply(a,r),a=r=null,clearTimeout(i),i=null)},c}c.debounce=c;var u=c;var h=function(){function e(t){var i=this;n(this,e),this.indoorequal=t,this._cbRefresh=function(){return i._refresh()},this.indoorequal.on("levelschange",this._cbRefresh),this.indoorequal.on("levelchange",this._cbRefresh),this.$el=document.createElement("div"),this.$el.classList.add("mapboxgl-ctrl","mapboxgl-ctrl-group","mapboxgl-ctrl-indoorequal"),this._refresh()}return r(e,[{key:"destroy",value:function(){this.$el.remove(),this.indoorequal.off("levelschange",this._cbRefresh),this.indoorequal.off("levelchange",this._cbRefresh)}},{key:"_refresh",value:function(){var e=this;this.$el.innerHTML="",this.indoorequal.levels.forEach((function(t){var n=document.createElement("button"),i=document.createElement("strong");i.textContent=t,n.appendChild(i),t==e.indoorequal.level&&n.classList.add("mapboxgl-ctrl-active"),n.addEventListener("click",(function(){e.indoorequal.setLevel(t)})),e.$el.appendChild(n)}))}}]),e}(),f={type:"symbol","source-layer":"poi",layout:{"icon-image":["coalesce",["image",["concat",["literal","indoorequal-"],["get","subclass"]]],["image",["concat",["literal","indoorequal-"],["get","class"]]]],"text-anchor":"top","text-field":"{name:latin}\n{name:nonlatin}","text-max-width":9,"text-offset":[0,.6],"text-padding":2,"text-size":12},paint:{"text-color":"#666","text-halo-blur":.5,"text-halo-color":"#ffffff","text-halo-width":1}},d=["waste_basket","information","vending_machine","bench","photo_booth","ticket_validator"],p=[{id:"indoor-polygon",type:"fill","source-layer":"area",filter:["all",["==","$type","Polygon"],["!=","class","level"]],paint:{"fill-color":["case",["all",["has","access"],["in",["get","access"],["literal",["no","private"]]]],"#F2F1F0",["all",["==",["get","is_poi"],!0],["!=",["get","class"],"corridor"]],"#D4EDFF",["==",["get","class"],"room"],"#fefee2","#fdfcfa"]}},{id:"indoor-area",type:"line","source-layer":"area",filter:["all",["in","class","area","corridor","platform"]],paint:{"line-color":"#bfbfbf","line-width":1}},{id:"indoor-column",type:"fill","source-layer":"area",filter:["all",["==","class","column"]],paint:{"fill-color":"#bfbfbf"}},{id:"indoor-lines",type:"line","source-layer":"area",filter:["all",["in","class","room","wall"]],paint:{"line-color":"gray","line-width":2}},{id:"indoor-transportation",type:"line","source-layer":"transportation",filter:["all"],paint:{"line-color":"gray","line-dasharray":[.4,.75],"line-width":{base:1.4,stops:[[17,2],[20,10]]}}},{id:"indoor-transportation-poi",type:"symbol","source-layer":"transportation",filter:["all",["in","$type","Point","LineString"],["in","class","steps","elevator","escalator"]],layout:{"icon-image":["case",["has","conveying"],"indoorequal-escalator",["concat",["literal","indoorequal-"],["get","class"]]],"symbol-placement":"line-center","icon-rotation-alignment":"viewport"}},t(t({id:"indoor-poi-rank1"},f),{},{filter:["all",["==","$type","Point"],["!in","class"].concat(d)]}),t(t({id:"indoor-poi-rank2"},f),{},{minzoom:19,filter:["all",["==","$type","Point"],["in","class"].concat(d)]}),{id:"indoor-heat",type:"heatmap","source-layer":"heat",filter:["all"],paint:{"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(102, 103, 173, 0)",.1,"rgba(102, 103, 173, 0.2)",1,"rgba(102, 103, 173, 0.7)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,3,13,20,17,40],"heatmap-intensity":1,"heatmap-opacity":["interpolate",["linear"],["zoom"],16,1,17.1,0]}},{id:"indoor-name",type:"symbol","source-layer":"area_name",filter:["all"],layout:{"text-field":["get","name"],"text-max-width":5,"text-size":14},paint:{"text-color":"#666","text-halo-color":"#ffffff","text-halo-width":1}}];function v(e,t,n,i){var r=t.width,a=t.height;if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==r*a*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(r*a*n);return e.width=r,e.height=a,e.data=i,e}function y(e,t,n,i,r,a){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,l=t.data,s=0;s1?"@2x":"",r=fetch("".concat(e).concat(i,".json")).then((function(e){return e.json()})).then((function(e){return t=e})),a=fetch("".concat(e).concat(i,".png")).then((function(e){return e.blob()})).then((function(e){return(n=new Image).src=URL.createObjectURL(e),new Promise((function(e,t){n.onload=function(){return e()},n.onerror=function(){return t()}}))}));return Promise.all([r,a]).then((function(){var e=function(e,t){var n=window.document.createElement("canvas"),i=n.getContext("2d");if(!i)throw new Error("failed to create canvas 2d context");return n.width=e.width,n.height=e.height,i.drawImage(e,0,0,e.width,e.height),i.getImageData(0,0,e.width,e.height)}(n),i={};for(var r in t){var a=t[r],o=a.width,l=a.height,s=a.x,c=a.y,u=a.sdf,h=a.pixelRatio,f=a.stretchX,d=a.stretchY,p=a.content,v=new m({width:o,height:l});m.copy(e,v,{x:s,y:c},{x:0,y:0},{width:o,height:l}),i[r]={data:v,pixelRatio:h,sdf:u,stretchX:f,stretchY:d,content:p}}return i}))}var b=["data"],w=function(){function e(i){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var a={layers:p,geojson:{}},o=t(t({},a),r);this.map=i,this.geojson=o.geojson,this.layers=o.layers,this.baseSourceId="indoorequal",this.sourceId="".concat(this.baseSourceId,"_area")}return r(e,[{key:"addSource",value:function(){var e=this;Object.keys(this.geojson).forEach((function(t){e.map.addSource("".concat(e.baseSourceId,"_").concat(t),{type:"geojson",data:e.geojson[t]})}))}},{key:"addLayers",value:function(){var e=this,n=Object.keys(this.geojson),i=this.layers;this.layers=i.filter((function(e){return n.includes(e["source-layer"])})),this.layers.forEach((function(n){e.map.addLayer(t(t({source:"".concat(e.baseSourceId,"_").concat(n["source-layer"])},n),{},{"source-layer":""}))}))}},{key:"remove",value:function(){var e=this;this.layers.forEach((function(t){e.map.removeLayer(t.id)})),Object.keys(this.geojson).forEach((function(t){e.map.removeSource("".concat(e.baseSourceId,"_").concat(t))}))}}]),e}(),_=function(){function e(i){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var a={url:"https://tiles.indoorequal.org/",layers:p},o=t(t({},a),r);if(o.url===a.url&&!o.apiKey)throw"You must register your apiKey at https://indoorequal.com before and set it as apiKey param.";this.map=i,this.url=o.url,this.apiKey=o.apiKey,this.layers=o.layers,this.sourceId="indoorequal"}return r(e,[{key:"addSource",value:function(){var e=this.apiKey?"?key=".concat(this.apiKey):"";this.map.addSource(this.sourceId,{type:"vector",url:"".concat(this.url).concat(e)})}},{key:"addLayers",value:function(){var e=this;this.layers.forEach((function(n){e.map.addLayer(t({source:e.sourceId},n))}))}},{key:"remove",value:function(){var e=this;this.layers.forEach((function(t){e.map.removeLayer(t.id)})),this.map.removeSource(this.sourceId)}}]),e}();return function(){function e(i){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var o=a.geojson?w:_,l={heatmap:!0},s=t(t({},l),a);this.source=new o(i,a),this.map=i,this.levels=[],this.level="0",this.events={},this.map.isStyleLoaded()?(this._init(),this.setHeatmapVisible(s.heatmap)):this.map.once("load",(function(){r._init(),r.setHeatmapVisible(s.heatmap)}))}return r(e,[{key:"remove",value:function(){this.source.remove(),this._updateLevelsDebounce.clear(),this.map.off("load",this._updateLevelsDebounce),this.map.off("data",this._updateLevelsDebounce),this.map.off("move",this._updateLevelsDebounce),this._control&&this.onRemove()}},{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"off",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e]=this.events[e].filter((function(e){return e!==t}))}},{key:"onAdd",value:function(){return this._control=new h(this),this._control.$el}},{key:"onRemove",value:function(){this._control.destroy(),this._control=null}},{key:"setLevel",value:function(e){this.level=e,this._updateFilters(),this._emitLevelChange()}},{key:"updateLevel",value:function(e){console.log("The updateLevel method is deprecated. Please use setLevel instead."),this.setLevel(e)}},{key:"loadSprite",value:function(e){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t({update:!1},i);return g(e).then((function(e){for(var t in e){var i=e[t],a=i.data,l=o(i,b);n.map.hasImage(t)?r.update&&n.map.updateImage(t,a):n.map.addImage(t,a,l)}return e}))}},{key:"setHeatmapVisible",value:function(e){this.map.getLayer("indoor-heat")&&this.map.setLayoutProperty("indoor-heat","visibility",e?"visible":"none")}},{key:"_init",value:function(){var e=this;this.source.addSource(),this.source.addLayers(),this._updateFilters(),this._updateLevelsDebounce=u(this._updateLevels.bind(this),1e3),this.map.on("load",this._updateLevelsDebounce),this.map.on("data",this._updateLevelsDebounce),this.map.on("move",this._updateLevelsDebounce),this.map.on("remove",(function(){e.remove()}))}},{key:"_updateFilters",value:function(){var e=this;this.source.layers.filter((function(e){return"heatmap"!==e.type})).forEach((function(t){e.map.setFilter(t.id,[].concat(l(t.filter||["all"]),[["==","level",e.level]]))}))}},{key:"_refreshAfterLevelsUpdate",value:function(){this.levels.includes(this.level)||this.setLevel("0")}},{key:"_updateLevels",value:function(){if(this.map.isSourceLoaded(this.source.sourceId)){var e=function(e){for(var t=[],n=0;n1?t-1:0),i=1;i=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function l(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n=0?i=setTimeout(s,t-c):(i=null,n||(l=e.apply(a,r),a=r=null))}null==t&&(t=100);var c=function(){a=this,r=arguments,o=Date.now();var c=n&&!i;return i||(i=setTimeout(s,t)),c&&(l=e.apply(a,r),a=r=null),l};return c.clear=function(){i&&(clearTimeout(i),i=null)},c.flush=function(){i&&(l=e.apply(a,r),a=r=null,clearTimeout(i),i=null)},c}c.debounce=c;var u=c;var h=function(){function e(t){var i=this;n(this,e),this.indoorequal=t,this._cbRefresh=function(){return i._refresh()},this.indoorequal.on("levelschange",this._cbRefresh),this.indoorequal.on("levelchange",this._cbRefresh),this.$el=document.createElement("div"),this.$el.classList.add("mapboxgl-ctrl","mapboxgl-ctrl-group","mapboxgl-ctrl-indoorequal"),this._refresh()}return r(e,[{key:"destroy",value:function(){this.$el.remove(),this.indoorequal.off("levelschange",this._cbRefresh),this.indoorequal.off("levelchange",this._cbRefresh)}},{key:"_refresh",value:function(){var e=this;this.$el.innerHTML="",this.indoorequal.levels.forEach((function(t){var n=document.createElement("button"),i=document.createElement("strong");i.textContent=t,n.appendChild(i),t==e.indoorequal.level&&n.classList.add("mapboxgl-ctrl-active"),n.addEventListener("click",(function(){e.indoorequal.setLevel(t)})),e.$el.appendChild(n)}))}}]),e}(),f={type:"symbol","source-layer":"poi",layout:{"icon-image":["coalesce",["image",["concat",["literal","indoorequal-"],["get","subclass"]]],["image",["concat",["literal","indoorequal-"],["get","class"]]]],"text-anchor":"top","text-field":["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],"text-max-width":9,"text-offset":[0,.6],"text-padding":2,"text-size":12},paint:{"text-color":"#666","text-halo-blur":.5,"text-halo-color":"#ffffff","text-halo-width":1}},d=["waste_basket","information","vending_machine","bench","photo_booth","ticket_validator"],p=[{id:"indoor-polygon",type:"fill","source-layer":"area",filter:["all",["==","$type","Polygon"],["!=","class","level"]],paint:{"fill-color":["case",["all",["has","access"],["in",["get","access"],["literal",["no","private"]]]],"#F2F1F0",["all",["==",["get","is_poi"],!0],["!=",["get","class"],"corridor"]],"#D4EDFF",["==",["get","class"],"room"],"#fefee2","#fdfcfa"]}},{id:"indoor-area",type:"line","source-layer":"area",filter:["all",["in","class","area","corridor","platform"]],paint:{"line-color":"#bfbfbf","line-width":1}},{id:"indoor-column",type:"fill","source-layer":"area",filter:["all",["==","class","column"]],paint:{"fill-color":"#bfbfbf"}},{id:"indoor-lines",type:"line","source-layer":"area",filter:["all",["in","class","room","wall"]],paint:{"line-color":"gray","line-width":2}},{id:"indoor-transportation",type:"line","source-layer":"transportation",filter:["all"],paint:{"line-color":"gray","line-dasharray":[.4,.75],"line-width":{base:1.4,stops:[[17,2],[20,10]]}}},{id:"indoor-transportation-poi",type:"symbol","source-layer":"transportation",filter:["all",["in","$type","Point","LineString"],["in","class","steps","elevator","escalator"]],layout:{"icon-image":["case",["has","conveying"],"indoorequal-escalator",["concat",["literal","indoorequal-"],["get","class"]]],"symbol-placement":"line-center","icon-rotation-alignment":"viewport"}},t(t({id:"indoor-poi-rank1"},f),{},{filter:["all",["==","$type","Point"],["!in","class"].concat(d)]}),t(t({id:"indoor-poi-rank2"},f),{},{minzoom:19,filter:["all",["==","$type","Point"],["in","class"].concat(d)]}),{id:"indoor-heat",type:"heatmap","source-layer":"heat",filter:["all"],paint:{"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(102, 103, 173, 0)",.1,"rgba(102, 103, 173, 0.2)",1,"rgba(102, 103, 173, 0.7)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,3,13,20,17,40],"heatmap-intensity":1,"heatmap-opacity":["interpolate",["linear"],["zoom"],16,1,17.1,0]}},{id:"indoor-name",type:"symbol","source-layer":"area_name",filter:["all"],layout:{"text-field":["concat",["get","name:latin"],"\n",["get","name:nonlatin"]],"text-max-width":5,"text-size":14},paint:{"text-color":"#666","text-halo-color":"#ffffff","text-halo-width":1}}];function v(e,t,n,i){var r=t.width,a=t.height;if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==r*a*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(r*a*n);return e.width=r,e.height=a,e.data=i,e}function y(e,t,n,i,r,a){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,l=t.data,s=0;s1?"@2x":"",r=fetch("".concat(e).concat(i,".json")).then((function(e){return e.json()})).then((function(e){return t=e})),a=fetch("".concat(e).concat(i,".png")).then((function(e){return e.blob()})).then((function(e){return(n=new Image).src=URL.createObjectURL(e),new Promise((function(e,t){n.onload=function(){return e()},n.onerror=function(){return t()}}))}));return Promise.all([r,a]).then((function(){var e=function(e,t){var n=window.document.createElement("canvas"),i=n.getContext("2d");if(!i)throw new Error("failed to create canvas 2d context");return n.width=e.width,n.height=e.height,i.drawImage(e,0,0,e.width,e.height),i.getImageData(0,0,e.width,e.height)}(n),i={};for(var r in t){var a=t[r],o=a.width,l=a.height,s=a.x,c=a.y,u=a.sdf,h=a.pixelRatio,f=a.stretchX,d=a.stretchY,p=a.content,v=new m({width:o,height:l});m.copy(e,v,{x:s,y:c},{x:0,y:0},{width:o,height:l}),i[r]={data:v,pixelRatio:h,sdf:u,stretchX:f,stretchY:d,content:p}}return i}))}var b=["data"],w=function(){function e(i){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var a={layers:p,geojson:{}},o=t(t({},a),r);this.map=i,this.geojson=o.geojson,this.layers=o.layers,this.baseSourceId="indoorequal",this.sourceId="".concat(this.baseSourceId,"_area")}return r(e,[{key:"addSource",value:function(){var e=this;Object.keys(this.geojson).forEach((function(t){e.map.addSource("".concat(e.baseSourceId,"_").concat(t),{type:"geojson",data:e.geojson[t]})}))}},{key:"addLayers",value:function(){var e=this,n=Object.keys(this.geojson),i=this.layers;this.layers=i.filter((function(e){return n.includes(e["source-layer"])})),this.layers.forEach((function(n){e.map.addLayer(t(t({source:"".concat(e.baseSourceId,"_").concat(n["source-layer"])},n),{},{"source-layer":""}))}))}},{key:"remove",value:function(){var e=this;this.layers.forEach((function(t){e.map.removeLayer(t.id)})),Object.keys(this.geojson).forEach((function(t){e.map.removeSource("".concat(e.baseSourceId,"_").concat(t))}))}}]),e}(),_=function(){function e(i){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var a={url:"https://tiles.indoorequal.org/",layers:p},o=t(t({},a),r);if(o.url===a.url&&!o.apiKey)throw"You must register your apiKey at https://indoorequal.com before and set it as apiKey param.";this.map=i,this.url=o.url,this.apiKey=o.apiKey,this.layers=o.layers,this.sourceId="indoorequal"}return r(e,[{key:"addSource",value:function(){var e=this.apiKey?"?key=".concat(this.apiKey):"";this.map.addSource(this.sourceId,{type:"vector",url:"".concat(this.url).concat(e)})}},{key:"addLayers",value:function(){var e=this;this.layers.forEach((function(n){e.map.addLayer(t({source:e.sourceId},n))}))}},{key:"remove",value:function(){var e=this;this.layers.forEach((function(t){e.map.removeLayer(t.id)})),this.map.removeSource(this.sourceId)}}]),e}(),x=function(){function e(i){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e);var o=a.geojson?w:_,l={heatmap:!0},s=t(t({},l),a);this.source=new o(i,a),this.map=i,this.levels=[],this.level="0",this.events={},this.map.isStyleLoaded()?(this._init(),this.setHeatmapVisible(s.heatmap)):this.map.once("load",(function(){r._init(),r.setHeatmapVisible(s.heatmap)}))}return r(e,[{key:"remove",value:function(){this.source.remove(),this._updateLevelsDebounce.clear(),this.map.off("load",this._updateLevelsDebounce),this.map.off("data",this._updateLevelsDebounce),this.map.off("move",this._updateLevelsDebounce),this._control&&this.onRemove()}},{key:"on",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}},{key:"off",value:function(e,t){this.events[e]||(this.events[e]=[]),this.events[e]=this.events[e].filter((function(e){return e!==t}))}},{key:"onAdd",value:function(){return this._control=new h(this),this._control.$el}},{key:"onRemove",value:function(){this._control.destroy(),this._control=null}},{key:"setLevel",value:function(e){this.level=e,this._updateFilters(),this._emitLevelChange()}},{key:"updateLevel",value:function(e){console.log("The updateLevel method is deprecated. Please use setLevel instead."),this.setLevel(e)}},{key:"loadSprite",value:function(e){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t({update:!1},i);return g(e).then((function(e){for(var t in e){var i=e[t],a=i.data,l=o(i,b);n.map.hasImage(t)?r.update&&n.map.updateImage(t,a):n.map.addImage(t,a,l)}return e}))}},{key:"setHeatmapVisible",value:function(e){this.map.getLayer("indoor-heat")&&this.map.setLayoutProperty("indoor-heat","visibility",e?"visible":"none")}},{key:"_init",value:function(){var e=this;this.source.addSource(),this.source.addLayers(),this._updateFilters(),this._updateLevelsDebounce=u(this._updateLevels.bind(this),1e3),this.map.on("load",this._updateLevelsDebounce),this.map.on("data",this._updateLevelsDebounce),this.map.on("move",this._updateLevelsDebounce),this.map.on("remove",(function(){e.remove()}))}},{key:"_updateFilters",value:function(){var e=this;this.source.layers.filter((function(e){return"heatmap"!==e.type})).forEach((function(t){e.map.setFilter(t.id,[].concat(l(t.filter||["all"]),[["==","level",e.level]]))}))}},{key:"_refreshAfterLevelsUpdate",value:function(){this.levels.includes(this.level)||this.setLevel("0")}},{key:"_updateLevels",value:function(){if(this.map.isSourceLoaded(this.source.sourceId)){var e=function(e){for(var t=[],n=0;n1?t-1:0),i=1;i