vue-maplibre-gl
Advanced tools
Comparing version 2.0.2 to 2.0.3
/*! | ||
* vue-maplibre-gl v2.0.2 | ||
* vue-maplibre-gl v2.0.3 | ||
* (c) 2023 Volker Nauruhn | ||
* @license MIT | ||
*/ | ||
var ce = Object.defineProperty; | ||
var me = (e, o, t) => o in e ? ce(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t; | ||
var p = (e, o, t) => (me(e, typeof o != "symbol" ? o + "" : o, t), t); | ||
import { reactive as oe, defineComponent as v, markRaw as ie, getCurrentInstance as _, shallowRef as K, ref as F, provide as O, watch as m, toRef as f, onMounted as ge, onBeforeUnmount as w, h as E, unref as ee, inject as n, createCommentVNode as L, Teleport as le, nextTick as he, warn as T, createTextVNode as ne } from "vue"; | ||
var me = Object.defineProperty; | ||
var ge = (e, o, t) => o in e ? me(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t; | ||
var p = (e, o, t) => (ge(e, typeof o != "symbol" ? o + "" : o, t), t); | ||
import { reactive as oe, defineComponent as v, markRaw as ie, getCurrentInstance as _, shallowRef as K, ref as F, provide as O, watch as m, toRef as f, onMounted as he, onBeforeUnmount as w, h as E, unref as ee, nextTick as le, inject as n, createCommentVNode as L, Teleport as ue, warn as T, createTextVNode as ne } from "vue"; | ||
import { Map as fe, AttributionControl as ye, FullscreenControl as ve, GeolocateControl as pe, NavigationControl as be, ScaleControl as Se, Marker as Oe } from "maplibre-gl"; | ||
@@ -135,8 +135,8 @@ import Le from "mitt"; | ||
var k = /* @__PURE__ */ ((e) => (e.TOP_LEFT = "top-left", e.TOP_RIGHT = "top-right", e.BOTTOM_LEFT = "bottom-left", e.BOTTOM_RIGHT = "bottom-right", e))(k || {}); | ||
const z = Object.values(k), J = /* @__PURE__ */ new Map(), ue = Symbol("default"); | ||
function gt(e = ue) { | ||
const z = Object.values(k), J = /* @__PURE__ */ new Map(), de = Symbol("default"); | ||
function gt(e = de) { | ||
let o = J.get(e); | ||
return o || (o = oe({ isLoaded: !1, isMounted: !1 }), J.set(e, o)), o; | ||
} | ||
function Re(e, o = ue) { | ||
function Re(e, o = de) { | ||
var a; | ||
@@ -325,5 +325,5 @@ let t = J.get(o); | ||
function C() { | ||
y(), W(); | ||
y(), le(W); | ||
} | ||
return ge(() => { | ||
return he(() => { | ||
W(), r.value && (V = new ResizeObserver(Me(r.value.resize.bind(r.value), 100)), V.observe(i.value)); | ||
@@ -386,3 +386,3 @@ }), w(() => { | ||
onAdd() { | ||
return he(() => this.isAdded.value = !0), this.container; | ||
return le(() => this.isAdded.value = !0), this.container; | ||
} | ||
@@ -419,3 +419,3 @@ onRemove() { | ||
return this.isAdded ? E( | ||
le, | ||
ue, | ||
{ to: this.container }, | ||
@@ -643,4 +643,4 @@ this.$slots.default ? this.$slots.default() : void 0 | ||
}); | ||
var de = /* @__PURE__ */ ((e) => (e.IMPERIAL = "imperial", e.METRIC = "metric", e.NAUTICAL = "nautical", e))(de || {}); | ||
const Ne = Object.values(de), _e = /* @__PURE__ */ v({ | ||
var ce = /* @__PURE__ */ ((e) => (e.IMPERIAL = "imperial", e.METRIC = "metric", e.NAUTICAL = "nautical", e))(ce || {}); | ||
const Ne = Object.values(ce), _e = /* @__PURE__ */ v({ | ||
name: "MglScaleControl", | ||
@@ -795,3 +795,3 @@ props: { | ||
return E( | ||
le, | ||
ue, | ||
{ to: this.container }, | ||
@@ -798,0 +798,0 @@ this.$slots.default ? this.$slots.default(e) : [ |
/*! | ||
* vue-maplibre-gl v2.0.2 | ||
* vue-maplibre-gl v2.0.3 | ||
* (c) 2023 Volker Nauruhn | ||
@@ -7,3 +7,3 @@ * @license MIT | ||
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("maplibre-gl"),require("mitt")):typeof define=="function"&&define.amd?define(["exports","vue","maplibre-gl","mitt"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.VueMaplibreGl={},s.Vue,s.maplibregl,s.mitt))})(this,function(s,e,w,Le){"use strict";var Fe=Object.defineProperty;var De=(s,e,w)=>e in s?Fe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:w}):s[e]=w;var p=(s,e,w)=>(De(s,typeof e!="symbol"?e+"":e,w),w);var G=document.createElement("style");G.textContent=`.mgl-container{position:relative}.mgl-wrapper{position:absolute;top:0;right:0;bottom:0;left:0}.maplibregl-ctrl .maplibregl-ctrl-icon svg{margin-top:2px}.maplibregl-ctrl .maplibregl-style-switch{display:block}.maplibregl-ctrl .maplibregl-style-switch.is-open,.maplibregl-ctrl .maplibregl-style-list{display:none}.maplibregl-ctrl .maplibregl-style-list.is-open{display:block}.maplibregl-ctrl .maplibregl-style-list button{width:100%;text-align:left;padding:0 5px}.maplibregl-ctrl .maplibregl-style-list button.is-active{font-weight:700}.maplibregl-ctrl-top-left .maplibregl-style-list button,.maplibregl-ctrl-bottom-left .maplibregl-style-list button{text-align:left}.maplibregl-ctrl-top-right .maplibregl-style-list button,.maplibregl-ctrl-bottom-right .maplibregl-style-list button{text-align:right} | ||
`,document.head.appendChild(G);const $e="",y=Symbol("map"),C=Symbol("isLoaded"),S=Symbol("componentId"),R=Symbol("sourceId"),E=Symbol("sourceLayerRegistry"),F=Symbol("emitter");function Me(t){return Object.keys(t)}function P(t){return Object.keys(t)}const u=e.reactive({style:"https://demotiles.maplibre.org/style.json",center:Object.freeze([0,0]),zoom:1,trackResize:!1});class L{static createEventHandler(i,o,a,r){return(n={})=>a.emit(r,{type:n.type,map:o,component:i,event:n})}}p(L,"MAP_OPTION_KEYS",["antialias","attributionControl","bearing","bearingSnap","bounds","boxZoom","center","clickTolerance","collectResourceTiming","crossSourceCollisions","container","customAttribution","dragPan","dragRotate","doubleClickZoom","hash","fadeDuration","failIfMajorPerformanceCaveat","fitBoundsOptions","interactive","keyboard","locale","localIdeographFontFamily","logoPosition","maxBounds","maxPitch","maxZoom","minPitch","minZoom","preserveDrawingBuffer","pitch","pitchWithRotate","refreshExpiredTiles","renderWorldCopies","scrollZoom","mapStyle","trackResize","transformRequest","touchZoomRotate","touchPitch","zoom","maxTileCacheSize","pixelRatio","cooperativeGestures"]),p(L,"MARKER_OPTION_KEYS",["element","offset","anchor","color","draggable","clickTolerance","rotation","rotationAlignment","pitchAlignment","scale"]),p(L,"MAP_EVENT_TYPES",["error","load","idle","remove","render","resize","webglcontextlost","webglcontextrestored","dataloading","data","tiledataloading","sourcedataloading","styledataloading","sourcedata","styledata","boxzoomcancel","boxzoomstart","boxzoomend","touchcancel","touchmove","touchend","touchstart","click","contextmenu","dblclick","mousemove","mouseup","mousedown","mouseout","mouseover","movestart","move","moveend","zoomstart","zoom","zoomend","rotatestart","rotate","rotateend","dragstart","drag","dragend","pitchstart","pitch","pitchend","wheel"]);var j=(t=>(t.TOP_LEFT="top-left",t.TOP_RIGHT="top-right",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_RIGHT="bottom-right",t))(j||{});const A=Object.values(j),D=new Map,Y=Symbol("default");function ve(t=Y){let i=D.get(t);return i||(i=e.reactive({isLoaded:!1,isMounted:!1}),D.set(t,i)),i}function Ee(t,i=Y){var a;let o=D.get(i);return o||(o=e.reactive({isLoaded:!1,isMounted:!1}),D.set(i,o)),o.isLoaded=!1,o.isMounted=!1,o.component=t,o.map=t.map,o.isLoaded=((a=t.map)==null?void 0:a.loaded())||!1,o}function je(t,i=250,o=!1){let a;function r(){const n=arguments,c=()=>{a=void 0,o!==!0&&t.apply(this,n)};clearTimeout(a),o===!0&&a===void 0&&t.apply(this,n),a=window.setTimeout(c,i)}return r.cancel=()=>{clearTimeout(a)},r}const q=e.defineComponent({name:"MglMap",props:{width:{type:[Number,String],default:"100%"},height:{type:[Number,String],default:"100%"},antialias:{type:Boolean,default:()=>u.antialias},attributionControl:{type:Boolean,default:()=>u.attributionControl},bearing:{type:Number,default:()=>u.bearing},bearingSnap:{type:Number,default:()=>u.bearingSnap},bounds:{type:[Array,Object],default:()=>u.bounds},boxZoom:{type:Boolean,default:()=>u.boxZoom},center:{type:[Array,Object],default:()=>u.center},clickTolerance:{type:Number,default:()=>u.clickTolerance},collectResourceTiming:{type:Boolean,default:()=>u.collectResourceTiming},crossSourceCollisions:{type:Boolean,default:()=>u.crossSourceCollisions},customAttribution:{type:[String,Array],default:()=>u.customAttribution},dragPan:{type:Boolean,default:()=>u.dragPan},dragRotate:{type:Boolean,default:()=>u.dragRotate},doubleClickZoom:{type:Boolean,default:()=>u.doubleClickZoom},hash:{type:[Boolean,String],default:()=>u.hash},fadeDuration:{type:Number,default:()=>u.fadeDuration},failIfMajorPerformanceCaveat:{type:Boolean,default:()=>u.failIfMajorPerformanceCaveat},fitBoundsOptions:{type:Object,default:()=>u.fitBoundsOptions},interactive:{type:Boolean,default:()=>u.interactive},keyboard:{type:Boolean,default:()=>u.keyboard},locale:{type:Object,default:()=>u.locale},localIdeographFontFamily:{type:String,default:()=>u.localIdeographFontFamily},logoPosition:{type:[String],validator:t=>t in j,default:()=>u.logoPosition},maxBounds:{type:[Array,Object],default:()=>u.maxBounds},maxPitch:{type:Number,default:()=>u.maxPitch},maxZoom:{type:Number,default:()=>u.maxZoom},minPitch:{type:Number,default:()=>u.minPitch},minZoom:{type:Number,default:()=>u.minZoom},preserveDrawingBuffer:{type:Boolean,default:()=>u.preserveDrawingBuffer},pitch:{type:Number,default:()=>u.pitch},pitchWithRotate:{type:Boolean,default:()=>u.pitchWithRotate},refreshExpiredTiles:{type:Boolean,default:()=>u.refreshExpiredTiles},renderWorldCopies:{type:Boolean,default:()=>u.renderWorldCopies},scrollZoom:{type:Boolean,default:()=>u.scrollZoom},mapStyle:{type:[String,Object],default:()=>u.style},trackResize:{type:Boolean,default:()=>u.trackResize},transformRequest:{type:Function,default:u.transformRequest},touchZoomRotate:{type:Boolean,default:()=>u.touchZoomRotate},touchPitch:{type:Boolean,default:()=>u.touchPitch},zoom:{type:Number,default:()=>u.zoom},maxTileCacheSize:{type:Number,default:()=>u.maxTileCacheSize},mapKey:{type:[String,Symbol]},pixelRatio:{type:Number,default:()=>u.pixelRatio},cooperativeGestures:{type:[Boolean,Object],default:()=>u.cooperativeGestures}},emits:["map:error","map:load","map:idle","map:remove","map:render","map:resize","map:webglcontextlost","map:webglcontextrestored","map:dataloading","map:data","map:tiledataloading","map:sourcedataloading","map:styledataloading","map:sourcedata","map:styledata","map:boxzoomcancel","map:boxzoomstart","map:boxzoomend","map:touchcancel","map:touchmove","map:touchend","map:touchstart","map:click","map:contextmenu","map:dblclick","map:mousemove","map:mouseup","map:mousedown","map:mouseout","map:mouseover","map:movestart","map:move","map:moveend","map:zoomstart","map:zoom","map:zoomend","map:rotatestart","map:rotate","map:rotateend","map:dragstart","map:drag","map:dragend","map:pitchstart","map:pitch","map:pitchend","map:wheel"],setup(t,i){const o=e.markRaw(e.getCurrentInstance()),a=e.shallowRef(null),r=e.shallowRef(null),n=e.shallowRef(null),c=e.ref(!1),h=e.ref(!1),f=new Map,N=Le(),T=Ee(o,t.mapKey);let _;e.provide(y,n),e.provide(C,h),e.provide(S,o.uid),e.provide(R,""),e.provide(F,N),e.watch(e.toRef(t,"bearing"),d=>{var l;d&&((l=n.value)==null||l.setBearing(d))}),e.watch(e.toRef(t,"bounds"),d=>{var l;d&&((l=n.value)==null||l.fitBounds(d,t.fitBoundsOptions))}),e.watch(e.toRef(t,"center"),d=>{var l;d&&((l=n.value)==null||l.setCenter(d))}),e.watch(e.toRef(t,"maxBounds"),d=>{var l;d&&((l=n.value)==null||l.setMaxBounds(d))}),e.watch(e.toRef(t,"maxPitch"),d=>{var l;d&&((l=n.value)==null||l.setMaxPitch(d))}),e.watch(e.toRef(t,"maxZoom"),d=>{var l;d&&((l=n.value)==null||l.setMaxZoom(d))}),e.watch(e.toRef(t,"minPitch"),d=>{var l;d&&((l=n.value)==null||l.setMinPitch(d))}),e.watch(e.toRef(t,"minZoom"),d=>{var l;d&&((l=n.value)==null||l.setMinZoom(d))}),e.watch(e.toRef(t,"pitch"),d=>{var l;d&&((l=n.value)==null||l.setPitch(d))}),e.watch(e.toRef(t,"renderWorldCopies"),d=>{var l;d&&((l=n.value)==null||l.setRenderWorldCopies(d))}),e.watch(e.toRef(t,"mapStyle"),d=>{var l;d&&((l=n.value)==null||l.setStyle(d))}),e.watch(e.toRef(t,"transformRequest"),d=>{var l;d&&((l=n.value)==null||l.setTransformRequest(d))}),e.watch(e.toRef(t,"zoom"),d=>{var l;d&&((l=n.value)==null||l.setZoom(d))}),e.watch(e.toRef(t,"zoom"),d=>{var l;d&&((l=n.value)==null||l.setZoom(d))});function V(){T.isMounted=!0;const d=Object.keys(t).filter(l=>t[l]!==void 0&&L.MAP_OPTION_KEYS.indexOf(l)!==-1).reduce((l,k)=>(l[k==="mapStyle"?"style":k]=e.unref(t[k]),l),{container:r.value});if(n.value=e.markRaw(new w.Map(d)),T.map=n.value,c.value=!0,f.set("__load",()=>(h.value=!0,T.isLoaded=!0)),n.value.on("load",f.get("__load")),o.vnode.props){for(let l=0,k=L.MAP_EVENT_TYPES.length;l<k;l++)if(o.vnode.props["onMap:"+L.MAP_EVENT_TYPES[l]]){const Oe=L.createEventHandler(o,n.value,i,"map:"+L.MAP_EVENT_TYPES[l]);f.set(L.MAP_EVENT_TYPES[l],Oe),n.value.on(L.MAP_EVENT_TYPES[l],Oe)}}n.value.getCanvas().addEventListener("webglcontextlost",O)}function g(){T.isMounted=!1,T.isLoaded=!1,n.value&&(n.value.getCanvas().removeEventListener("webglcontextlost",O),c.value=!1,f.forEach((d,l)=>{n.value.off(l.startsWith("__")?l.substring(2):l,d)}),n.value.remove())}function O(){g(),V()}return e.onMounted(()=>{V(),n.value&&(_=new ResizeObserver(je(n.value.resize.bind(n.value),100)),_.observe(r.value))}),e.onBeforeUnmount(()=>{_&&_.disconnect(),g()}),{map:n,componentContainer:a,container:r,isLoaded:h,isInitialized:c}},render(){return e.h("div",{ref:"componentContainer",class:"mgl-container",style:{height:this.$props.height,width:this.$props.width}},[e.h("div",{ref:"container",class:"mgl-wrapper"}),this.isInitialized&&this.$slots.default?this.$slots.default():void 0])}});function I(t,i,o){e.watch(t,a=>{var r,n;a&&A.indexOf(a)===-1||((r=i.value)!=null&&r.hasControl(o)&&i.value.removeControl(o),(n=i.value)==null||n.addControl(o,a))},{immediate:!0})}const K=e.defineComponent({name:"MglAttributionControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},compact:Boolean,customAttribution:[String,Array]},setup(t){const i=e.inject(y),o=new w.AttributionControl({compact:t.compact,customAttribution:t.customAttribution});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>i.value.removeControl(o))},render(){}}),H=class{constructor(i,o){p(this,"container");this.isAdded=i,this.container=document.createElement("div"),this.setClasses(o)}getDefaultPosition(){return j.TOP_LEFT}onAdd(){return e.nextTick(()=>this.isAdded.value=!0),this.container}onRemove(){this.isAdded.value=!1,this.container.remove()}setClasses(i){i?(this.container.classList.remove(H.CONTROL_CLASS),this.container.classList.remove(H.CONTROL_GROUP_CLASS)):(this.container.classList.add(H.CONTROL_CLASS),this.container.classList.add(H.CONTROL_GROUP_CLASS))}};let z=H;p(z,"CONTROL_CLASS","maplibregl-ctrl"),p(z,"CONTROL_GROUP_CLASS","maplibregl-ctrl-group");const J=e.defineComponent({name:"MglCustomControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},noClasses:{type:Boolean,default:!1}},setup(t){const i=e.inject(y),o=e.ref(!1),a=new z(o,t.noClasses);return I(e.toRef(t,"position"),i,a),e.watch(e.toRef(t,"noClasses"),r=>a.setClasses(r)),e.onBeforeUnmount(()=>{var r;(r=i.value)==null||r.removeControl(a)}),{isAdded:o,container:a.container}},render(){return this.isAdded?e.h(e.Teleport,{to:this.container},this.$slots.default?this.$slots.default():void 0):e.createCommentVNode("custom-component")}}),X=e.defineComponent({name:"MglFullscreenControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},container:{type:Object,default:null}},setup(t){const i=e.inject(y),o=new w.FullscreenControl({container:t.container||void 0});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});class Ae{constructor(i="rgba(0,0,0,0.9)",o=4*window.devicePixelRatio,a="#7cf859",r="Monaco, Consolas, Courier, monospace",n=60*window.devicePixelRatio,c=90*window.devicePixelRatio,h=0,f=5*window.devicePixelRatio,N=100*window.devicePixelRatio){p(this,"frames",0);p(this,"totalTime",0);p(this,"totalFrames",0);p(this,"time",null);p(this,"map");p(this,"container");p(this,"readOutput");p(this,"canvas");p(this,"eventHandlers",new Map);this.background=i,this.barWidth=o,this.color=a,this.font=r,this.graphHeight=n,this.graphWidth=c,this.graphTop=h,this.graphRight=f,this.width=N}getDefaultPosition(){return j.TOP_RIGHT}onAdd(i){this.map=i;const o=this.container=document.createElement("div");return o.className="mapboxgl-ctrl mapboxgl-ctrl-fps",o.style.backgroundColor=this.background,o.style.borderRadius="6px",this.readOutput=document.createElement("div"),this.readOutput.style.color=this.color,this.readOutput.style.fontFamily=this.font,this.readOutput.style.padding="0 5px 5px",this.readOutput.style.fontSize="9px",this.readOutput.style.fontWeight="bold",this.readOutput.textContent="Waiting…",this.canvas=document.createElement("canvas"),this.canvas.className="mapboxgl-ctrl-canvas",this.canvas.width=this.width,this.canvas.height=this.graphHeight,this.canvas.style.cssText=`width: ${this.width/window.devicePixelRatio}px; height: ${this.graphHeight/window.devicePixelRatio}px;`,o.appendChild(this.readOutput),o.appendChild(this.canvas),this.eventHandlers.set("movestart",this.onMoveStart.bind(this)),this.eventHandlers.set("moveend",this.onMoveEnd.bind(this)),this.map.on("movestart",this.eventHandlers.get("movestart")),this.map.on("moveend",this.eventHandlers.get("moveend")),this.container}onRemove(){this.map.off("movestart",this.eventHandlers.get("movestart")),this.map.off("moveend",this.eventHandlers.get("moveend")),this.eventHandlers.clear(),this.container.parentNode.removeChild(this.container),this.map=void 0}onMoveStart(){this.frames=0,this.time=performance.now(),this.eventHandlers.set("render",this.onRender.bind(this)),this.map.on("render",this.eventHandlers.get("render"))}onMoveEnd(){const i=performance.now();this.updateGraph(this.getFPS(i)),this.frames=0,this.time=null,this.map.off("render",this.eventHandlers.get("render"))}onRender(){if(this.time){this.frames++;const i=performance.now();i>=this.time+1e3&&(this.updateGraph(this.getFPS(i)),this.frames=0,this.time=performance.now())}}getFPS(i){return this.totalTime+=i-this.time,this.totalFrames+=this.frames,Math.round(1e3*this.frames/(i-this.time))||0}updateGraph(i){const o=this.canvas.getContext("2d"),a=Math.round(1e3*this.totalFrames/this.totalTime)||0,r=(this.graphHeight,this.barWidth);o.fillStyle=this.background,o.globalAlpha=1,o.fillRect(0,0,this.graphWidth,this.graphTop),o.fillStyle=this.color,this.readOutput.textContent=`${i} FPS (${a} Avg)`,o.drawImage(this.canvas,this.graphRight+r,this.graphTop,this.graphWidth-r,this.graphHeight,this.graphRight,this.graphTop,this.graphWidth-r,this.graphHeight),o.fillRect(this.graphRight+this.graphWidth-r,this.graphTop,r,this.graphHeight),o.fillStyle=this.background,o.globalAlpha=.75,o.fillRect(this.graphRight+this.graphWidth-r,this.graphTop,r,(1-i/100)*this.graphHeight)}}const Q=e.defineComponent({name:"MglFrameRateControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},background:{type:String,default:"rgba(0,0,0,0.9)"},barWidth:{type:Number,default:4*window.devicePixelRatio},color:{type:String,default:"#7cf859"},font:{type:String,default:"Monaco, Consolas, Courier, monospace"},graphHeight:{type:Number,default:60*window.devicePixelRatio},graphWidth:{type:Number,default:90*window.devicePixelRatio},graphTop:{type:Number,default:0},graphRight:{type:Number,default:5*window.devicePixelRatio},width:{type:Number,default:100*window.devicePixelRatio}},setup(t){const i=e.inject(y),o=new Ae(t.background,t.barWidth,t.color,t.font,t.graphHeight,t.graphWidth,t.graphTop,t.graphRight,t.width);I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}}),ee=e.defineComponent({name:"MglGeolocationControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},positionOptions:{type:Object,default:{enableHighAccuracy:!1,timeout:6e3}},fitBoundsOptions:{type:Object,default:{maxZoom:15}},trackUserLocation:{type:Boolean,default:!1},showAccuracyCircle:{type:Boolean,default:!0},showUserLocation:{type:Boolean,default:!0}},setup(t){const i=e.inject(y),o=new w.GeolocateControl({positionOptions:t.positionOptions,fitBoundsOptions:t.fitBoundsOptions,trackUserLocation:t.trackUserLocation,showAccuracyCircle:t.showAccuracyCircle,showUserLocation:t.showUserLocation});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}}),te=e.defineComponent({name:"MglNavigationControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},showCompass:{type:Boolean,default:!0},showZoom:{type:Boolean,default:!0},visualizePitch:Boolean},setup(t){const i=e.inject(y),o=new w.NavigationControl({showCompass:t.showCompass,showZoom:t.showZoom,visualizePitch:t.visualizePitch});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});var oe=(t=>(t.IMPERIAL="imperial",t.METRIC="metric",t.NAUTICAL="nautical",t))(oe||{});const Ie=Object.values(oe),ie=e.defineComponent({name:"MglScaleControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},maxWidth:{type:Number,default:100},unit:{type:String,default:"metric",validator:t=>Ie.indexOf(t)!==-1}},setup(t){const i=e.inject(y),o=new w.ScaleControl({maxWidth:t.maxWidth,unit:t.unit});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});var $=(t=>(t.DEFAULT="default",t.TEXT="text",t.MDI="mdi",t.SIMPLE_ICON="simple-icons",t))($||{});const Ne=Object.values($),U={text:void 0,mdi:{size:21,viewbox:"0 0 24 24"},["simple-icons"]:{size:21,viewbox:"0 0 24 24"},default:{size:0,viewbox:"0 0 0 0"}},Z=e.defineComponent({name:"MglButton",props:{type:{type:String,default:"default",validator:t=>Ne.indexOf(t)!==-1},path:{type:String},size:Number,viewbox:String},setup(t){!t.path&&t.type!=="text"&&e.warn("property `path` must be set on MaplibreButton");const i=e.ref(U[t.type]||U.default);return e.watch(()=>t.type,o=>i.value=U[o]||U.default),{defaults:i}},render(){return this.type==="text"?e.h("button",{type:"button"},this.$slots.default?this.$slots.default():void 0):e.h("button",{type:"button",class:"maplibregl-ctrl-icon"},[e.h("svg",{width:this.size||this.defaults.size,height:this.size||this.defaults.size,viewBox:this.viewbox||this.defaults.viewbox},e.h("path",{fill:"currentColor",d:this.path})),this.$slots.default?this.$slots.default():void 0])}});function ae(t){return t&&!!t.stopPropagation}const ne=e.defineComponent({name:"MglStyleSwitchControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},mapStyles:{type:Array,required:!0,default:[]},modelValue:{type:Object},isOpen:{type:Boolean,default:void 0}},emits:["update:modelValue","update:isOpen"],setup(t,{emit:i}){const o=e.inject(y),a=e.inject(C),r=e.inject(F),n=e.ref(!1),c=e.ref(t.isOpen===void 0?!1:t.isOpen),h=e.shallowRef(t.modelValue===void 0?t.mapStyles.length?t.mapStyles[0]:null:t.modelValue),f=new z(n,!1),N=V.bind(null,!1);function T(){const g=o.value.getStyle().name;for(let O=0,d=t.mapStyles.length;O<d;O++)if(t.mapStyles[O].name===g){_(t.mapStyles[O]);break}}e.watch(a,g=>{g&&T()},{immediate:!0}),o.value.on("style.load",T),document.addEventListener("click",N),I(e.toRef(t,"position"),o,f),t.modelValue!==void 0&&e.watch(e.toRef(t,"modelValue"),g=>{g!==void 0&&(h.value=g)}),t.isOpen!==void 0&&e.watch(e.toRef(t,"isOpen"),g=>{g!==void 0&&(c.value=g)}),e.onBeforeUnmount(()=>{o.value.removeControl(f),o.value.off("style.load",T),document.removeEventListener("click",N)});function _(g){var O;((O=h.value)==null?void 0:O.name)!==g.name&&(r.emit("styleSwitched",g),o.value.setStyle(g.style),t.modelValue===void 0&&(h.value=g),i("update:modelValue",g),V(!1))}function V(g,O){ae(O)?O.stopPropagation():ae(g)&&g.stopPropagation(),!(t.isOpen!==void 0&&t.isOpen===g||c.value===g)&&(t.isOpen===void 0?(c.value=typeof g=="boolean"?g:!c.value,i("update:isOpen",c.value)):i("update:isOpen",typeof g=="boolean"?g:!t.isOpen))}return{isAdded:n,container:f.container,setStyle:_,toggleOpen:V,intIsOpen:c,intModelValue:h}},template:` | ||
`,document.head.appendChild(G);const $e="",y=Symbol("map"),C=Symbol("isLoaded"),S=Symbol("componentId"),R=Symbol("sourceId"),E=Symbol("sourceLayerRegistry"),F=Symbol("emitter");function Me(t){return Object.keys(t)}function P(t){return Object.keys(t)}const u=e.reactive({style:"https://demotiles.maplibre.org/style.json",center:Object.freeze([0,0]),zoom:1,trackResize:!1});class L{static createEventHandler(i,o,a,r){return(n={})=>a.emit(r,{type:n.type,map:o,component:i,event:n})}}p(L,"MAP_OPTION_KEYS",["antialias","attributionControl","bearing","bearingSnap","bounds","boxZoom","center","clickTolerance","collectResourceTiming","crossSourceCollisions","container","customAttribution","dragPan","dragRotate","doubleClickZoom","hash","fadeDuration","failIfMajorPerformanceCaveat","fitBoundsOptions","interactive","keyboard","locale","localIdeographFontFamily","logoPosition","maxBounds","maxPitch","maxZoom","minPitch","minZoom","preserveDrawingBuffer","pitch","pitchWithRotate","refreshExpiredTiles","renderWorldCopies","scrollZoom","mapStyle","trackResize","transformRequest","touchZoomRotate","touchPitch","zoom","maxTileCacheSize","pixelRatio","cooperativeGestures"]),p(L,"MARKER_OPTION_KEYS",["element","offset","anchor","color","draggable","clickTolerance","rotation","rotationAlignment","pitchAlignment","scale"]),p(L,"MAP_EVENT_TYPES",["error","load","idle","remove","render","resize","webglcontextlost","webglcontextrestored","dataloading","data","tiledataloading","sourcedataloading","styledataloading","sourcedata","styledata","boxzoomcancel","boxzoomstart","boxzoomend","touchcancel","touchmove","touchend","touchstart","click","contextmenu","dblclick","mousemove","mouseup","mousedown","mouseout","mouseover","movestart","move","moveend","zoomstart","zoom","zoomend","rotatestart","rotate","rotateend","dragstart","drag","dragend","pitchstart","pitch","pitchend","wheel"]);var j=(t=>(t.TOP_LEFT="top-left",t.TOP_RIGHT="top-right",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_RIGHT="bottom-right",t))(j||{});const A=Object.values(j),D=new Map,Y=Symbol("default");function ve(t=Y){let i=D.get(t);return i||(i=e.reactive({isLoaded:!1,isMounted:!1}),D.set(t,i)),i}function Ee(t,i=Y){var a;let o=D.get(i);return o||(o=e.reactive({isLoaded:!1,isMounted:!1}),D.set(i,o)),o.isLoaded=!1,o.isMounted=!1,o.component=t,o.map=t.map,o.isLoaded=((a=t.map)==null?void 0:a.loaded())||!1,o}function je(t,i=250,o=!1){let a;function r(){const n=arguments,c=()=>{a=void 0,o!==!0&&t.apply(this,n)};clearTimeout(a),o===!0&&a===void 0&&t.apply(this,n),a=window.setTimeout(c,i)}return r.cancel=()=>{clearTimeout(a)},r}const q=e.defineComponent({name:"MglMap",props:{width:{type:[Number,String],default:"100%"},height:{type:[Number,String],default:"100%"},antialias:{type:Boolean,default:()=>u.antialias},attributionControl:{type:Boolean,default:()=>u.attributionControl},bearing:{type:Number,default:()=>u.bearing},bearingSnap:{type:Number,default:()=>u.bearingSnap},bounds:{type:[Array,Object],default:()=>u.bounds},boxZoom:{type:Boolean,default:()=>u.boxZoom},center:{type:[Array,Object],default:()=>u.center},clickTolerance:{type:Number,default:()=>u.clickTolerance},collectResourceTiming:{type:Boolean,default:()=>u.collectResourceTiming},crossSourceCollisions:{type:Boolean,default:()=>u.crossSourceCollisions},customAttribution:{type:[String,Array],default:()=>u.customAttribution},dragPan:{type:Boolean,default:()=>u.dragPan},dragRotate:{type:Boolean,default:()=>u.dragRotate},doubleClickZoom:{type:Boolean,default:()=>u.doubleClickZoom},hash:{type:[Boolean,String],default:()=>u.hash},fadeDuration:{type:Number,default:()=>u.fadeDuration},failIfMajorPerformanceCaveat:{type:Boolean,default:()=>u.failIfMajorPerformanceCaveat},fitBoundsOptions:{type:Object,default:()=>u.fitBoundsOptions},interactive:{type:Boolean,default:()=>u.interactive},keyboard:{type:Boolean,default:()=>u.keyboard},locale:{type:Object,default:()=>u.locale},localIdeographFontFamily:{type:String,default:()=>u.localIdeographFontFamily},logoPosition:{type:[String],validator:t=>t in j,default:()=>u.logoPosition},maxBounds:{type:[Array,Object],default:()=>u.maxBounds},maxPitch:{type:Number,default:()=>u.maxPitch},maxZoom:{type:Number,default:()=>u.maxZoom},minPitch:{type:Number,default:()=>u.minPitch},minZoom:{type:Number,default:()=>u.minZoom},preserveDrawingBuffer:{type:Boolean,default:()=>u.preserveDrawingBuffer},pitch:{type:Number,default:()=>u.pitch},pitchWithRotate:{type:Boolean,default:()=>u.pitchWithRotate},refreshExpiredTiles:{type:Boolean,default:()=>u.refreshExpiredTiles},renderWorldCopies:{type:Boolean,default:()=>u.renderWorldCopies},scrollZoom:{type:Boolean,default:()=>u.scrollZoom},mapStyle:{type:[String,Object],default:()=>u.style},trackResize:{type:Boolean,default:()=>u.trackResize},transformRequest:{type:Function,default:u.transformRequest},touchZoomRotate:{type:Boolean,default:()=>u.touchZoomRotate},touchPitch:{type:Boolean,default:()=>u.touchPitch},zoom:{type:Number,default:()=>u.zoom},maxTileCacheSize:{type:Number,default:()=>u.maxTileCacheSize},mapKey:{type:[String,Symbol]},pixelRatio:{type:Number,default:()=>u.pixelRatio},cooperativeGestures:{type:[Boolean,Object],default:()=>u.cooperativeGestures}},emits:["map:error","map:load","map:idle","map:remove","map:render","map:resize","map:webglcontextlost","map:webglcontextrestored","map:dataloading","map:data","map:tiledataloading","map:sourcedataloading","map:styledataloading","map:sourcedata","map:styledata","map:boxzoomcancel","map:boxzoomstart","map:boxzoomend","map:touchcancel","map:touchmove","map:touchend","map:touchstart","map:click","map:contextmenu","map:dblclick","map:mousemove","map:mouseup","map:mousedown","map:mouseout","map:mouseover","map:movestart","map:move","map:moveend","map:zoomstart","map:zoom","map:zoomend","map:rotatestart","map:rotate","map:rotateend","map:dragstart","map:drag","map:dragend","map:pitchstart","map:pitch","map:pitchend","map:wheel"],setup(t,i){const o=e.markRaw(e.getCurrentInstance()),a=e.shallowRef(null),r=e.shallowRef(null),n=e.shallowRef(null),c=e.ref(!1),h=e.ref(!1),f=new Map,T=Le(),N=Ee(o,t.mapKey);let _;e.provide(y,n),e.provide(C,h),e.provide(S,o.uid),e.provide(R,""),e.provide(F,T),e.watch(e.toRef(t,"bearing"),d=>{var l;d&&((l=n.value)==null||l.setBearing(d))}),e.watch(e.toRef(t,"bounds"),d=>{var l;d&&((l=n.value)==null||l.fitBounds(d,t.fitBoundsOptions))}),e.watch(e.toRef(t,"center"),d=>{var l;d&&((l=n.value)==null||l.setCenter(d))}),e.watch(e.toRef(t,"maxBounds"),d=>{var l;d&&((l=n.value)==null||l.setMaxBounds(d))}),e.watch(e.toRef(t,"maxPitch"),d=>{var l;d&&((l=n.value)==null||l.setMaxPitch(d))}),e.watch(e.toRef(t,"maxZoom"),d=>{var l;d&&((l=n.value)==null||l.setMaxZoom(d))}),e.watch(e.toRef(t,"minPitch"),d=>{var l;d&&((l=n.value)==null||l.setMinPitch(d))}),e.watch(e.toRef(t,"minZoom"),d=>{var l;d&&((l=n.value)==null||l.setMinZoom(d))}),e.watch(e.toRef(t,"pitch"),d=>{var l;d&&((l=n.value)==null||l.setPitch(d))}),e.watch(e.toRef(t,"renderWorldCopies"),d=>{var l;d&&((l=n.value)==null||l.setRenderWorldCopies(d))}),e.watch(e.toRef(t,"mapStyle"),d=>{var l;d&&((l=n.value)==null||l.setStyle(d))}),e.watch(e.toRef(t,"transformRequest"),d=>{var l;d&&((l=n.value)==null||l.setTransformRequest(d))}),e.watch(e.toRef(t,"zoom"),d=>{var l;d&&((l=n.value)==null||l.setZoom(d))}),e.watch(e.toRef(t,"zoom"),d=>{var l;d&&((l=n.value)==null||l.setZoom(d))});function V(){N.isMounted=!0;const d=Object.keys(t).filter(l=>t[l]!==void 0&&L.MAP_OPTION_KEYS.indexOf(l)!==-1).reduce((l,k)=>(l[k==="mapStyle"?"style":k]=e.unref(t[k]),l),{container:r.value});if(n.value=e.markRaw(new w.Map(d)),N.map=n.value,c.value=!0,f.set("__load",()=>(h.value=!0,N.isLoaded=!0)),n.value.on("load",f.get("__load")),o.vnode.props){for(let l=0,k=L.MAP_EVENT_TYPES.length;l<k;l++)if(o.vnode.props["onMap:"+L.MAP_EVENT_TYPES[l]]){const Oe=L.createEventHandler(o,n.value,i,"map:"+L.MAP_EVENT_TYPES[l]);f.set(L.MAP_EVENT_TYPES[l],Oe),n.value.on(L.MAP_EVENT_TYPES[l],Oe)}}n.value.getCanvas().addEventListener("webglcontextlost",O)}function g(){N.isMounted=!1,N.isLoaded=!1,n.value&&(n.value.getCanvas().removeEventListener("webglcontextlost",O),c.value=!1,f.forEach((d,l)=>{n.value.off(l.startsWith("__")?l.substring(2):l,d)}),n.value.remove())}function O(){g(),e.nextTick(V)}return e.onMounted(()=>{V(),n.value&&(_=new ResizeObserver(je(n.value.resize.bind(n.value),100)),_.observe(r.value))}),e.onBeforeUnmount(()=>{_&&_.disconnect(),g()}),{map:n,componentContainer:a,container:r,isLoaded:h,isInitialized:c}},render(){return e.h("div",{ref:"componentContainer",class:"mgl-container",style:{height:this.$props.height,width:this.$props.width}},[e.h("div",{ref:"container",class:"mgl-wrapper"}),this.isInitialized&&this.$slots.default?this.$slots.default():void 0])}});function I(t,i,o){e.watch(t,a=>{var r,n;a&&A.indexOf(a)===-1||((r=i.value)!=null&&r.hasControl(o)&&i.value.removeControl(o),(n=i.value)==null||n.addControl(o,a))},{immediate:!0})}const K=e.defineComponent({name:"MglAttributionControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},compact:Boolean,customAttribution:[String,Array]},setup(t){const i=e.inject(y),o=new w.AttributionControl({compact:t.compact,customAttribution:t.customAttribution});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>i.value.removeControl(o))},render(){}}),H=class{constructor(i,o){p(this,"container");this.isAdded=i,this.container=document.createElement("div"),this.setClasses(o)}getDefaultPosition(){return j.TOP_LEFT}onAdd(){return e.nextTick(()=>this.isAdded.value=!0),this.container}onRemove(){this.isAdded.value=!1,this.container.remove()}setClasses(i){i?(this.container.classList.remove(H.CONTROL_CLASS),this.container.classList.remove(H.CONTROL_GROUP_CLASS)):(this.container.classList.add(H.CONTROL_CLASS),this.container.classList.add(H.CONTROL_GROUP_CLASS))}};let z=H;p(z,"CONTROL_CLASS","maplibregl-ctrl"),p(z,"CONTROL_GROUP_CLASS","maplibregl-ctrl-group");const J=e.defineComponent({name:"MglCustomControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},noClasses:{type:Boolean,default:!1}},setup(t){const i=e.inject(y),o=e.ref(!1),a=new z(o,t.noClasses);return I(e.toRef(t,"position"),i,a),e.watch(e.toRef(t,"noClasses"),r=>a.setClasses(r)),e.onBeforeUnmount(()=>{var r;(r=i.value)==null||r.removeControl(a)}),{isAdded:o,container:a.container}},render(){return this.isAdded?e.h(e.Teleport,{to:this.container},this.$slots.default?this.$slots.default():void 0):e.createCommentVNode("custom-component")}}),X=e.defineComponent({name:"MglFullscreenControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},container:{type:Object,default:null}},setup(t){const i=e.inject(y),o=new w.FullscreenControl({container:t.container||void 0});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});class Ae{constructor(i="rgba(0,0,0,0.9)",o=4*window.devicePixelRatio,a="#7cf859",r="Monaco, Consolas, Courier, monospace",n=60*window.devicePixelRatio,c=90*window.devicePixelRatio,h=0,f=5*window.devicePixelRatio,T=100*window.devicePixelRatio){p(this,"frames",0);p(this,"totalTime",0);p(this,"totalFrames",0);p(this,"time",null);p(this,"map");p(this,"container");p(this,"readOutput");p(this,"canvas");p(this,"eventHandlers",new Map);this.background=i,this.barWidth=o,this.color=a,this.font=r,this.graphHeight=n,this.graphWidth=c,this.graphTop=h,this.graphRight=f,this.width=T}getDefaultPosition(){return j.TOP_RIGHT}onAdd(i){this.map=i;const o=this.container=document.createElement("div");return o.className="mapboxgl-ctrl mapboxgl-ctrl-fps",o.style.backgroundColor=this.background,o.style.borderRadius="6px",this.readOutput=document.createElement("div"),this.readOutput.style.color=this.color,this.readOutput.style.fontFamily=this.font,this.readOutput.style.padding="0 5px 5px",this.readOutput.style.fontSize="9px",this.readOutput.style.fontWeight="bold",this.readOutput.textContent="Waiting…",this.canvas=document.createElement("canvas"),this.canvas.className="mapboxgl-ctrl-canvas",this.canvas.width=this.width,this.canvas.height=this.graphHeight,this.canvas.style.cssText=`width: ${this.width/window.devicePixelRatio}px; height: ${this.graphHeight/window.devicePixelRatio}px;`,o.appendChild(this.readOutput),o.appendChild(this.canvas),this.eventHandlers.set("movestart",this.onMoveStart.bind(this)),this.eventHandlers.set("moveend",this.onMoveEnd.bind(this)),this.map.on("movestart",this.eventHandlers.get("movestart")),this.map.on("moveend",this.eventHandlers.get("moveend")),this.container}onRemove(){this.map.off("movestart",this.eventHandlers.get("movestart")),this.map.off("moveend",this.eventHandlers.get("moveend")),this.eventHandlers.clear(),this.container.parentNode.removeChild(this.container),this.map=void 0}onMoveStart(){this.frames=0,this.time=performance.now(),this.eventHandlers.set("render",this.onRender.bind(this)),this.map.on("render",this.eventHandlers.get("render"))}onMoveEnd(){const i=performance.now();this.updateGraph(this.getFPS(i)),this.frames=0,this.time=null,this.map.off("render",this.eventHandlers.get("render"))}onRender(){if(this.time){this.frames++;const i=performance.now();i>=this.time+1e3&&(this.updateGraph(this.getFPS(i)),this.frames=0,this.time=performance.now())}}getFPS(i){return this.totalTime+=i-this.time,this.totalFrames+=this.frames,Math.round(1e3*this.frames/(i-this.time))||0}updateGraph(i){const o=this.canvas.getContext("2d"),a=Math.round(1e3*this.totalFrames/this.totalTime)||0,r=(this.graphHeight,this.barWidth);o.fillStyle=this.background,o.globalAlpha=1,o.fillRect(0,0,this.graphWidth,this.graphTop),o.fillStyle=this.color,this.readOutput.textContent=`${i} FPS (${a} Avg)`,o.drawImage(this.canvas,this.graphRight+r,this.graphTop,this.graphWidth-r,this.graphHeight,this.graphRight,this.graphTop,this.graphWidth-r,this.graphHeight),o.fillRect(this.graphRight+this.graphWidth-r,this.graphTop,r,this.graphHeight),o.fillStyle=this.background,o.globalAlpha=.75,o.fillRect(this.graphRight+this.graphWidth-r,this.graphTop,r,(1-i/100)*this.graphHeight)}}const Q=e.defineComponent({name:"MglFrameRateControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},background:{type:String,default:"rgba(0,0,0,0.9)"},barWidth:{type:Number,default:4*window.devicePixelRatio},color:{type:String,default:"#7cf859"},font:{type:String,default:"Monaco, Consolas, Courier, monospace"},graphHeight:{type:Number,default:60*window.devicePixelRatio},graphWidth:{type:Number,default:90*window.devicePixelRatio},graphTop:{type:Number,default:0},graphRight:{type:Number,default:5*window.devicePixelRatio},width:{type:Number,default:100*window.devicePixelRatio}},setup(t){const i=e.inject(y),o=new Ae(t.background,t.barWidth,t.color,t.font,t.graphHeight,t.graphWidth,t.graphTop,t.graphRight,t.width);I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}}),ee=e.defineComponent({name:"MglGeolocationControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},positionOptions:{type:Object,default:{enableHighAccuracy:!1,timeout:6e3}},fitBoundsOptions:{type:Object,default:{maxZoom:15}},trackUserLocation:{type:Boolean,default:!1},showAccuracyCircle:{type:Boolean,default:!0},showUserLocation:{type:Boolean,default:!0}},setup(t){const i=e.inject(y),o=new w.GeolocateControl({positionOptions:t.positionOptions,fitBoundsOptions:t.fitBoundsOptions,trackUserLocation:t.trackUserLocation,showAccuracyCircle:t.showAccuracyCircle,showUserLocation:t.showUserLocation});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}}),te=e.defineComponent({name:"MglNavigationControl",props:{position:{type:String,default:j.TOP_RIGHT,validator:t=>A.indexOf(t)!==-1},showCompass:{type:Boolean,default:!0},showZoom:{type:Boolean,default:!0},visualizePitch:Boolean},setup(t){const i=e.inject(y),o=new w.NavigationControl({showCompass:t.showCompass,showZoom:t.showZoom,visualizePitch:t.visualizePitch});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});var oe=(t=>(t.IMPERIAL="imperial",t.METRIC="metric",t.NAUTICAL="nautical",t))(oe||{});const Ie=Object.values(oe),ie=e.defineComponent({name:"MglScaleControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},maxWidth:{type:Number,default:100},unit:{type:String,default:"metric",validator:t=>Ie.indexOf(t)!==-1}},setup(t){const i=e.inject(y),o=new w.ScaleControl({maxWidth:t.maxWidth,unit:t.unit});I(e.toRef(t,"position"),i,o),e.onBeforeUnmount(()=>{var a;return(a=i.value)==null?void 0:a.removeControl(o)})},render(){}});var $=(t=>(t.DEFAULT="default",t.TEXT="text",t.MDI="mdi",t.SIMPLE_ICON="simple-icons",t))($||{});const Te=Object.values($),U={text:void 0,mdi:{size:21,viewbox:"0 0 24 24"},["simple-icons"]:{size:21,viewbox:"0 0 24 24"},default:{size:0,viewbox:"0 0 0 0"}},Z=e.defineComponent({name:"MglButton",props:{type:{type:String,default:"default",validator:t=>Te.indexOf(t)!==-1},path:{type:String},size:Number,viewbox:String},setup(t){!t.path&&t.type!=="text"&&e.warn("property `path` must be set on MaplibreButton");const i=e.ref(U[t.type]||U.default);return e.watch(()=>t.type,o=>i.value=U[o]||U.default),{defaults:i}},render(){return this.type==="text"?e.h("button",{type:"button"},this.$slots.default?this.$slots.default():void 0):e.h("button",{type:"button",class:"maplibregl-ctrl-icon"},[e.h("svg",{width:this.size||this.defaults.size,height:this.size||this.defaults.size,viewBox:this.viewbox||this.defaults.viewbox},e.h("path",{fill:"currentColor",d:this.path})),this.$slots.default?this.$slots.default():void 0])}});function ae(t){return t&&!!t.stopPropagation}const ne=e.defineComponent({name:"MglStyleSwitchControl",props:{position:{type:String,validator:t=>A.indexOf(t)!==-1},mapStyles:{type:Array,required:!0,default:[]},modelValue:{type:Object},isOpen:{type:Boolean,default:void 0}},emits:["update:modelValue","update:isOpen"],setup(t,{emit:i}){const o=e.inject(y),a=e.inject(C),r=e.inject(F),n=e.ref(!1),c=e.ref(t.isOpen===void 0?!1:t.isOpen),h=e.shallowRef(t.modelValue===void 0?t.mapStyles.length?t.mapStyles[0]:null:t.modelValue),f=new z(n,!1),T=V.bind(null,!1);function N(){const g=o.value.getStyle().name;for(let O=0,d=t.mapStyles.length;O<d;O++)if(t.mapStyles[O].name===g){_(t.mapStyles[O]);break}}e.watch(a,g=>{g&&N()},{immediate:!0}),o.value.on("style.load",N),document.addEventListener("click",T),I(e.toRef(t,"position"),o,f),t.modelValue!==void 0&&e.watch(e.toRef(t,"modelValue"),g=>{g!==void 0&&(h.value=g)}),t.isOpen!==void 0&&e.watch(e.toRef(t,"isOpen"),g=>{g!==void 0&&(c.value=g)}),e.onBeforeUnmount(()=>{o.value.removeControl(f),o.value.off("style.load",N),document.removeEventListener("click",T)});function _(g){var O;((O=h.value)==null?void 0:O.name)!==g.name&&(r.emit("styleSwitched",g),o.value.setStyle(g.style),t.modelValue===void 0&&(h.value=g),i("update:modelValue",g),V(!1))}function V(g,O){ae(O)?O.stopPropagation():ae(g)&&g.stopPropagation(),!(t.isOpen!==void 0&&t.isOpen===g||c.value===g)&&(t.isOpen===void 0?(c.value=typeof g=="boolean"?g:!c.value,i("update:isOpen",c.value)):i("update:isOpen",typeof g=="boolean"?g:!t.isOpen))}return{isAdded:n,container:f.container,setStyle:_,toggleOpen:V,intIsOpen:c,intModelValue:h}},template:` | ||
<slot> | ||
@@ -13,3 +13,3 @@ <slot name="button"></slot> | ||
</slot> | ||
`,render(){if(!this.isAdded)return e.createCommentVNode("style-switch-control");const t={isOpen:this.intIsOpen,currentStyle:this.intModelValue,mapStyles:this.mapStyles,toggleOpen:this.toggleOpen,setStyle:this.setStyle};return e.h(e.Teleport,{to:this.container},this.$slots.default?this.$slots.default(t):[this.$slots.button?this.$slots.button(t):e.h(Z,{type:$.MDI,path:"M12,18.54L19.37,12.8L21,14.07L12,21.07L3,14.07L4.62,12.81L12,18.54M12,16L3,9L12,2L21,9L12,16M12,4.53L6.26,9L12,13.47L17.74,9L12,4.53Z",class:["maplibregl-ctrl-icon maplibregl-style-switch",this.intIsOpen?"is-open":""],onClick:this.toggleOpen.bind(null,!0)}),this.$slots.styleList?this.$slots.styleList(t):e.h("div",{class:["maplibregl-style-list",this.intIsOpen?"is-open":""]},this.mapStyles.map(i=>{var o,a;return i.icon?e.h(Z,{type:$.MDI,path:i.icon.path,class:((o=this.intModelValue)==null?void 0:o.name)===i.name?"is-active":"",onClick:()=>this.setStyle(i)},e.createTextVNode(i.label)):e.h("button",{type:"button",class:((a=this.intModelValue)==null?void 0:a.name)===i.name?"is-active":"",onClick:()=>this.setStyle(i)},e.createTextVNode(i.label))}))])}}),re=e.defineComponent({name:"MglMarker",props:{coordinates:{type:[Object,Array],required:!0},offset:[Object,Array],anchor:String,color:String,clickTolerance:Number,rotation:Number,rotationAlignment:String,pitchAlignment:String,scale:Number},setup(t){const i=e.inject(y),o=Object.keys(t).filter(r=>t[r]!==void 0&&L.MARKER_OPTION_KEYS.indexOf(r)!==-1).reduce((r,n)=>(r[n]=e.unref(t[n]),r),{}),a=new w.Marker(o);return a.setLngLat(t.coordinates).addTo(i.value),e.watch(()=>t.coordinates,r=>a.setLngLat(r)),e.watch(()=>t.offset,r=>a.setOffset(r||[0,0])),e.watch(()=>t.pitchAlignment,r=>a.setPitchAlignment(r||"auto")),e.watch(()=>t.rotationAlignment,r=>a.setRotationAlignment(r||"auto")),e.onBeforeUnmount(a.remove.bind(a)),{marker:a}},render(){}});class B{constructor(){p(this,"unmountHandlers",new Map)}registerUnmountHandler(i,o){this.unmountHandlers.set(i,o)}unregisterUnmountHandler(i){this.unmountHandlers.delete(i)}unmount(){this.unmountHandlers.forEach(i=>i())}}const W=class{static genSourceOpts(i,o,a){return Object.keys(o).filter(r=>o[r]!==void 0&&a.indexOf(r)!==-1).reduce((r,n)=>(r[n]=e.unref(o[n]),r),{type:i})}static getSourceRef(i,o){const a=typeof o=="string",r=String(i)+(a?o:"");let n=W.REFS.get(r);return n||(n=e.ref(a?null:void 0),W.REFS.set(r,n)),n}};let b=W;p(b,"REFS",new Map);function x(t,i,o,a,r){const n=e.inject(y),c=e.inject(C),h=e.inject(F);function f(){c.value&&(n.value.addSource(i.sourceId,b.genSourceOpts(o,i,a)),t.value=n.value.getSource(i.sourceId))}function N(){t.value=null}return e.watch(c,f,{immediate:!0}),n.value.on("style.load",f),h.on("styleSwitched",N),e.onBeforeUnmount(()=>{c.value&&(r.unmount(),n.value.removeSource(i.sourceId)),n.value.off("style.load",f),h.off("styleSwitched",N)})}const Te=P({animate:void 0,canvas:void 0,coordinates:void 0}),le=e.defineComponent({name:"MglCanvasSource",props:{sourceId:{type:String,required:!0},coordinates:Array,animate:Boolean,canvas:[Object,String]},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"canvas",Te,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return[e.createCommentVNode("Canvas Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),Pe=P({data:void 0,maxzoom:void 0,attribution:void 0,buffer:void 0,tolerance:void 0,cluster:void 0,clusterRadius:void 0,clusterMaxZoom:void 0,clusterMinPoints:void 0,clusterProperties:void 0,lineMetrics:void 0,generateId:void 0,promoteId:void 0,filter:void 0}),se=e.defineComponent({name:"MglGeoJsonSource",props:{sourceId:{type:String,required:!0},data:[Object,String],maxzoom:Number,attribution:String,buffer:Number,tolerance:Number,cluster:[Number,Boolean],clusterRadius:Number,clusterMaxZoom:Number,clusterMinPoints:Number,clusterProperties:Object,lineMetrics:Boolean,generateId:Boolean,promoteId:[Object,String],filter:[Array,String,Object]},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"geojson",Pe,a),e.watch(e.toRef(t,"data"),r=>{var n;return(n=o.value)==null?void 0:n.setData(r||{type:"FeatureCollection",features:[]})}),{source:o}},render(){return[e.createCommentVNode("GeoJSON Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),xe=P({url:void 0,coordinates:void 0}),ce=e.defineComponent({name:"MglImageSource",props:{sourceId:{type:String,required:!0},url:String,coordinates:Array},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"image",xe,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return[e.createCommentVNode("Image Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),Be=P({url:void 0,tiles:void 0,bounds:void 0,minzoom:void 0,maxzoom:void 0,tileSize:void 0,scheme:void 0,attribution:void 0,volatile:void 0}),de=e.defineComponent({name:"MglRasterSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,minzoom:Number,maxzoom:Number,tileSize:Number,scheme:String,attribution:String,volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"raster",Be,a),{source:o}},render(){return e.createCommentVNode("Video Source")}}),_e=P({url:void 0,tiles:void 0,bounds:void 0,minzoom:void 0,maxzoom:void 0,tileSize:void 0,attribution:void 0,encoding:void 0,volatile:void 0}),ue=e.defineComponent({name:"MglRasterDemSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,minzoom:Number,maxzoom:Number,tileSize:Number,attribution:String,encoding:String,volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"raster-dem",_e,a),{source:o}},render(){return e.createCommentVNode("Video Source")}}),ze=P({url:void 0,tiles:void 0,bounds:void 0,scheme:void 0,minzoom:void 0,maxzoom:void 0,attribution:void 0,promoteId:void 0,volatile:void 0}),me=e.defineComponent({name:"MglVectorSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,scheme:String,minzoom:Number,maxzoom:Number,attribution:String,promoteId:[Object,String],volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"vector",ze,a),e.watch(e.toRef(t,"tiles"),r=>{var n;return(n=o.value)==null?void 0:n.setTiles(r||[])}),e.watch(e.toRef(t,"url"),r=>{var n;return(n=o.value)==null?void 0:n.setUrl(r||"")}),{source:o}},render(){return e.createCommentVNode("Vector Source")}}),He=P({urls:void 0,coordinates:void 0}),fe=e.defineComponent({name:"MglVideoSource",props:{sourceId:{type:String,required:!0},urls:Array,coordinates:Array},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"video",He,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return e.createCommentVNode("Video Source")}}),M=class{static genLayerOpts(i,o,a,r){return Object.keys(a).filter(n=>a[n]!==void 0&&M.SOURCE_OPTS.indexOf(n)!==-1).reduce((n,c)=>(n[c==="sourceLayer"?"source-layer":c]=e.unref(a[c]),n),{type:o,source:a.source||r,id:i})}static registerLayerEvents(i,o,a){if(a.props)for(let r=0,n=M.LAYER_EVENTS.length;r<n;r++){const c="on"+M.LAYER_EVENTS[r].charAt(0).toUpperCase()+M.LAYER_EVENTS[r].substr(1);a.props[c]&&i.on(M.LAYER_EVENTS[r],o,a.props[c])}}static unregisterLayerEvents(i,o,a){if(a.props)for(let r=0,n=M.LAYER_EVENTS.length;r<n;r++){const c="on"+M.LAYER_EVENTS[r].charAt(0).toUpperCase()+M.LAYER_EVENTS[r].substr(1);a.props[c]&&i.off(M.LAYER_EVENTS[r],o,a.props[c])}}};let m=M;p(m,"SOURCE_OPTS",["metadata","ref","source","sourceLayer","minzoom","maxzoom","interactive","filter","layout","paint"]),p(m,"LAYER_EVENTS",["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"]),p(m,"SHARED",{props:{layerId:{type:String,required:!0},source:[String,Object],metadata:[Object,Array,String,Number],ref:String,sourceLayer:String,minzoom:Number,maxzoom:Number,interactive:Boolean,filter:Array,before:String},emits:["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"]});function v(t,i){const o=e.inject(y),a=e.inject(C),r=e.inject(E);function n(){a.value&&(i&&m.unregisterLayerEvents(o.value,t,i.vnode),o.value.getLayer(t)&&o.value.removeLayer(t))}r.registerUnmountHandler(t,n),e.onBeforeUnmount(()=>{r.unregisterUnmountHandler(t),n()})}const he=e.defineComponent({name:"MglBackgroundLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Background Layer: layer must be used inside source tag or source prop must be set");return}const o=e.inject(y),a=e.inject(C),r=e.inject(S),n=b.getSourceRef(r,t.source||i);v(t.layerId),e.watch([a,n],([c,h])=>{c&&(h||h===void 0)&&o.value.addLayer(m.genLayerOpts(t.layerId,"background",t,i),t.before||void 0)},{immediate:!0})},render(){return e.createCommentVNode("Background Layer")}}),ge=e.defineComponent({name:"MglCircleLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Circle Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"circle",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Circle Layer")}}),ye=e.defineComponent({name:"MglFillLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Fill Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"fill",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Fill Layer")}}),pe=e.defineComponent({name:"MglFillExtrusionLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Fill Extrude Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"fill-extrusion",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Fill Extrusion Layer")}}),be=e.defineComponent({name:"MglHeatmapLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Heatmap Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"heatmap",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Heatmap Layer")}}),Se=e.defineComponent({name:"MglHillshadeLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Hillshade Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"hillshade",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Hillshade Layer")}}),Re=e.defineComponent({name:"MglLineLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Line Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"line",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Line Layer")}}),Ce=e.defineComponent({name:"MglRasterLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Raster Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"raster",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Raster Layer")}}),we=e.defineComponent({name:"MglSymbolLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Symbol Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"symbol",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Symbol Layer")}}),Ve=Object.freeze(Object.defineProperty({__proto__:null,MglAttributionControl:K,MglBackgroundLayer:he,MglButton:Z,MglCanvasSource:le,MglCircleLayer:ge,MglCustomControl:J,MglFillExtrusionLayer:pe,MglFillLayer:ye,MglFrameRateControl:Q,MglFullscreenControl:X,MglGeoJsonSource:se,MglGeolocationControl:ee,MglHeatmapLayer:be,MglHillshadeLayer:Se,MglImageSource:ce,MglLineLayer:Re,MglMap:q,MglMarker:re,MglNavigationControl:te,MglRasterDemSource:ue,MglRasterLayer:Ce,MglRasterSource:de,MglScaleControl:ie,MglStyleSwitchControl:ne,MglSymbolLayer:we,MglVectorSource:me,MglVideoSource:fe},Symbol.toStringTag,{value:"Module"})),ke=function(i){Object.entries(Ve).forEach(([o,a])=>{i.component(o,a)})};s.AllOptions=Me,s.AllSourceOptions=P,s.MglAttributionControl=K,s.MglBackgroundLayer=he,s.MglButton=Z,s.MglCanvasSource=le,s.MglCircleLayer=ge,s.MglCustomControl=J,s.MglDefaults=u,s.MglFillExtrusionLayer=pe,s.MglFillLayer=ye,s.MglFrameRateControl=Q,s.MglFullscreenControl=X,s.MglGeoJsonSource=se,s.MglGeolocationControl=ee,s.MglHeatmapLayer=be,s.MglHillshadeLayer=Se,s.MglImageSource=ce,s.MglLineLayer=Re,s.MglMap=q,s.MglMarker=re,s.MglNavigationControl=te,s.MglRasterDemSource=ue,s.MglRasterLayer=Ce,s.MglRasterSource=de,s.MglScaleControl=ie,s.MglStyleSwitchControl=ne,s.MglSymbolLayer=we,s.MglVectorSource=me,s.MglVideoSource=fe,s.Position=j,s.componentIdSymbol=S,s.default=ke,s.emitterSymbol=F,s.isLoadedSymbol=C,s.mapSymbol=y,s.sourceIdSymbol=R,s.sourceLayerRegistry=E,s.useDisposableLayer=v,s.useMap=ve,s.usePositionWatcher=I,s.useSource=x,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
`,render(){if(!this.isAdded)return e.createCommentVNode("style-switch-control");const t={isOpen:this.intIsOpen,currentStyle:this.intModelValue,mapStyles:this.mapStyles,toggleOpen:this.toggleOpen,setStyle:this.setStyle};return e.h(e.Teleport,{to:this.container},this.$slots.default?this.$slots.default(t):[this.$slots.button?this.$slots.button(t):e.h(Z,{type:$.MDI,path:"M12,18.54L19.37,12.8L21,14.07L12,21.07L3,14.07L4.62,12.81L12,18.54M12,16L3,9L12,2L21,9L12,16M12,4.53L6.26,9L12,13.47L17.74,9L12,4.53Z",class:["maplibregl-ctrl-icon maplibregl-style-switch",this.intIsOpen?"is-open":""],onClick:this.toggleOpen.bind(null,!0)}),this.$slots.styleList?this.$slots.styleList(t):e.h("div",{class:["maplibregl-style-list",this.intIsOpen?"is-open":""]},this.mapStyles.map(i=>{var o,a;return i.icon?e.h(Z,{type:$.MDI,path:i.icon.path,class:((o=this.intModelValue)==null?void 0:o.name)===i.name?"is-active":"",onClick:()=>this.setStyle(i)},e.createTextVNode(i.label)):e.h("button",{type:"button",class:((a=this.intModelValue)==null?void 0:a.name)===i.name?"is-active":"",onClick:()=>this.setStyle(i)},e.createTextVNode(i.label))}))])}}),re=e.defineComponent({name:"MglMarker",props:{coordinates:{type:[Object,Array],required:!0},offset:[Object,Array],anchor:String,color:String,clickTolerance:Number,rotation:Number,rotationAlignment:String,pitchAlignment:String,scale:Number},setup(t){const i=e.inject(y),o=Object.keys(t).filter(r=>t[r]!==void 0&&L.MARKER_OPTION_KEYS.indexOf(r)!==-1).reduce((r,n)=>(r[n]=e.unref(t[n]),r),{}),a=new w.Marker(o);return a.setLngLat(t.coordinates).addTo(i.value),e.watch(()=>t.coordinates,r=>a.setLngLat(r)),e.watch(()=>t.offset,r=>a.setOffset(r||[0,0])),e.watch(()=>t.pitchAlignment,r=>a.setPitchAlignment(r||"auto")),e.watch(()=>t.rotationAlignment,r=>a.setRotationAlignment(r||"auto")),e.onBeforeUnmount(a.remove.bind(a)),{marker:a}},render(){}});class B{constructor(){p(this,"unmountHandlers",new Map)}registerUnmountHandler(i,o){this.unmountHandlers.set(i,o)}unregisterUnmountHandler(i){this.unmountHandlers.delete(i)}unmount(){this.unmountHandlers.forEach(i=>i())}}const W=class{static genSourceOpts(i,o,a){return Object.keys(o).filter(r=>o[r]!==void 0&&a.indexOf(r)!==-1).reduce((r,n)=>(r[n]=e.unref(o[n]),r),{type:i})}static getSourceRef(i,o){const a=typeof o=="string",r=String(i)+(a?o:"");let n=W.REFS.get(r);return n||(n=e.ref(a?null:void 0),W.REFS.set(r,n)),n}};let b=W;p(b,"REFS",new Map);function x(t,i,o,a,r){const n=e.inject(y),c=e.inject(C),h=e.inject(F);function f(){c.value&&(n.value.addSource(i.sourceId,b.genSourceOpts(o,i,a)),t.value=n.value.getSource(i.sourceId))}function T(){t.value=null}return e.watch(c,f,{immediate:!0}),n.value.on("style.load",f),h.on("styleSwitched",T),e.onBeforeUnmount(()=>{c.value&&(r.unmount(),n.value.removeSource(i.sourceId)),n.value.off("style.load",f),h.off("styleSwitched",T)})}const Ne=P({animate:void 0,canvas:void 0,coordinates:void 0}),le=e.defineComponent({name:"MglCanvasSource",props:{sourceId:{type:String,required:!0},coordinates:Array,animate:Boolean,canvas:[Object,String]},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"canvas",Ne,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return[e.createCommentVNode("Canvas Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),Pe=P({data:void 0,maxzoom:void 0,attribution:void 0,buffer:void 0,tolerance:void 0,cluster:void 0,clusterRadius:void 0,clusterMaxZoom:void 0,clusterMinPoints:void 0,clusterProperties:void 0,lineMetrics:void 0,generateId:void 0,promoteId:void 0,filter:void 0}),se=e.defineComponent({name:"MglGeoJsonSource",props:{sourceId:{type:String,required:!0},data:[Object,String],maxzoom:Number,attribution:String,buffer:Number,tolerance:Number,cluster:[Number,Boolean],clusterRadius:Number,clusterMaxZoom:Number,clusterMinPoints:Number,clusterProperties:Object,lineMetrics:Boolean,generateId:Boolean,promoteId:[Object,String],filter:[Array,String,Object]},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"geojson",Pe,a),e.watch(e.toRef(t,"data"),r=>{var n;return(n=o.value)==null?void 0:n.setData(r||{type:"FeatureCollection",features:[]})}),{source:o}},render(){return[e.createCommentVNode("GeoJSON Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),xe=P({url:void 0,coordinates:void 0}),ce=e.defineComponent({name:"MglImageSource",props:{sourceId:{type:String,required:!0},url:String,coordinates:Array},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"image",xe,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return[e.createCommentVNode("Image Source"),this.source&&this.$slots.default?this.$slots.default():void 0]}}),Be=P({url:void 0,tiles:void 0,bounds:void 0,minzoom:void 0,maxzoom:void 0,tileSize:void 0,scheme:void 0,attribution:void 0,volatile:void 0}),de=e.defineComponent({name:"MglRasterSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,minzoom:Number,maxzoom:Number,tileSize:Number,scheme:String,attribution:String,volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"raster",Be,a),{source:o}},render(){return e.createCommentVNode("Video Source")}}),_e=P({url:void 0,tiles:void 0,bounds:void 0,minzoom:void 0,maxzoom:void 0,tileSize:void 0,attribution:void 0,encoding:void 0,volatile:void 0}),ue=e.defineComponent({name:"MglRasterDemSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,minzoom:Number,maxzoom:Number,tileSize:Number,attribution:String,encoding:String,volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"raster-dem",_e,a),{source:o}},render(){return e.createCommentVNode("Video Source")}}),ze=P({url:void 0,tiles:void 0,bounds:void 0,scheme:void 0,minzoom:void 0,maxzoom:void 0,attribution:void 0,promoteId:void 0,volatile:void 0}),me=e.defineComponent({name:"MglVectorSource",props:{sourceId:{type:String,required:!0},url:String,tiles:Array,bounds:Array,scheme:String,minzoom:Number,maxzoom:Number,attribution:String,promoteId:[Object,String],volatile:Boolean},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"vector",ze,a),e.watch(e.toRef(t,"tiles"),r=>{var n;return(n=o.value)==null?void 0:n.setTiles(r||[])}),e.watch(e.toRef(t,"url"),r=>{var n;return(n=o.value)==null?void 0:n.setUrl(r||"")}),{source:o}},render(){return e.createCommentVNode("Vector Source")}}),He=P({urls:void 0,coordinates:void 0}),fe=e.defineComponent({name:"MglVideoSource",props:{sourceId:{type:String,required:!0},urls:Array,coordinates:Array},setup(t){const i=e.inject(S),o=b.getSourceRef(i,t.sourceId),a=new B;return e.provide(R,t.sourceId),e.provide(E,a),x(o,t,"video",He,a),e.watch(e.toRef(t,"coordinates"),r=>{var n;r&&((n=o.value)==null||n.setCoordinates(r))}),{source:o}},render(){return e.createCommentVNode("Video Source")}}),M=class{static genLayerOpts(i,o,a,r){return Object.keys(a).filter(n=>a[n]!==void 0&&M.SOURCE_OPTS.indexOf(n)!==-1).reduce((n,c)=>(n[c==="sourceLayer"?"source-layer":c]=e.unref(a[c]),n),{type:o,source:a.source||r,id:i})}static registerLayerEvents(i,o,a){if(a.props)for(let r=0,n=M.LAYER_EVENTS.length;r<n;r++){const c="on"+M.LAYER_EVENTS[r].charAt(0).toUpperCase()+M.LAYER_EVENTS[r].substr(1);a.props[c]&&i.on(M.LAYER_EVENTS[r],o,a.props[c])}}static unregisterLayerEvents(i,o,a){if(a.props)for(let r=0,n=M.LAYER_EVENTS.length;r<n;r++){const c="on"+M.LAYER_EVENTS[r].charAt(0).toUpperCase()+M.LAYER_EVENTS[r].substr(1);a.props[c]&&i.off(M.LAYER_EVENTS[r],o,a.props[c])}}};let m=M;p(m,"SOURCE_OPTS",["metadata","ref","source","sourceLayer","minzoom","maxzoom","interactive","filter","layout","paint"]),p(m,"LAYER_EVENTS",["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"]),p(m,"SHARED",{props:{layerId:{type:String,required:!0},source:[String,Object],metadata:[Object,Array,String,Number],ref:String,sourceLayer:String,minzoom:Number,maxzoom:Number,interactive:Boolean,filter:Array,before:String},emits:["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"]});function v(t,i){const o=e.inject(y),a=e.inject(C),r=e.inject(E);function n(){a.value&&(i&&m.unregisterLayerEvents(o.value,t,i.vnode),o.value.getLayer(t)&&o.value.removeLayer(t))}r.registerUnmountHandler(t,n),e.onBeforeUnmount(()=>{r.unregisterUnmountHandler(t),n()})}const he=e.defineComponent({name:"MglBackgroundLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Background Layer: layer must be used inside source tag or source prop must be set");return}const o=e.inject(y),a=e.inject(C),r=e.inject(S),n=b.getSourceRef(r,t.source||i);v(t.layerId),e.watch([a,n],([c,h])=>{c&&(h||h===void 0)&&o.value.addLayer(m.genLayerOpts(t.layerId,"background",t,i),t.before||void 0)},{immediate:!0})},render(){return e.createCommentVNode("Background Layer")}}),ge=e.defineComponent({name:"MglCircleLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Circle Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"circle",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Circle Layer")}}),ye=e.defineComponent({name:"MglFillLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Fill Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"fill",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Fill Layer")}}),pe=e.defineComponent({name:"MglFillExtrusionLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Fill Extrude Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"fill-extrusion",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Fill Extrusion Layer")}}),be=e.defineComponent({name:"MglHeatmapLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Heatmap Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"heatmap",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Heatmap Layer")}}),Se=e.defineComponent({name:"MglHillshadeLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Hillshade Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"hillshade",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Hillshade Layer")}}),Re=e.defineComponent({name:"MglLineLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Line Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"line",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Line Layer")}}),Ce=e.defineComponent({name:"MglRasterLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Raster Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"raster",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Raster Layer")}}),we=e.defineComponent({name:"MglSymbolLayer",props:{...m.SHARED.props,layout:Object,paint:Object},emits:[...m.SHARED.emits],setup(t){const i=e.inject(R);if(!i&&!t.source){e.warn("Symbol Layer: layer must be used inside source tag or source prop must be set");return}const o=e.getCurrentInstance(),a=e.inject(y),r=e.inject(C),n=e.inject(S),c=b.getSourceRef(n,t.source||i);v(t.layerId,o),e.watch([r,c],([h,f])=>{h&&(f||f===void 0)&&(a.value.addLayer(m.genLayerOpts(t.layerId,"symbol",t,i),t.before||void 0),m.registerLayerEvents(a.value,t.layerId,o.vnode))},{immediate:!0})},render(){return e.createCommentVNode("Symbol Layer")}}),Ve=Object.freeze(Object.defineProperty({__proto__:null,MglAttributionControl:K,MglBackgroundLayer:he,MglButton:Z,MglCanvasSource:le,MglCircleLayer:ge,MglCustomControl:J,MglFillExtrusionLayer:pe,MglFillLayer:ye,MglFrameRateControl:Q,MglFullscreenControl:X,MglGeoJsonSource:se,MglGeolocationControl:ee,MglHeatmapLayer:be,MglHillshadeLayer:Se,MglImageSource:ce,MglLineLayer:Re,MglMap:q,MglMarker:re,MglNavigationControl:te,MglRasterDemSource:ue,MglRasterLayer:Ce,MglRasterSource:de,MglScaleControl:ie,MglStyleSwitchControl:ne,MglSymbolLayer:we,MglVectorSource:me,MglVideoSource:fe},Symbol.toStringTag,{value:"Module"})),ke=function(i){Object.entries(Ve).forEach(([o,a])=>{i.component(o,a)})};s.AllOptions=Me,s.AllSourceOptions=P,s.MglAttributionControl=K,s.MglBackgroundLayer=he,s.MglButton=Z,s.MglCanvasSource=le,s.MglCircleLayer=ge,s.MglCustomControl=J,s.MglDefaults=u,s.MglFillExtrusionLayer=pe,s.MglFillLayer=ye,s.MglFrameRateControl=Q,s.MglFullscreenControl=X,s.MglGeoJsonSource=se,s.MglGeolocationControl=ee,s.MglHeatmapLayer=be,s.MglHillshadeLayer=Se,s.MglImageSource=ce,s.MglLineLayer=Re,s.MglMap=q,s.MglMarker=re,s.MglNavigationControl=te,s.MglRasterDemSource=ue,s.MglRasterLayer=Ce,s.MglRasterSource=de,s.MglScaleControl=ie,s.MglStyleSwitchControl=ne,s.MglSymbolLayer=we,s.MglVectorSource=me,s.MglVideoSource=fe,s.Position=j,s.componentIdSymbol=S,s.default=ke,s.emitterSymbol=F,s.isLoadedSymbol=C,s.mapSymbol=y,s.sourceIdSymbol=R,s.sourceLayerRegistry=E,s.useDisposableLayer=v,s.useMap=ve,s.usePositionWatcher=I,s.useSource=x,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
//# sourceMappingURL=vue-maplibre-gl.umd.js.map |
{ | ||
"name": "vue-maplibre-gl", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Vue 3 plugin for maplibre-gl", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,3 +0,18 @@ | ||
import { defineComponent, getCurrentInstance, h, markRaw, onBeforeUnmount, onMounted, PropType, provide, ref, shallowRef, toRef, unref, watch } from 'vue'; | ||
import { | ||
defineComponent, | ||
getCurrentInstance, | ||
h, | ||
markRaw, | ||
nextTick, | ||
onBeforeUnmount, | ||
onMounted, | ||
PropType, | ||
provide, | ||
ref, | ||
shallowRef, | ||
toRef, | ||
unref, | ||
watch | ||
} from 'vue'; | ||
import { | ||
FitBoundsOptions, | ||
@@ -231,3 +246,3 @@ GestureOptions, | ||
dispose(); | ||
initialize(); | ||
nextTick(initialize); | ||
} | ||
@@ -234,0 +249,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
421834
3660