(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pvm_MglImageLayer"],{"521f":function(e,t,i){"use strict";var s=i("9f0b");const a={sourceId:{type:String,required:!0},source:{type:[Object,String],default:void 0}},r={layerId:{type:String,required:!0},layer:{type:Object,required:!0},before:{default:void 0}},o={clearSource:{type:Boolean,default:!0},replaceSource:{type:Boolean,default:!1},replace:{type:Boolean,default:!1}};t["a"]={mixins:[s["a"]],props:{...a,...r,...o},inject:["mapbox","map"],data(){return{initial:!0}},computed:{sourceLoaded(){return!!this.map&&this.map.isSourceLoaded(this.sourceId)},mapLayer(){return this.map?this.map.getLayer(this.layerId):null},mapSource(){return this.map?this.map.getSource(this.sourceId):null}},created(){this.layer.minzoom&&this.$watch("layer.minzoom",(function(e){this.initial||this.map.setLayerZoomRange(this.layerId,e,this.layer.maxzoom)})),this.layer.maxzoom&&this.$watch("layer.maxzoom",(function(e){this.initial||this.map.setLayerZoomRange(this.layerId,this.layer.minzoom,e)})),this.layer.paint&&this.$watch("layer.paint",(function(e){if(!this.initial&&e){console.log("layerMixin.js, in watch layer.paint, next:",e,"this.layerId:",this.layerId,"this.$store.map.getStyle().layers:",this.$store.map.getStyle().layers);let t=[];for(let e of this.$store.map.getStyle().layers)t.push(e.id);for(let i of Object.keys(e))console.log("in loop, prop:",i,"ids:",t,"this.layerId:",this.layerId),t.includes(this.layerId)&&this.map.setPaintProperty(this.layerId,i,e[i])}}),{deep:!0}),this.layer.layout&&this.$watch("layer.layout",(function(e){if(!this.initial&&e){let t=[];for(let e of this.$store.map.getStyle().layers)t.push(e.id);for(let i of Object.keys(e))t.includes(this.layerId)&&this.map.setLayoutProperty(this.layerId,i,e[i])}}),{deep:!0}),this.layer.filter&&this.$watch("layer.filter",(function(e){this.initial||this.map.setFilter(this.layerId,e)}),{deep:!0})},beforeDestroy(){console.log("layerMixin beforeDestroy is running, this.layerId:",this.layerId,"this.clearSource:",this.clearSource,"this.map:",this.map,"this.map.loaded():",this.map.loaded());try{this.map.removeLayer(this.layerId)}catch(e){this.$_emitEvent("layer-does-not-exist",{layerId:this.sourceId,error:e})}if(this.clearSource)try{Object.keys(this.map.style.sourceCaches).includes(this.sourceId)&&this.map.removeSource(this.sourceId)}catch(e){this.$_emitEvent("source-does-not-exist",{sourceId:this.sourceId,error:e})}},methods:{$_emitLayerMapEvent(e){return this.$_emitMapEvent(e,{layerId:this.layerId})},$_bindLayerEvents(e){Object.keys(this.$listeners).forEach(t=>{e.includes(t)&&this.map.on(t,this.layerId,this.$_emitLayerMapEvent)})},$_unbindEvents(e){this.map&&e.forEach(e=>{this.map.off(e,this.layerId,this.$_emitLayerMapEvent)})},$_watchSourceLoading(e){"source"===e.dataType&&e.sourceId===this.sourceId&&(this.$_emitEvent("layer-source-loading",{sourceId:this.sourceId}),this.map.off("dataloading",this.$_watchSourceLoading))},move(e){this.map.moveLayer(this.layerId,e),this.$_emitEvent("layer-moved",{layerId:this.layerId,beforeId:e})},remove(){this.map.removeLayer(this.layerId),this.map.removeSource(this.sourceId),this.$_emitEvent("layer-removed",{layerId:this.layerId}),this.$destroy()}},render(){}}},"9f0b":function(e,t,i){"use strict";t["a"]={methods:{$_emitEvent(e,t={}){this.$emit(e,{map:this.map,component:this,...t})},$_emitMapEvent(e,t={}){this.$_emitEvent(e.type,{mapboxEvent:e,...t})}}}},a2c7:function(e,t,i){"use strict";t["a"]=["mousedown","mouseup","click","dblclick","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"]},c3ab:function(e,t,i){"use strict";i.r(t);var s=i("521f"),a=i("a2c7");t["default"]={name:"ImageLayer",mixins:[s["a"]],created(){console.log("imageLayer created is running, this.source:",this.source,"this.$store.map.getBounds():",this.$store.map.getBounds()),this.source&&(this.source.coordinates&&this.$watch("source.coordinates",(function(e){this.initial||e&&this.mapSource.setCoordinates(e)}),{deep:!0}),this.source.url&&this.$watch("source.url",(function(e){this.initial||e&&this.mapSource.updateImage({url:e,coordinates:this.source.coordinates})}),{deep:!0})),this.$_deferredMount()},methods:{$_deferredMount(){const e={type:"image",...this.source};this.map.on("dataloading",this.$_watchSourceLoading);try{this.map.addSource(this.sourceId,e)}catch(t){this.replaceSource&&(this.map.removeSource(this.sourceId),this.map.addSource(this.sourceId,e))}this.$_addLayer(),this.$_bindLayerEvents(a["a"]),this.initial=!1},$_addLayer(){let e=this.map.getLayer(this.layerId);if(e){if(!this.replace)return this.$_emitEvent("layer-exists",{layerId:this.layerId}),e;this.map.removeLayer(this.layerId)}const t={id:this.layerId,source:this.sourceId,type:"raster",...this.layer};console.log("$_addLayer, layer:",t),this.map.addLayer(t,this.before),this.$_emitEvent("added",{layerId:this.layerId})}}}}}]);
//# sourceMappingURL=pvm_MglImageLayer.8eee0e19.js.map