vue3-google-map 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +819 -620
- package/dist/index.umd.js +7 -7
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".mapdiv[data-v-765a8e46]{width:100%;height:100%}.info-window-wrapper[data-v-7138f548]{display:none}.mapdiv .info-window-wrapper[data-v-7138f548]{display:inline-block}.custom-marker-wrapper[data-v-cab807c1]{display:none}.mapdiv .custom-marker-wrapper[data-v-cab807c1]{display:inline-block}")),document.head.appendChild(e)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
|
|
2
|
-
(function(C,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(C=typeof globalThis<"u"?globalThis:C||self,i(C.Vue3GoogleMap={},C.Vue))})(this,function(C,i){"use strict";var st=Object.defineProperty;var rt=(C,i,k)=>i in C?st(C,i,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[i]=k;var D=(C,i,k)=>(rt(C,typeof i!="symbol"?i+"":i,k),k);const k=Symbol("map"),M=Symbol("api"),U=Symbol("marker"),F=Symbol("markerCluster"),j=Symbol("CustomMarker"),G=Symbol("mapTilesLoaded"),O=["click","dblclick","drag","dragend","dragstart","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"];var ue=function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var o,n,r;if(Array.isArray(e)){if(o=e.length,o!=t.length)return!1;for(n=o;n--!==0;)if(!s(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(r=Object.keys(e),o=r.length,o!==Object.keys(t).length)return!1;for(n=o;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=o;n--!==0;){var l=r[n];if(!s(e[l],t[l]))return!1}return!0}return e!==e&&t!==t};const V="__googleMapsScriptId";class b{constructor({apiKey:e,channel:t,client:o,id:n=V,libraries:r=[],language:l,region:c,version:a,mapIds:p,nonce:d,retries:u=3,url:f="https://maps.googleapis.com/maps/api/js"}){if(this.CALLBACK="__googleMapsCallback",this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.version=a,this.apiKey=e,this.channel=t,this.client=o,this.id=n||V,this.libraries=r,this.language=l,this.region=c,this.mapIds=p,this.nonce=d,this.retries=u,this.url=f,b.instance){if(!ue(this.options,b.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(b.instance.options)}`);return b.instance}b.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url}}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+=`?callback=${this.CALLBACK}`,this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(o=>{o?t(o.error):e(window.google)})})}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){if(document.getElementById(this.id)){this.callback();return}const e=this.createUrl(),t=document.createElement("script");t.id=this.id,t.type="text/javascript",t.src=e,t.onerror=this.loadErrorCallback.bind(this),t.defer=!0,t.async=!0,this.nonce&&(t.nonce=this.nonce),document.head.appendChild(t)}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.log(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=e,this.callback()}setCallback(){window.__googleMapsCallback=this.callback.bind(this)}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setCallback(),this.setScript())}}}function de(s){return class extends s.OverlayView{constructor(o){super();D(this,"element");D(this,"opts");const{element:n,...r}=o;this.element=n,this.opts=r,this.opts.map&&this.setMap(this.opts.map)}getPosition(){return this.opts.position?this.opts.position instanceof s.LatLng?this.opts.position:new s.LatLng(this.opts.position):null}getVisible(){if(!this.element)return!1;const o=this.element;return o.style.display!=="none"&&o.style.visibility!=="hidden"&&(o.style.opacity===""||Number(o.style.opacity)>.01)}onAdd(){if(!this.element)return;const o=this.getPanes();o&&o.overlayMouseTarget.appendChild(this.element)}draw(){if(!this.element)return;const n=this.getProjection().fromLatLngToDivPixel(this.getPosition());if(n){this.element.style.position="absolute";const r=this.element.offsetHeight,l=this.element.offsetWidth;let c,a;switch(this.opts.anchorPoint){case"TOP_CENTER":c=n.x-l/2,a=n.y;break;case"BOTTOM_CENTER":c=n.x-l/2,a=n.y-r;break;case"LEFT_CENTER":c=n.x,a=n.y-r/2;break;case"RIGHT_CENTER":c=n.x-l,a=n.y-r/2;break;case"TOP_LEFT":c=n.x,a=n.y;break;case"TOP_RIGHT":c=n.x-l,a=n.y;break;case"BOTTOM_LEFT":c=n.x,a=n.y-r;break;case"BOTTOM_RIGHT":c=n.x-l,a=n.y-r;break;default:c=n.x-l/2,a=n.y-r/2}this.element.style.left=c+"px",this.element.style.top=a+"px",this.element.style.transform=`translateX(${this.opts.offsetX||0}px) translateY(${this.opts.offsetY||0}px)`,this.opts.zIndex&&(this.element.style.zIndex=this.opts.zIndex.toString())}}onRemove(){this.element&&this.element.remove()}setOptions(o){this.opts=o,this.draw()}}}let H;const K=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","heading_changed","idle","maptypeid_changed","mousemove","mouseout","mouseover","projection_changed","resize","rightclick","tilesloaded","tilt_changed","zoom_changed"],pe=i.defineComponent({props:{apiPromise:{type:Promise},apiKey:{type:String,default:""},version:{type:String,default:"weekly"},libraries:{type:Array,default:()=>["places"]},region:{type:String,required:!1},language:{type:String,required:!1},backgroundColor:{type:String,required:!1},center:{type:Object,default:()=>({lat:0,lng:0})},clickableIcons:{type:Boolean,required:!1,default:void 0},controlSize:{type:Number,required:!1},disableDefaultUi:{type:Boolean,required:!1,default:void 0},disableDoubleClickZoom:{type:Boolean,required:!1,default:void 0},draggable:{type:Boolean,required:!1,default:void 0},draggableCursor:{type:String,required:!1},draggingCursor:{type:String,required:!1},fullscreenControl:{type:Boolean,required:!1,default:void 0},fullscreenControlPosition:{type:String,required:!1},gestureHandling:{type:String,required:!1},heading:{type:Number,required:!1},keyboardShortcuts:{type:Boolean,required:!1,default:void 0},mapTypeControl:{type:Boolean,required:!1,default:void 0},mapTypeControlOptions:{type:Object,required:!1},mapTypeId:{type:[Number,String],required:!1},mapId:{type:String,required:!1},maxZoom:{type:Number,required:!1},minZoom:{type:Number,required:!1},noClear:{type:Boolean,required:!1,default:void 0},panControl:{type:Boolean,required:!1,default:void 0},panControlPosition:{type:String,required:!1},restriction:{type:Object,required:!1},rotateControl:{type:Boolean,required:!1,default:void 0},rotateControlPosition:{type:String,required:!1},scaleControl:{type:Boolean,required:!1,default:void 0},scaleControlStyle:{type:Number,required:!1},scrollwheel:{type:Boolean,required:!1,default:void 0},streetView:{type:Object,required:!1},streetViewControl:{type:Boolean,required:!1,default:void 0},streetViewControlPosition:{type:String,required:!1},styles:{type:Array,required:!1},tilt:{type:Number,required:!1},zoom:{type:Number,required:!1},zoomControl:{type:Boolean,required:!1,default:void 0},zoomControlPosition:{type:String,required:!1}},emits:K,setup(s,{emit:e}){const t=i.ref(),o=i.ref(!1),n=i.ref(),r=i.ref(),l=i.ref(!1);i.provide(k,n),i.provide(M,r),i.provide(G,l);const c=()=>{const u={...s};Object.keys(u).forEach(g=>{u[g]===void 0&&delete u[g]});const m=g=>{var y;return g?{position:(y=r.value)==null?void 0:y.ControlPosition[g]}:{}},h={scaleControlOptions:s.scaleControlStyle?{style:s.scaleControlStyle}:{},panControlOptions:m(s.panControlPosition),zoomControlOptions:m(s.zoomControlPosition),rotateControlOptions:m(s.rotateControlPosition),streetViewControlOptions:m(s.streetViewControlPosition),fullscreenControlOptions:m(s.fullscreenControlPosition),disableDefaultUI:s.disableDefaultUi};return{...u,...h}},a=i.watch([r,n],([u,f])=>{const m=u,h=f;m&&h&&(m.event.addListenerOnce(h,"tilesloaded",()=>{l.value=!0}),setTimeout(a,0))},{immediate:!0}),p=()=>{try{const{apiKey:u,region:f,version:m,language:h,libraries:g}=s;H=new b({apiKey:u,region:f,version:m,language:h,libraries:g})}catch(u){console.error(u)}},d=u=>{r.value=i.markRaw(u.maps),n.value=i.markRaw(new u.maps.Map(t.value,c()));const f=de(r.value);r.value[j]=f,K.forEach(h=>{var g;(g=n.value)==null||g.addListener(h,y=>e(h,y))}),o.value=!0;const m=Object.keys(s).filter(h=>!["apiPromise","apiKey","version","libraries","region","language","center","zoom"].includes(h)).map(h=>i.toRef(s,h));i.watch([()=>s.center,()=>s.zoom,...m],([h,g],[y,v])=>{var ae,le,ce;const{center:w,zoom:I,..._}=c();(ae=n.value)==null||ae.setOptions(_),g!==void 0&&g!==v&&((le=n.value)==null||le.setZoom(g));const B=!y||h.lng!==y.lng||h.lat!==y.lat;h&&B&&((ce=n.value)==null||ce.panTo(h))})};return i.onMounted(()=>{s.apiPromise&&s.apiPromise instanceof Promise?s.apiPromise.then(d):(p(),H.load().then(d))}),i.onBeforeUnmount(()=>{var u;l.value=!1,n.value&&((u=r.value)==null||u.event.clearInstanceListeners(n.value))}),{mapRef:t,ready:o,map:n,api:r,mapTilesLoaded:l}}}),it="",$=(s,e)=>{const t=s.__vccOpts||s;for(const[o,n]of e)t[o]=n;return t},he={ref:"mapRef",class:"mapdiv"};function fe(s,e,t,o,n,r){return i.openBlock(),i.createElementBlock("div",null,[i.createElementVNode("div",he,null,512),i.renderSlot(s.$slots,"default",i.normalizeProps(i.guardReactiveProps({ready:s.ready,map:s.map,api:s.api,mapTilesLoaded:s.mapTilesLoaded})),void 0,!0)])}const me=$(pe,[["render",fe],["__scopeId","data-v-765a8e46"]]);function ge(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ye=function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var o,n,r;if(Array.isArray(e)){if(o=e.length,o!=t.length)return!1;for(n=o;n--!==0;)if(!s(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(r=Object.keys(e),o=r.length,o!==Object.keys(t).length)return!1;for(n=o;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=o;n--!==0;){var l=r[n];if(!s(e[l],t[l]))return!1}return!0}return e!==e&&t!==t};const x=ge(ye),Ce=s=>s==="Marker",ke=s=>s===j,P=(s,e,t,o)=>{const n=i.ref(),r=i.inject(k,i.ref()),l=i.inject(M,i.ref()),c=i.inject(F,i.ref()),a=i.computed(()=>!!(c.value&&l.value&&(n.value instanceof l.value.Marker||n.value instanceof l.value[j])));return i.watch([r,t],(p,[d,u])=>{var m,h,g;const f=!x(t.value,u)||r.value!==d;!r.value||!l.value||!f||(n.value?(n.value.setOptions(t.value),a.value&&((m=c.value)==null||m.removeMarker(n.value),(h=c.value)==null||h.addMarker(n.value))):(Ce(s)?n.value=i.markRaw(new l.value[s](t.value)):ke(s)?n.value=i.markRaw(new l.value[s](t.value)):n.value=i.markRaw(new l.value[s]({...t.value,map:r.value})),a.value?(g=c.value)==null||g.addMarker(n.value):n.value.setMap(r.value),e.forEach(y=>{var v;(v=n.value)==null||v.addListener(y,w=>o(y,w))})))},{immediate:!0}),i.onBeforeUnmount(()=>{var p,d;n.value&&((p=l.value)==null||p.event.clearInstanceListeners(n.value),a.value?(d=c.value)==null||d.removeMarker(n.value):n.value.setMap(null))}),n},W=["animation_changed","click","dblclick","rightclick","dragstart","dragend","drag","mouseover","mousedown","mouseout","mouseup","draggable_changed","clickable_changed","contextmenu","cursor_changed","flat_changed","rightclick","zindex_changed","icon_changed","position_changed","shape_changed","title_changed","visible_changed"],ve=i.defineComponent({name:"Marker",props:{options:{type:Object,required:!0}},emits:W,setup(s,{emit:e,expose:t,slots:o}){const n=i.toRef(s,"options"),r=P("Marker",W,n,e);return i.provide(U,r),t({marker:r}),()=>{var l;return(l=o.default)==null?void 0:l.call(o)}}}),_e=i.defineComponent({name:"Polyline",props:{options:{type:Object,required:!0}},emits:O,setup(s,{emit:e}){const t=i.toRef(s,"options");return{polyline:P("Polyline",O,t,e)}},render:()=>null}),we=i.defineComponent({name:"Polygon",props:{options:{type:Object,required:!0}},emits:O,setup(s,{emit:e}){const t=i.toRef(s,"options");return{polygon:P("Polygon",O,t,e)}},render:()=>null}),J=O.concat(["bounds_changed"]),be=i.defineComponent({name:"Rectangle",props:{options:{type:Object,required:!0}},emits:J,setup(s,{emit:e}){const t=i.toRef(s,"options");return{rectangle:P("Rectangle",J,t,e)}},render:()=>null}),X=O.concat(["center_changed","radius_changed"]),Me=i.defineComponent({name:"Circle",props:{options:{type:Object,required:!0}},emits:X,setup(s,{emit:e}){const t=i.toRef(s,"options");return{circle:P("Circle",X,t,e)}},render:()=>null}),Oe=i.defineComponent({props:{position:{type:String,required:!0},index:{type:Number,default:1}},emits:["content:loaded"],setup(s,{emit:e}){const t=i.ref(null),o=i.inject(k,i.ref()),n=i.inject(M,i.ref()),r=i.inject(G,i.ref(!1)),l=i.ref(!1),c=i.watch([r,n,t],([d,u,f])=>{u&&d&&f&&(a(s.position),l.value=!0,e("content:loaded"),setTimeout(c,0))},{immediate:!0}),a=d=>{if(o.value&&n.value&&t.value){const u=n.value.ControlPosition[d];o.value.controls[u].push(t.value)}},p=d=>{if(o.value&&n.value){let u=null;const f=n.value.ControlPosition[d];o.value.controls[f].forEach((m,h)=>{m===t.value&&(u=h)}),u!==null&&o.value.controls[f].removeAt(u)}};return i.onBeforeUnmount(()=>p(s.position)),i.watch(()=>s.position,(d,u)=>{p(u),a(d)}),i.watch(()=>s.index,d=>{d&&t.value&&(t.value.index=s.index)}),{controlRef:t,showContent:l}}}),Pe={ref:"controlRef"};function Se(s,e,t,o,n,r){return i.withDirectives((i.openBlock(),i.createElementBlock("div",Pe,[i.renderSlot(s.$slots,"default")],512)),[[i.vShow,s.showContent]])}const xe=$(Oe,[["render",Se]]),Y=["closeclick","content_changed","domready","position_changed","visible","zindex_changed"],Le=i.defineComponent({inheritAttrs:!1,props:{options:{type:Object,default:()=>({})}},emits:Y,setup(s,{slots:e,emit:t,expose:o}){const n=i.ref(),r=i.ref(),l=i.inject(k,i.ref()),c=i.inject(M,i.ref()),a=i.inject(U,i.ref());let p;const d=i.computed(()=>{var m;return(m=e.default)==null?void 0:m.call(e).some(h=>h.type!==i.Comment)}),u=m=>{var h;return(h=n.value)==null?void 0:h.open({map:l.value,anchor:a.value,...m})},f=()=>{var m;return(m=n.value)==null?void 0:m.close()};return i.onMounted(()=>{i.watch([l,()=>s.options],([m,h],[g,y])=>{const v=!x(h,y)||l.value!==g;l.value&&c.value&&v&&(n.value?(n.value.setOptions({...h,content:d.value?r.value:h.content}),a.value||u()):(n.value=i.markRaw(new c.value.InfoWindow({...h,content:d.value?r.value:h.content})),a.value?p=a.value.addListener("click",()=>{u()}):u(),Y.forEach(w=>{var I;(I=n.value)==null||I.addListener(w,_=>t(w,_))})))},{immediate:!0})}),i.onBeforeUnmount(()=>{var m;p&&p.remove(),n.value&&((m=c.value)==null||m.event.clearInstanceListeners(n.value),f())}),o({infoWindow:n,open:u,close:f}),{infoWindow:n,infoWindowRef:r,hasSlotContent:d,open:u,close:f}}}),at="",Ee={key:0,class:"info-window-wrapper"};function Ie(s,e,t,o,n,r){return s.hasSlotContent?(i.openBlock(),i.createElementBlock("div",Ee,[i.createElementVNode("div",i.mergeProps({ref:"infoWindowRef"},s.$attrs),[i.renderSlot(s.$slots,"default",{},void 0,!0)],16)])):i.createCommentVNode("",!0)}const je=$(Le,[["render",Ie],["__scopeId","data-v-7138f548"]]);function A(s,e,t,o,n,r){if(n-o<=t)return;const l=o+n>>1;Q(s,e,l,o,n,r%2),A(s,e,t,o,l-1,r+1),A(s,e,t,l+1,n,r+1)}function Q(s,e,t,o,n,r){for(;n>o;){if(n-o>600){const p=n-o+1,d=t-o+1,u=Math.log(p),f=.5*Math.exp(2*u/3),m=.5*Math.sqrt(u*f*(p-f)/p)*(d-p/2<0?-1:1),h=Math.max(o,Math.floor(t-d*f/p+m)),g=Math.min(n,Math.floor(t+(p-d)*f/p+m));Q(s,e,t,h,g,r)}const l=e[2*t+r];let c=o,a=n;for(L(s,e,o,t),e[2*n+r]>l&&L(s,e,o,n);c<a;){for(L(s,e,c,a),c++,a--;e[2*c+r]<l;)c++;for(;e[2*a+r]>l;)a--}e[2*o+r]===l?L(s,e,o,a):(a++,L(s,e,a,n)),a<=t&&(o=a+1),t<=a&&(n=a-1)}}function L(s,e,t,o){N(s,t,o),N(e,2*t,2*o),N(e,2*t+1,2*o+1)}function N(s,e,t){const o=s[e];s[e]=s[t],s[t]=o}function $e(s,e,t,o,n,r,l){const c=[0,s.length-1,0],a=[];let p,d;for(;c.length;){const u=c.pop(),f=c.pop(),m=c.pop();if(f-m<=l){for(let y=m;y<=f;y++)p=e[2*y],d=e[2*y+1],p>=t&&p<=n&&d>=o&&d<=r&&a.push(s[y]);continue}const h=Math.floor((m+f)/2);p=e[2*h],d=e[2*h+1],p>=t&&p<=n&&d>=o&&d<=r&&a.push(s[h]);const g=(u+1)%2;(u===0?t<=p:o<=d)&&(c.push(m),c.push(h-1),c.push(g)),(u===0?n>=p:r>=d)&&(c.push(h+1),c.push(f),c.push(g))}return a}function Re(s,e,t,o,n,r){const l=[0,s.length-1,0],c=[],a=n*n;for(;l.length;){const p=l.pop(),d=l.pop(),u=l.pop();if(d-u<=r){for(let y=u;y<=d;y++)ee(e[2*y],e[2*y+1],t,o)<=a&&c.push(s[y]);continue}const f=Math.floor((u+d)/2),m=e[2*f],h=e[2*f+1];ee(m,h,t,o)<=a&&c.push(s[f]);const g=(p+1)%2;(p===0?t-n<=m:o-n<=h)&&(l.push(u),l.push(f-1),l.push(g)),(p===0?t+n>=m:o+n>=h)&&(l.push(f+1),l.push(d),l.push(g))}return c}function ee(s,e,t,o){const n=s-t,r=e-o;return n*n+r*r}const Te=s=>s[0],qe=s=>s[1];class te{constructor(e,t=Te,o=qe,n=64,r=Float64Array){this.nodeSize=n,this.points=e;const l=e.length<65536?Uint16Array:Uint32Array,c=this.ids=new l(e.length),a=this.coords=new r(e.length*2);for(let p=0;p<e.length;p++)c[p]=p,a[2*p]=t(e[p]),a[2*p+1]=o(e[p]);A(c,a,n,0,c.length-1,0)}range(e,t,o,n){return $e(this.ids,this.coords,e,t,o,n,this.nodeSize)}within(e,t,o){return Re(this.ids,this.coords,e,t,o,this.nodeSize)}}const Be={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:s=>s},R=Math.fround||(s=>e=>(s[0]=+e,s[0]))(new Float32Array(1));class Ae{constructor(e){this.options=E(Object.create(Be),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:o,maxZoom:n,nodeSize:r}=this.options;t&&console.time("total time");const l=`prepare ${e.length} points`;t&&console.time(l),this.points=e;let c=[];for(let a=0;a<e.length;a++)e[a].geometry&&c.push(Ze(e[a],a));this.trees[n+1]=new te(c,se,re,r,Float32Array),t&&console.timeEnd(l);for(let a=n;a>=o;a--){const p=+Date.now();c=this._cluster(c,a),this.trees[a]=new te(c,se,re,r,Float32Array),t&&console.log("z%d: %d clusters in %dms",a,c.length,+Date.now()-p)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=e[2]===180?180:((e[2]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const d=this.getClusters([o,n,180,l],t),u=this.getClusters([-180,n,r,l],t);return d.concat(u)}const c=this.trees[this._limitZoom(t)],a=c.range(T(o),q(l),T(r),q(n)),p=[];for(const d of a){const u=c.points[d];p.push(u.numPoints?ne(u):this.points[u.index])}return p}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(n);const l=r.points[t];if(!l)throw new Error(n);const c=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(l.x,l.y,c),p=[];for(const d of a){const u=r.points[d];u.parentId===e&&p.push(u.numPoints?ne(u):this.points[u.index])}if(p.length===0)throw new Error(n);return p}getLeaves(e,t,o){t=t||10,o=o||0;const n=[];return this._appendLeaves(n,e,t,o,0),n}getTile(e,t,o){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:l,radius:c}=this.options,a=c/l,p=(o-a)/r,d=(o+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,p,(t+1+a)/r,d),n.points,t,o,r,u),t===0&&this._addTileFeatures(n.range(1-a/r,p,1,d),n.points,r,o,r,u),t===r-1&&this._addTileFeatures(n.range(0,p,a/r,d),n.points,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,o.length!==1)break;e=o[0].properties.cluster_id}return t}_appendLeaves(e,t,o,n,r){const l=this.getChildren(t);for(const c of l){const a=c.properties;if(a&&a.cluster?r+a.point_count<=n?r+=a.point_count:r=this._appendLeaves(e,a.cluster_id,o,n,r):r<n?r++:e.push(c),e.length===o)break}return r}_addTileFeatures(e,t,o,n,r,l){for(const c of e){const a=t[c],p=a.numPoints;let d,u,f;if(p)d=oe(a),u=a.x,f=a.y;else{const g=this.points[a.index];d=g.properties,u=T(g.geometry.coordinates[0]),f=q(g.geometry.coordinates[1])}const m={type:1,geometry:[[Math.round(this.options.extent*(u*r-o)),Math.round(this.options.extent*(f*r-n))]],tags:d};let h;p?h=a.id:this.options.generateId?h=a.index:this.points[a.index].id&&(h=this.points[a.index].id),h!==void 0&&(m.id=h),l.features.push(m)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const o=[],{radius:n,extent:r,reduce:l,minPoints:c}=this.options,a=n/(r*Math.pow(2,t));for(let p=0;p<e.length;p++){const d=e[p];if(d.zoom<=t)continue;d.zoom=t;const u=this.trees[t+1],f=u.within(d.x,d.y,a),m=d.numPoints||1;let h=m;for(const g of f){const y=u.points[g];y.zoom>t&&(h+=y.numPoints||1)}if(h>m&&h>=c){let g=d.x*m,y=d.y*m,v=l&&m>1?this._map(d,!0):null;const w=(p<<5)+(t+1)+this.points.length;for(const I of f){const _=u.points[I];if(_.zoom<=t)continue;_.zoom=t;const B=_.numPoints||1;g+=_.x*B,y+=_.y*B,_.parentId=w,l&&(v||(v=this._map(d,!0)),l(v,this._map(_)))}d.parentId=w,o.push(Ne(g/h,y/h,w,h,v))}else if(o.push(d),h>1)for(const g of f){const y=u.points[g];y.zoom<=t||(y.zoom=t,o.push(y))}}return o}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?E({},e.properties):e.properties;const o=this.points[e.index].properties,n=this.options.map(o);return t&&n===o?E({},n):n}}function Ne(s,e,t,o,n){return{x:R(s),y:R(e),zoom:1/0,id:t,parentId:-1,numPoints:o,properties:n}}function Ze(s,e){const[t,o]=s.geometry.coordinates;return{x:R(T(t)),y:R(q(o)),zoom:1/0,index:e,parentId:-1}}function ne(s){return{type:"Feature",id:s.id,properties:oe(s),geometry:{type:"Point",coordinates:[ze(s.x),De(s.y)]}}}function oe(s){const e=s.numPoints,t=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${Math.round(e/100)/10}k`:e;return E(E({},s.properties),{cluster:!0,cluster_id:s.id,point_count:e,point_count_abbreviated:t})}function T(s){return s/360+.5}function q(s){const e=Math.sin(s*Math.PI/180),t=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return t<0?0:t>1?1:t}function ze(s){return(s-.5)*360}function De(s){const e=(180-s*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function E(s,e){for(const t in e)s[t]=e[t];return s}function se(s){return s.x}function re(s){return s.y}/*! *****************************************************************************
|
|
2
|
+
(function(w,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(w=typeof globalThis<"u"?globalThis:w||self,a(w.Vue3GoogleMap={},w.Vue))})(this,function(w,a){"use strict";var ht=Object.defineProperty;var pt=(w,a,_)=>a in w?ht(w,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):w[a]=_;var X=(w,a,_)=>(pt(w,typeof a!="symbol"?a+"":a,_),_);const _=Symbol("map"),L=Symbol("api"),Q=Symbol("marker"),ee=Symbol("markerCluster"),Z=Symbol("CustomMarker"),te=Symbol("mapTilesLoaded"),T=["click","dblclick","drag","dragend","dragstart","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"];var Ce=function r(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,n,o;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(n=s;n--!==0;)if(!r(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(o=Object.keys(e),s=o.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=s;n--!==0;){var l=o[n];if(!r(e[l],t[l]))return!1}return!0}return e!==e&&t!==t};const se="__googleMapsScriptId";class E{constructor({apiKey:e,channel:t,client:s,id:n=se,libraries:o=[],language:l,region:u,version:i,mapIds:h,nonce:d,retries:c=3,url:p="https://maps.googleapis.com/maps/api/js"}){if(this.CALLBACK="__googleMapsCallback",this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.version=i,this.apiKey=e,this.channel=t,this.client=s,this.id=n||se,this.libraries=o,this.language=l,this.region=u,this.mapIds=h,this.nonce=d,this.retries=c,this.url=p,E.instance){if(!Ce(this.options,E.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(E.instance.options)}`);return E.instance}E.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url}}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+=`?callback=${this.CALLBACK}`,this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(s=>{s?t(s.error):e(window.google)})})}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){if(document.getElementById(this.id)){this.callback();return}const e=this.createUrl(),t=document.createElement("script");t.id=this.id,t.type="text/javascript",t.src=e,t.onerror=this.loadErrorCallback.bind(this),t.defer=!0,t.async=!0,this.nonce&&(t.nonce=this.nonce),document.head.appendChild(t)}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.log(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=e,this.callback()}setCallback(){window.__googleMapsCallback=this.callback.bind(this)}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setCallback(),this.setScript())}}}function _e(r){return class extends r.OverlayView{constructor(s){super();X(this,"element");X(this,"opts");const{element:n,...o}=s;this.element=n,this.opts=o,this.opts.map&&this.setMap(this.opts.map)}getPosition(){return this.opts.position?this.opts.position instanceof r.LatLng?this.opts.position:new r.LatLng(this.opts.position):null}getVisible(){if(!this.element)return!1;const s=this.element;return s.style.display!=="none"&&s.style.visibility!=="hidden"&&(s.style.opacity===""||Number(s.style.opacity)>.01)}onAdd(){if(!this.element)return;const s=this.getPanes();s&&s.overlayMouseTarget.appendChild(this.element)}draw(){if(!this.element)return;const n=this.getProjection().fromLatLngToDivPixel(this.getPosition());if(n){this.element.style.position="absolute";const o=this.element.offsetHeight,l=this.element.offsetWidth;let u,i;switch(this.opts.anchorPoint){case"TOP_CENTER":u=n.x-l/2,i=n.y;break;case"BOTTOM_CENTER":u=n.x-l/2,i=n.y-o;break;case"LEFT_CENTER":u=n.x,i=n.y-o/2;break;case"RIGHT_CENTER":u=n.x-l,i=n.y-o/2;break;case"TOP_LEFT":u=n.x,i=n.y;break;case"TOP_RIGHT":u=n.x-l,i=n.y;break;case"BOTTOM_LEFT":u=n.x,i=n.y-o;break;case"BOTTOM_RIGHT":u=n.x-l,i=n.y-o;break;default:u=n.x-l/2,i=n.y-o/2}this.element.style.left=u+"px",this.element.style.top=i+"px",this.element.style.transform=`translateX(${this.opts.offsetX||0}px) translateY(${this.opts.offsetY||0}px)`,this.opts.zIndex&&(this.element.style.zIndex=this.opts.zIndex.toString())}}onRemove(){this.element&&this.element.remove()}setOptions(s){this.opts=s,this.draw()}}}let ne;const re=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","heading_changed","idle","maptypeid_changed","mousemove","mouseout","mouseover","projection_changed","resize","rightclick","tilesloaded","tilt_changed","zoom_changed"],Me=a.defineComponent({props:{apiPromise:{type:Promise},apiKey:{type:String,default:""},version:{type:String,default:"weekly"},libraries:{type:Array,default:()=>["places"]},region:{type:String,required:!1},language:{type:String,required:!1},backgroundColor:{type:String,required:!1},center:{type:Object,default:()=>({lat:0,lng:0})},clickableIcons:{type:Boolean,required:!1,default:void 0},controlSize:{type:Number,required:!1},disableDefaultUi:{type:Boolean,required:!1,default:void 0},disableDoubleClickZoom:{type:Boolean,required:!1,default:void 0},draggable:{type:Boolean,required:!1,default:void 0},draggableCursor:{type:String,required:!1},draggingCursor:{type:String,required:!1},fullscreenControl:{type:Boolean,required:!1,default:void 0},fullscreenControlPosition:{type:String,required:!1},gestureHandling:{type:String,required:!1},heading:{type:Number,required:!1},keyboardShortcuts:{type:Boolean,required:!1,default:void 0},mapTypeControl:{type:Boolean,required:!1,default:void 0},mapTypeControlOptions:{type:Object,required:!1},mapTypeId:{type:[Number,String],required:!1},mapId:{type:String,required:!1},maxZoom:{type:Number,required:!1},minZoom:{type:Number,required:!1},noClear:{type:Boolean,required:!1,default:void 0},panControl:{type:Boolean,required:!1,default:void 0},panControlPosition:{type:String,required:!1},restriction:{type:Object,required:!1},rotateControl:{type:Boolean,required:!1,default:void 0},rotateControlPosition:{type:String,required:!1},scaleControl:{type:Boolean,required:!1,default:void 0},scaleControlStyle:{type:Number,required:!1},scrollwheel:{type:Boolean,required:!1,default:void 0},streetView:{type:Object,required:!1},streetViewControl:{type:Boolean,required:!1,default:void 0},streetViewControlPosition:{type:String,required:!1},styles:{type:Array,required:!1},tilt:{type:Number,required:!1},zoom:{type:Number,required:!1},zoomControl:{type:Boolean,required:!1,default:void 0},zoomControlPosition:{type:String,required:!1}},emits:re,setup(r,{emit:e}){const t=a.ref(),s=a.ref(!1),n=a.ref(),o=a.ref(),l=a.ref(!1);a.provide(_,n),a.provide(L,o),a.provide(te,l);const u=()=>{const c={...r};Object.keys(c).forEach(g=>{c[g]===void 0&&delete c[g]});const f=g=>{var y;return g?{position:(y=o.value)==null?void 0:y.ControlPosition[g]}:{}},m={scaleControlOptions:r.scaleControlStyle?{style:r.scaleControlStyle}:{},panControlOptions:f(r.panControlPosition),zoomControlOptions:f(r.zoomControlPosition),rotateControlOptions:f(r.rotateControlPosition),streetViewControlOptions:f(r.streetViewControlPosition),fullscreenControlOptions:f(r.fullscreenControlPosition),disableDefaultUI:r.disableDefaultUi};return{...c,...m}},i=a.watch([o,n],([c,p])=>{const f=c,m=p;f&&m&&(f.event.addListenerOnce(m,"tilesloaded",()=>{l.value=!0}),setTimeout(i,0))},{immediate:!0}),h=()=>{try{const{apiKey:c,region:p,version:f,language:m,libraries:g}=r;ne=new E({apiKey:c,region:p,version:f,language:m,libraries:g})}catch(c){console.error(c)}},d=c=>{o.value=a.markRaw(c.maps),n.value=a.markRaw(new c.maps.Map(t.value,u()));const p=_e(o.value);o.value[Z]=p,re.forEach(m=>{var g;(g=n.value)==null||g.addListener(m,y=>e(m,y))}),s.value=!0;const f=Object.keys(r).filter(m=>!["apiPromise","apiKey","version","libraries","region","language","center","zoom"].includes(m)).map(m=>a.toRef(r,m));a.watch([()=>r.center,()=>r.zoom,...f],([m,g],[y,v])=>{var z,b,N;const{center:k,zoom:M,...j}=u();(z=n.value)==null||z.setOptions(j),g!==void 0&&g!==v&&((b=n.value)==null||b.setZoom(g));const q=!y||m.lng!==y.lng||m.lat!==y.lat;m&&q&&((N=n.value)==null||N.panTo(m))})};return a.onMounted(()=>{r.apiPromise&&r.apiPromise instanceof Promise?r.apiPromise.then(d):(h(),ne.load().then(d))}),a.onBeforeUnmount(()=>{var c;l.value=!1,n.value&&((c=o.value)==null||c.event.clearInstanceListeners(n.value))}),{mapRef:t,ready:s,map:n,api:o,mapTilesLoaded:l}}}),ft="",U=(r,e)=>{const t=r.__vccOpts||r;for(const[s,n]of e)t[s]=n;return t},be={ref:"mapRef",class:"mapdiv"};function Pe(r,e,t,s,n,o){return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",be,null,512),a.renderSlot(r.$slots,"default",a.normalizeProps(a.guardReactiveProps({ready:r.ready,map:r.map,api:r.api,mapTilesLoaded:r.mapTilesLoaded})),void 0,!0)])}const Oe=U(Me,[["render",Pe],["__scopeId","data-v-765a8e46"]]);function Ee(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Se=function r(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,n,o;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(n=s;n--!==0;)if(!r(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(o=Object.keys(e),s=o.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=s;n--!==0;){var l=o[n];if(!r(e[l],t[l]))return!1}return!0}return e!==e&&t!==t};const S=Ee(Se),xe=r=>r==="Marker",Le=r=>r===Z,A=(r,e,t,s)=>{const n=a.ref(),o=a.inject(_,a.ref()),l=a.inject(L,a.ref()),u=a.inject(ee,a.ref()),i=a.computed(()=>!!(u.value&&l.value&&(n.value instanceof l.value.Marker||n.value instanceof l.value[Z])));return a.watch([o,t],(h,[d,c])=>{var f,m,g;const p=!S(t.value,c)||o.value!==d;!o.value||!l.value||!p||(n.value?(n.value.setOptions(t.value),i.value&&((f=u.value)==null||f.removeMarker(n.value),(m=u.value)==null||m.addMarker(n.value))):(xe(r)?n.value=a.markRaw(new l.value[r](t.value)):Le(r)?n.value=a.markRaw(new l.value[r](t.value)):n.value=a.markRaw(new l.value[r]({...t.value,map:o.value})),i.value?(g=u.value)==null||g.addMarker(n.value):n.value.setMap(o.value),e.forEach(y=>{var v;(v=n.value)==null||v.addListener(y,k=>s(y,k))})))},{immediate:!0}),a.onBeforeUnmount(()=>{var h,d;n.value&&((h=l.value)==null||h.event.clearInstanceListeners(n.value),i.value?(d=u.value)==null||d.removeMarker(n.value):n.value.setMap(null))}),n},oe=["animation_changed","click","dblclick","rightclick","dragstart","dragend","drag","mouseover","mousedown","mouseout","mouseup","draggable_changed","clickable_changed","contextmenu","cursor_changed","flat_changed","rightclick","zindex_changed","icon_changed","position_changed","shape_changed","title_changed","visible_changed"],Te=a.defineComponent({name:"Marker",props:{options:{type:Object,required:!0}},emits:oe,setup(r,{emit:e,expose:t,slots:s}){const n=a.toRef(r,"options"),o=A("Marker",oe,n,e);return a.provide(Q,o),t({marker:o}),()=>{var l;return(l=s.default)==null?void 0:l.call(s)}}}),Ae=a.defineComponent({name:"Polyline",props:{options:{type:Object,required:!0}},emits:T,setup(r,{emit:e}){const t=a.toRef(r,"options");return{polyline:A("Polyline",T,t,e)}},render:()=>null}),Ie=a.defineComponent({name:"Polygon",props:{options:{type:Object,required:!0}},emits:T,setup(r,{emit:e}){const t=a.toRef(r,"options");return{polygon:A("Polygon",T,t,e)}},render:()=>null}),ie=T.concat(["bounds_changed"]),je=a.defineComponent({name:"Rectangle",props:{options:{type:Object,required:!0}},emits:ie,setup(r,{emit:e}){const t=a.toRef(r,"options");return{rectangle:A("Rectangle",ie,t,e)}},render:()=>null}),ae=T.concat(["center_changed","radius_changed"]),Be=a.defineComponent({name:"Circle",props:{options:{type:Object,required:!0}},emits:ae,setup(r,{emit:e}){const t=a.toRef(r,"options");return{circle:A("Circle",ae,t,e)}},render:()=>null}),Re=a.defineComponent({props:{position:{type:String,required:!0},index:{type:Number,default:1}},emits:["content:loaded"],setup(r,{emit:e}){const t=a.ref(null),s=a.inject(_,a.ref()),n=a.inject(L,a.ref()),o=a.inject(te,a.ref(!1)),l=a.ref(!1),u=a.watch([o,n,t],([d,c,p])=>{c&&d&&p&&(i(r.position),l.value=!0,e("content:loaded"),setTimeout(u,0))},{immediate:!0}),i=d=>{if(s.value&&n.value&&t.value){const c=n.value.ControlPosition[d];s.value.controls[c].push(t.value)}},h=d=>{if(s.value&&n.value){let c=null;const p=n.value.ControlPosition[d];s.value.controls[p].forEach((f,m)=>{f===t.value&&(c=m)}),c!==null&&s.value.controls[p].removeAt(c)}};return a.onBeforeUnmount(()=>h(r.position)),a.watch(()=>r.position,(d,c)=>{h(c),i(d)}),a.watch(()=>r.index,d=>{d&&t.value&&(t.value.index=r.index)}),{controlRef:t,showContent:l}}}),$e={ref:"controlRef"};function qe(r,e,t,s,n,o){return a.withDirectives((a.openBlock(),a.createElementBlock("div",$e,[a.renderSlot(r.$slots,"default")],512)),[[a.vShow,r.showContent]])}const Ne=U(Re,[["render",qe]]),le=["closeclick","content_changed","domready","position_changed","visible","zindex_changed"],Ze=a.defineComponent({inheritAttrs:!1,props:{options:{type:Object,default:()=>({})}},emits:le,setup(r,{slots:e,emit:t,expose:s}){const n=a.ref(),o=a.ref(),l=a.inject(_,a.ref()),u=a.inject(L,a.ref()),i=a.inject(Q,a.ref());let h;const d=a.computed(()=>{var f;return(f=e.default)==null?void 0:f.call(e).some(m=>m.type!==a.Comment)}),c=f=>{var m;return(m=n.value)==null?void 0:m.open({map:l.value,anchor:i.value,...f})},p=()=>{var f;return(f=n.value)==null?void 0:f.close()};return a.onMounted(()=>{a.watch([l,()=>r.options],([f,m],[g,y])=>{const v=!S(m,y)||l.value!==g;l.value&&u.value&&v&&(n.value?(n.value.setOptions({...m,content:d.value?o.value:m.content}),i.value||c()):(n.value=a.markRaw(new u.value.InfoWindow({...m,content:d.value?o.value:m.content})),i.value?h=i.value.addListener("click",()=>{c()}):c(),le.forEach(k=>{var M;(M=n.value)==null||M.addListener(k,j=>t(k,j))})))},{immediate:!0})}),a.onBeforeUnmount(()=>{var f;h&&h.remove(),n.value&&((f=u.value)==null||f.event.clearInstanceListeners(n.value),p())}),s({infoWindow:n,open:c,close:p}),{infoWindow:n,infoWindowRef:o,hasSlotContent:d,open:c,close:p}}}),mt="",Ue={key:0,class:"info-window-wrapper"};function Fe(r,e,t,s,n,o){return r.hasSlotContent?(a.openBlock(),a.createElementBlock("div",Ue,[a.createElementVNode("div",a.mergeProps({ref:"infoWindowRef"},r.$attrs),[a.renderSlot(r.$slots,"default",{},void 0,!0)],16)])):a.createCommentVNode("",!0)}const De=U(Ze,[["render",Fe],["__scopeId","data-v-7138f548"]]),ce=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],V=1,B=8;class G{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,s]=new Uint8Array(e,0,2);if(t!==219)throw new Error("Data does not appear to be in a KDBush format.");const n=s>>4;if(n!==V)throw new Error(`Got v${n} data when expected v${V}.`);const o=ce[s&15];if(!o)throw new Error("Unrecognized array type.");const[l]=new Uint16Array(e,2,1),[u]=new Uint32Array(e,4,1);return new G(u,l,o,e)}constructor(e,t=64,s=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const o=ce.indexOf(this.ArrayType),l=e*2*this.ArrayType.BYTES_PER_ELEMENT,u=e*this.IndexArrayType.BYTES_PER_ELEMENT,i=(8-u%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${s}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,B,e),this.coords=new this.ArrayType(this.data,B+u+i,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(B+l+u+i),this.ids=new this.IndexArrayType(this.data,B,e),this.coords=new this.ArrayType(this.data,B+u+i,e*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(V<<4)+o]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=t,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return H(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,s,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:l,nodeSize:u}=this,i=[0,o.length-1,0],h=[];for(;i.length;){const d=i.pop()||0,c=i.pop()||0,p=i.pop()||0;if(c-p<=u){for(let y=p;y<=c;y++){const v=l[2*y],k=l[2*y+1];v>=e&&v<=s&&k>=t&&k<=n&&h.push(o[y])}continue}const f=p+c>>1,m=l[2*f],g=l[2*f+1];m>=e&&m<=s&&g>=t&&g<=n&&h.push(o[f]),(d===0?e<=m:t<=g)&&(i.push(p),i.push(f-1),i.push(1-d)),(d===0?s>=m:n>=g)&&(i.push(f+1),i.push(c),i.push(1-d))}return h}within(e,t,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:l}=this,u=[0,n.length-1,0],i=[],h=s*s;for(;u.length;){const d=u.pop()||0,c=u.pop()||0,p=u.pop()||0;if(c-p<=l){for(let y=p;y<=c;y++)de(o[2*y],o[2*y+1],e,t)<=h&&i.push(n[y]);continue}const f=p+c>>1,m=o[2*f],g=o[2*f+1];de(m,g,e,t)<=h&&i.push(n[f]),(d===0?e-s<=m:t-s<=g)&&(u.push(p),u.push(f-1),u.push(1-d)),(d===0?e+s>=m:t+s>=g)&&(u.push(f+1),u.push(c),u.push(1-d))}return i}}function H(r,e,t,s,n,o){if(n-s<=t)return;const l=s+n>>1;ue(r,e,l,s,n,o),H(r,e,t,s,l-1,1-o),H(r,e,t,l+1,n,1-o)}function ue(r,e,t,s,n,o){for(;n>s;){if(n-s>600){const h=n-s+1,d=t-s+1,c=Math.log(h),p=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*p*(h-p)/h)*(d-h/2<0?-1:1),m=Math.max(s,Math.floor(t-d*p/h+f)),g=Math.min(n,Math.floor(t+(h-d)*p/h+f));ue(r,e,t,m,g,o)}const l=e[2*t+o];let u=s,i=n;for(R(r,e,s,t),e[2*n+o]>l&&R(r,e,s,n);u<i;){for(R(r,e,u,i),u++,i--;e[2*u+o]<l;)u++;for(;e[2*i+o]>l;)i--}e[2*s+o]===l?R(r,e,s,i):(i++,R(r,e,i,n)),i<=t&&(s=i+1),t<=i&&(n=i-1)}}function R(r,e,t,s){W(r,t,s),W(e,2*t,2*s),W(e,2*t+1,2*s+1)}function W(r,e,t){const s=r[e];r[e]=r[t],r[t]=s}function de(r,e,t,s){const n=r-t,o=e-s;return n*n+o*o}const ze={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:r=>r},he=Math.fround||(r=>e=>(r[0]=+e,r[0]))(new Float32Array(1)),x=2,P=3,K=4,O=5,pe=6;class fe{constructor(e){this.options=Object.assign(Object.create(ze),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:s,maxZoom:n}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const l=[];for(let i=0;i<e.length;i++){const h=e[i];if(!h.geometry)continue;const[d,c]=h.geometry.coordinates,p=he(F(d)),f=he(D(c));l.push(p,f,1/0,i,-1,1),this.options.reduce&&l.push(0)}let u=this.trees[n+1]=this._createTree(l);t&&console.timeEnd(o);for(let i=n;i>=s;i--){const h=+Date.now();u=this.trees[i]=this._createTree(this._cluster(u,i)),t&&console.log("z%d: %d clusters in %dms",i,u.numItems,+Date.now()-h)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let o=e[2]===180?180:((e[2]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const c=this.getClusters([s,n,180,l],t),p=this.getClusters([-180,n,o,l],t);return c.concat(p)}const u=this.trees[this._limitZoom(t)],i=u.range(F(s),D(l),F(o),D(n)),h=u.data,d=[];for(const c of i){const p=this.stride*c;d.push(h[p+O]>1?me(h,p,this.clusterProps):this.points[h[p+P]])}return d}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),n="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(n);const l=o.data;if(t*this.stride>=l.length)throw new Error(n);const u=this.options.radius/(this.options.extent*Math.pow(2,s-1)),i=l[t*this.stride],h=l[t*this.stride+1],d=o.within(i,h,u),c=[];for(const p of d){const f=p*this.stride;l[f+K]===e&&c.push(l[f+O]>1?me(l,f,this.clusterProps):this.points[l[f+P]])}if(c.length===0)throw new Error(n);return c}getLeaves(e,t,s){t=t||10,s=s||0;const n=[];return this._appendLeaves(n,e,t,s,0),n}getTile(e,t,s){const n=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:l,radius:u}=this.options,i=u/l,h=(s-i)/o,d=(s+1+i)/o,c={features:[]};return this._addTileFeatures(n.range((t-i)/o,h,(t+1+i)/o,d),n.data,t,s,o,c),t===0&&this._addTileFeatures(n.range(1-i/o,h,1,d),n.data,o,s,o,c),t===o-1&&this._addTileFeatures(n.range(0,h,i/o,d),n.data,-1,s,o,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,s.length!==1)break;e=s[0].properties.cluster_id}return t}_appendLeaves(e,t,s,n,o){const l=this.getChildren(t);for(const u of l){const i=u.properties;if(i&&i.cluster?o+i.point_count<=n?o+=i.point_count:o=this._appendLeaves(e,i.cluster_id,s,n,o):o<n?o++:e.push(u),e.length===s)break}return o}_createTree(e){const t=new G(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let s=0;s<e.length;s+=this.stride)t.add(e[s],e[s+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,s,n,o,l){for(const u of e){const i=u*this.stride,h=t[i+O]>1;let d,c,p;if(h)d=ge(t,i,this.clusterProps),c=t[i],p=t[i+1];else{const g=this.points[t[i+P]];d=g.properties;const[y,v]=g.geometry.coordinates;c=F(y),p=D(v)}const f={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(p*o-n))]],tags:d};let m;h||this.options.generateId?m=t[i+P]:m=this.points[t[i+P]].id,m!==void 0&&(f.id=m),l.features.push(f)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:n,reduce:o,minPoints:l}=this.options,u=s/(n*Math.pow(2,t)),i=e.data,h=[],d=this.stride;for(let c=0;c<i.length;c+=d){if(i[c+x]<=t)continue;i[c+x]=t;const p=i[c],f=i[c+1],m=e.within(i[c],i[c+1],u),g=i[c+O];let y=g;for(const v of m){const k=v*d;i[k+x]>t&&(y+=i[k+O])}if(y>g&&y>=l){let v=p*g,k=f*g,M,j=-1;const q=((c/d|0)<<5)+(t+1)+this.points.length;for(const z of m){const b=z*d;if(i[b+x]<=t)continue;i[b+x]=t;const N=i[b+O];v+=i[b]*N,k+=i[b+1]*N,i[b+K]=q,o&&(M||(M=this._map(i,c,!0),j=this.clusterProps.length,this.clusterProps.push(M)),o(M,this._map(i,b)))}i[c+K]=q,h.push(v/y,k/y,1/0,q,-1,y),o&&h.push(j)}else{for(let v=0;v<d;v++)h.push(i[c+v]);if(y>1)for(const v of m){const k=v*d;if(!(i[k+x]<=t)){i[k+x]=t;for(let M=0;M<d;M++)h.push(i[k+M])}}}}return h}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,s){if(e[t+O]>1){const l=this.clusterProps[e[t+pe]];return s?Object.assign({},l):l}const n=this.points[e[t+P]].properties,o=this.options.map(n);return s&&o===n?Object.assign({},o):o}}function me(r,e,t){return{type:"Feature",id:r[e+P],properties:ge(r,e,t),geometry:{type:"Point",coordinates:[Ve(r[e]),Ge(r[e+1])]}}}function ge(r,e,t){const s=r[e+O],n=s>=1e4?`${Math.round(s/1e3)}k`:s>=1e3?`${Math.round(s/100)/10}k`:s,o=r[e+pe],l=o===-1?{}:Object.assign({},t[o]);return Object.assign(l,{cluster:!0,cluster_id:r[e+P],point_count:s,point_count_abbreviated:n})}function F(r){return r/360+.5}function D(r){const e=Math.sin(r*Math.PI/180),t=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return t<0?0:t>1?1:t}function Ve(r){return(r-.5)*360}function Ge(r){const e=(180-r*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
***************************************************************************** */function J(r,e){var t={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(r);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(r,s[n])&&(t[s[n]]=r[s[n]]);return t}class C{static isAdvancedMarkerAvailable(e){return google.maps.marker&&e.getMapCapabilities().isAdvancedMarkersAvailable===!0}static isAdvancedMarker(e){return google.maps.marker&&e instanceof google.maps.marker.AdvancedMarkerElement}static setMap(e,t){this.isAdvancedMarker(e)?e.map=t:e.setMap(t)}static getPosition(e){if(this.isAdvancedMarker(e)){if(e.position){if(e.position instanceof google.maps.LatLng)return e.position;if(e.position.lat&&e.position.lng)return new google.maps.LatLng(e.position.lat,e.position.lng)}return new google.maps.LatLng(null)}return e.getPosition()}static getVisible(e){return this.isAdvancedMarker(e)?!0:e.getVisible()}}class ${constructor({markers:e,position:t}){this.markers=e,t&&(t instanceof google.maps.LatLng?this._position=t:this._position=new google.maps.LatLng(t))}get bounds(){if(this.markers.length===0&&!this._position)return;const e=new google.maps.LatLngBounds(this._position,this._position);for(const t of this.markers)e.extend(C.getPosition(t));return e}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(e=>C.getVisible(e)).length}push(e){this.markers.push(e)}delete(){this.marker&&(C.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}const He=(r,e,t,s)=>{const n=ye(r.getBounds(),e,s);return t.filter(o=>n.contains(C.getPosition(o)))},ye=(r,e,t)=>{const{northEast:s,southWest:n}=We(r,e),o=Ke({northEast:s,southWest:n},t);return Je(o,e)},we=(r,e,t)=>{const s=ye(r,e,t),n=s.getNorthEast(),o=s.getSouthWest();return[o.lng(),o.lat(),n.lng(),n.lat()]},We=(r,e)=>({northEast:e.fromLatLngToDivPixel(r.getNorthEast()),southWest:e.fromLatLngToDivPixel(r.getSouthWest())}),Ke=({northEast:r,southWest:e},t)=>(r.x+=t,r.y-=t,e.x-=t,e.y+=t,{northEast:r,southWest:e}),Je=({northEast:r,southWest:e},t)=>{const s=t.fromDivPixelToLatLng(e),n=t.fromDivPixelToLatLng(r);return new google.maps.LatLngBounds(s,n)};class ve{constructor({maxZoom:e=16}){this.maxZoom=e}noop({markers:e}){return Xe(e)}}class Ye extends ve{constructor(e){var{viewportPadding:t=60}=e,s=J(e,["viewportPadding"]);super(s),this.viewportPadding=60,this.viewportPadding=t}calculate({markers:e,map:t,mapCanvasProjection:s}){return t.getZoom()>=this.maxZoom?{clusters:this.noop({markers:e}),changed:!1}:{clusters:this.cluster({markers:He(t,s,e,this.viewportPadding),map:t,mapCanvasProjection:s})}}}const Xe=r=>r.map(t=>new $({position:C.getPosition(t),markers:[t]}));class Qe extends ve{constructor(e){var{maxZoom:t,radius:s=60}=e,n=J(e,["maxZoom","radius"]);super({maxZoom:t}),this.state={zoom:-1},this.superCluster=new fe(Object.assign({maxZoom:this.maxZoom,radius:s},n))}calculate(e){let t=!1;const s={zoom:e.map.getZoom()};if(!S(e.markers,this.markers)){t=!0,this.markers=[...e.markers];const n=this.markers.map(o=>{const l=C.getPosition(o);return{type:"Feature",geometry:{type:"Point",coordinates:[l.lng(),l.lat()]},properties:{marker:o}}});this.superCluster.load(n)}return t||(this.state.zoom<=this.maxZoom||s.zoom<=this.maxZoom)&&(t=!S(this.state,s)),this.state=s,t&&(this.clusters=this.cluster(e)),{clusters:this.clusters,changed:t}}cluster({map:e}){return this.superCluster.getClusters([-180,-90,180,90],Math.round(e.getZoom())).map(t=>this.transformCluster(t))}transformCluster({geometry:{coordinates:[e,t]},properties:s}){if(s.cluster)return new $({markers:this.superCluster.getLeaves(s.cluster_id,1/0).map(o=>o.properties.marker),position:{lat:t,lng:e}});const n=s.marker;return new $({markers:[n],position:C.getPosition(n)})}}class et extends Ye{constructor(e){var{maxZoom:t,radius:s=60,viewportPadding:n=60}=e,o=J(e,["maxZoom","radius","viewportPadding"]);super({maxZoom:t,viewportPadding:n}),this.superCluster=new fe(Object.assign({maxZoom:this.maxZoom,radius:s},o)),this.state={zoom:-1,view:[0,0,0,0]}}calculate(e){const t={zoom:Math.round(e.map.getZoom()),view:we(e.map.getBounds(),e.mapCanvasProjection,this.viewportPadding)};let s=!S(this.state,t);if(!S(e.markers,this.markers)){s=!0,this.markers=[...e.markers];const n=this.markers.map(o=>{const l=C.getPosition(o);return{type:"Feature",geometry:{type:"Point",coordinates:[l.lng(),l.lat()]},properties:{marker:o}}});this.superCluster.load(n)}return s&&(this.clusters=this.cluster(e),this.state=t),{clusters:this.clusters,changed:s}}cluster({map:e,mapCanvasProjection:t}){const s={zoom:Math.round(e.getZoom()),view:we(e.getBounds(),t,this.viewportPadding)};return this.superCluster.getClusters(s.view,s.zoom).map(n=>this.transformCluster(n))}transformCluster({geometry:{coordinates:[e,t]},properties:s}){if(s.cluster)return new $({markers:this.superCluster.getLeaves(s.cluster_id,1/0).map(o=>o.properties.marker),position:{lat:t,lng:e}});const n=s.marker;return new $({markers:[n],position:C.getPosition(n)})}}class tt{constructor(e,t){this.markers={sum:e.length};const s=t.map(o=>o.count),n=s.reduce((o,l)=>o+l,0);this.clusters={count:t.length,markers:{mean:n/t.length,sum:n,min:Math.min(...s),max:Math.max(...s)}}}}class st{render({count:e,position:t},s,n){const l=`<svg fill="${e>Math.max(10,s.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">
|
|
16
|
+
<circle cx="120" cy="120" opacity=".6" r="70" />
|
|
17
|
+
<circle cx="120" cy="120" opacity=".3" r="90" />
|
|
18
|
+
<circle cx="120" cy="120" opacity=".2" r="110" />
|
|
19
|
+
<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${e}</text>
|
|
20
|
+
</svg>`,u=`Cluster of ${e} markers`,i=Number(google.maps.Marker.MAX_ZINDEX)+e;if(C.isAdvancedMarkerAvailable(n)){const d=document.createElement("div");d.innerHTML=l;const c=d.firstElementChild;c.setAttribute("transform","translate(0 25)");const p={map:n,position:t,zIndex:i,title:u,content:c};return new google.maps.marker.AdvancedMarkerElement(p)}const h={position:t,zIndex:i,title:u,icon:{url:`data:image/svg+xml;base64,${btoa(l)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(h)}}function nt(r,e){for(let t in e.prototype)r.prototype[t]=e.prototype[t]}class Y{constructor(){nt(Y,google.maps.OverlayView)}}var I;(function(r){r.CLUSTERING_BEGIN="clusteringbegin",r.CLUSTERING_END="clusteringend",r.CLUSTER_CLICK="click"})(I||(I={}));const rt=(r,e,t)=>{t.fitBounds(e.bounds)};class ot extends Y{constructor({map:e,markers:t=[],algorithmOptions:s={},algorithm:n=new Qe(s),renderer:o=new st,onClusterClick:l=rt}){super(),this.markers=[...t],this.clusters=[],this.algorithm=n,this.renderer=o,this.onClusterClick=l,e&&this.setMap(e)}addMarker(e,t){this.markers.includes(e)||(this.markers.push(e),t||this.render())}addMarkers(e,t){e.forEach(s=>{this.addMarker(s,!0)}),t||this.render()}removeMarker(e,t){const s=this.markers.indexOf(e);return s===-1?!1:(C.setMap(e,null),this.markers.splice(s,1),t||this.render(),!0)}removeMarkers(e,t){let s=!1;return e.forEach(n=>{s=this.removeMarker(n,!0)||s}),s&&!t&&this.render(),s}clearMarkers(e){this.markers.length=0,e||this.render()}render(){const e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,I.CLUSTERING_BEGIN,this);const{clusters:t,changed:s}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(s||s==null){const n=new Set;for(const l of t)l.markers.length==1&&n.add(l.markers[0]);const o=[];for(const l of this.clusters)l.marker!=null&&(l.markers.length==1?n.has(l.marker)||C.setMap(l.marker,null):o.push(l.marker));this.clusters=t,this.renderClusters(),requestAnimationFrame(()=>o.forEach(l=>C.setMap(l,null)))}google.maps.event.trigger(this,I.CLUSTERING_END,this)}}onAdd(){this.idleListener=this.getMap().addListener("idle",this.render.bind(this)),this.render()}onRemove(){google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(e=>C.setMap(e,null)),this.clusters.forEach(e=>e.delete()),this.clusters=[]}renderClusters(){const e=new tt(this.markers,this.clusters),t=this.getMap();this.clusters.forEach(s=>{s.markers.length===1?s.marker=s.markers[0]:(s.marker=this.renderer.render(s,e,t),s.markers.forEach(n=>C.setMap(n,null)),this.onClusterClick&&s.marker.addListener("click",n=>{google.maps.event.trigger(this,I.CLUSTER_CLICK,s),this.onClusterClick(n,s,t)})),C.setMap(s.marker,t)})}}const ke=Object.values(I),it=a.defineComponent({name:"MarkerCluster",props:{options:{type:Object,default:()=>({})}},emits:ke,setup(r,{emit:e,expose:t,slots:s}){const n=a.ref(),o=a.inject(_,a.ref()),l=a.inject(L,a.ref());return a.provide(ee,n),a.watch(o,()=>{o.value&&(n.value=a.markRaw(new ot({map:o.value,algorithm:new et(r.options.algorithmOptions??{}),...r.options})),ke.forEach(u=>{var i;(i=n.value)==null||i.addListener(u,h=>e(u,h))}))},{immediate:!0}),a.onBeforeUnmount(()=>{var u;n.value&&((u=l.value)==null||u.event.clearInstanceListeners(n.value),n.value.clearMarkers(),n.value.setMap(null))}),t({markerCluster:n}),()=>{var u;return(u=s.default)==null?void 0:u.call(s)}}}),at=a.defineComponent({inheritAttrs:!1,props:{options:{type:Object,required:!0}},setup(r,{slots:e,emit:t,expose:s}){const n=a.ref(),o=a.computed(()=>{var i;return(i=e.default)==null?void 0:i.call(e).some(h=>h.type!==a.Comment)}),l=a.computed(()=>({...r.options,element:n.value})),u=A(Z,[],l,t);return s({customMarker:u}),{customMarkerRef:n,customMarker:u,hasSlotContent:o}}}),gt="",lt={key:0,class:"custom-marker-wrapper"};function ct(r,e,t,s,n,o){return r.hasSlotContent?(a.openBlock(),a.createElementBlock("div",lt,[a.createElementVNode("div",a.mergeProps({ref:"customMarkerRef",style:{cursor:r.$attrs.onClick?"pointer":void 0}},r.$attrs),[a.renderSlot(r.$slots,"default",{},void 0,!0)],16)])):a.createCommentVNode("",!0)}const ut=U(at,[["render",ct],["__scopeId","data-v-cab807c1"]]),dt=a.defineComponent({name:"HeatmapLayer",props:{options:{type:Object,default:()=>({})}},setup(r){const e=a.ref(),t=a.inject(_,a.ref()),s=a.inject(L,a.ref());return a.watch([t,()=>r.options],([n,o],[l,u])=>{var h;const i=!S(o,u)||t.value!==l;if(t.value&&s.value&&i){const d=structuredClone(o);if(d.data&&!(d.data instanceof s.value.MVCArray)){const c=s.value.LatLng;d.data=(h=d.data)==null?void 0:h.map(p=>p instanceof c||"location"in p&&(p.location instanceof c||p.location===null)?p:"location"in p?{...p,location:new c(p.location)}:new c(p))}e.value?e.value.setOptions(d):e.value=a.markRaw(new s.value.visualization.HeatmapLayer({...d,map:t.value}))}},{immediate:!0}),a.onBeforeUnmount(()=>{e.value&&e.value.setMap(null)}),{heatmapLayer:e}},render:()=>null});w.Circle=Be,w.CustomControl=Ne,w.CustomMarker=ut,w.GoogleMap=Oe,w.HeatmapLayer=dt,w.InfoWindow=De,w.Marker=Te,w.MarkerCluster=it,w.Polygon=Ie,w.Polyline=Ae,w.Rectangle=je,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-google-map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@googlemaps/js-api-loader": "^1.12.11",
|
|
55
|
-
"@googlemaps/markerclusterer": "^2.0
|
|
55
|
+
"@googlemaps/markerclusterer": "^2.4.0",
|
|
56
56
|
"fast-deep-equal": "^3.1.3",
|
|
57
57
|
"vite-plugin-css-injected-by-js": "^3.2.1"
|
|
58
58
|
},
|