vue3-google-map 0.15.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 +62 -1
- package/dist/index.cjs.js +20 -0
- package/dist/index.es.js +1767 -0
- package/dist/index.umd.js +20 -0
- package/dist/themes/index.cjs.js +1 -0
- package/dist/themes/index.es.js +1294 -0
- package/dist/types/@types/index.d.ts +4 -4
- package/dist/types/components/Circle.d.ts +18 -13
- package/dist/types/components/CustomControl.vue.d.ts +28 -20
- package/dist/types/components/CustomMarker.vue.d.ts +22 -19
- package/dist/types/components/GoogleMap.vue.d.ts +409 -263
- package/dist/types/components/HeatmapLayer.d.ts +24 -21
- package/dist/types/components/InfoWindow.vue.d.ts +24 -17
- package/dist/types/components/Marker.d.ts +18 -13
- package/dist/types/components/MarkerCluster.d.ts +22 -15
- package/dist/types/components/Polygon.d.ts +18 -13
- package/dist/types/components/Polyline.d.ts +18 -13
- package/dist/types/components/Rectangle.d.ts +18 -13
- package/dist/types/components/index.d.ts +11 -11
- package/dist/types/composables/index.d.ts +1 -1
- package/dist/types/composables/useSetupMapComponent.d.ts +10 -10
- package/dist/types/index.d.ts +1 -3
- package/dist/types/shared/index.d.ts +14 -14
- package/dist/{themes/types → types/themes}/aubergine.d.ts +2 -2
- package/dist/{themes/types → types/themes}/dark.d.ts +6 -6
- package/dist/{themes/types → types/themes}/grey.d.ts +2 -2
- package/dist/{themes/types → types/themes}/index.d.ts +8 -8
- package/dist/{themes/types → types/themes}/minimal.d.ts +2 -2
- package/dist/{themes/types → types/themes}/retro.d.ts +2 -2
- package/dist/{themes/types → types/themes}/roadways.d.ts +2 -2
- package/dist/{themes/types → types/themes}/roadwaysMinimal.d.ts +2 -2
- package/dist/{themes/types → types/themes}/ultraLight.d.ts +2 -2
- package/dist/types/utils/index.d.ts +13 -13
- package/package.json +28 -44
- package/dist/cjs/index.js +0 -93
- package/dist/es/index.js +0 -87
- package/dist/themes/es/index.js +0 -28
- package/dist/types/shims-google-maps-d.d.ts +0 -15
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Note: Please refer to the [documentation site](https://vue3-google-map.netlify.a
|
|
|
21
21
|
- [Custom Marker](#custom-marker)
|
|
22
22
|
- [Custom Control](#custom-control)
|
|
23
23
|
- [Marker Cluster](#marker-cluster)
|
|
24
|
+
- [Heatmap Layer](#heatmap-layer)
|
|
24
25
|
- [Advanced Usage](#advanced-usage)
|
|
25
26
|
- [Contribution](#contribution)
|
|
26
27
|
- [License](#license)
|
|
@@ -39,12 +40,16 @@ yarn add vue3-google-map
|
|
|
39
40
|
|
|
40
41
|
#### CDN
|
|
41
42
|
|
|
42
|
-
Include the following script tag in your `index.html` (make sure to include it after Vue 3).
|
|
43
|
+
Include the following script tag in your `index.html` (make sure to include it after Vue 3's global build).
|
|
43
44
|
|
|
44
45
|
```html
|
|
45
46
|
<script src="https://unpkg.com/vue3-google-map"></script>
|
|
46
47
|
```
|
|
47
48
|
|
|
49
|
+
All the map components are available on the `Vue3GoogeMap` global variable.
|
|
50
|
+
|
|
51
|
+
[Codepen demo](https://codepen.io/husamibrahim/pen/poQXZbR)
|
|
52
|
+
|
|
48
53
|
### Your First Map
|
|
49
54
|
|
|
50
55
|
To construct a map using `vue3-google-map` you'll need to use the base `GoogleMap` component which receives your [Google Maps API key](https://developers.google.com/maps/documentation/javascript/get-api-key), styles (e.g. setting width and height), and any [MapOptions](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions) to configure your map ([see this](https://github.com/inocan-group/vue3-google-map/blob/develop/src/components/GoogleMap.vue#L57-L218) for all the supported `MapOptions`).
|
|
@@ -604,6 +609,62 @@ export default defineComponent({
|
|
|
604
609
|
|
|
605
610
|
You can listen for [the following events](https://googlemaps.github.io/js-markerclusterer/enums/MarkerClustererEvents.html) on the `MarkerCluster` component.
|
|
606
611
|
|
|
612
|
+
### Heatmap Layer
|
|
613
|
+
|
|
614
|
+
Use the `HeatmapLayer` component to depict the intensity of data at geographical points on the map. Make sure to include the `visualization` library in the `libraries` prop of the `GoogleMap` component.
|
|
615
|
+
|
|
616
|
+
#### Options
|
|
617
|
+
|
|
618
|
+
You can pass a [HeatmapLayerOptions](https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayerOptions) object to the `options` prop to configure your heatmap layer. Note that for convenience you can use [LatLngLiteral](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral)s if you wish for the locations.
|
|
619
|
+
|
|
620
|
+
```vue
|
|
621
|
+
<template>
|
|
622
|
+
<GoogleMap
|
|
623
|
+
api-key="YOUR_GOOGLE_MAPS_API_KEY"
|
|
624
|
+
:libraries="['visualization']"
|
|
625
|
+
style="width: 100%; height: 500px"
|
|
626
|
+
:center="sanFrancisco"
|
|
627
|
+
:zoom="13"
|
|
628
|
+
>
|
|
629
|
+
<HeatmapLayer :options="{ data: heatmapData }" />
|
|
630
|
+
</GoogleMap>
|
|
631
|
+
</template>
|
|
632
|
+
|
|
633
|
+
<script>
|
|
634
|
+
import { defineComponent } from "vue";
|
|
635
|
+
import { GoogleMap, HeatmapLayer } from "vue3-google-map";
|
|
636
|
+
|
|
637
|
+
export default defineComponent({
|
|
638
|
+
components: { GoogleMap, HeatmapLayer },
|
|
639
|
+
setup() {
|
|
640
|
+
const sanFrancisco = { lat: 37.774546, lng: -122.433523 }
|
|
641
|
+
|
|
642
|
+
const heatmapData = [
|
|
643
|
+
{ location: { lat: 37.782, lng: -122.447 }, weight: 0.5 },
|
|
644
|
+
{ lat: 37.782, lng: -122.445 },
|
|
645
|
+
{ location: { lat: 37.782, lng: -122.443 }, weight: 2 },
|
|
646
|
+
{ location: { lat: 37.782, lng: -122.441 }, weight: 3 },
|
|
647
|
+
{ location: { lat: 37.782, lng: -122.439 }, weight: 2 },
|
|
648
|
+
{ lat: 37.782, lng: -122.437 },
|
|
649
|
+
{ location: { lat: 37.782, lng: -122.435 }, weight: 0.5 },
|
|
650
|
+
|
|
651
|
+
{ location: { lat: 37.785, lng: -122.447 }, weight: 3 },
|
|
652
|
+
{ location: { lat: 37.785, lng: -122.445 }, weight: 2 },
|
|
653
|
+
{ lat: 37.785, lng: -122.443 },
|
|
654
|
+
{ location: { lat: 37.785, lng: -122.441 }, weight: 0.5 },
|
|
655
|
+
{ lat: 37.785, lng: -122.439 },
|
|
656
|
+
{ location: { lat: 37.785, lng: -122.437 }, weight: 2 },
|
|
657
|
+
{ location: { lat: 37.785, lng: -122.435 }, weight: 3 },
|
|
658
|
+
];
|
|
659
|
+
|
|
660
|
+
return {
|
|
661
|
+
sanFrancisco,
|
|
662
|
+
heatmapData,
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
});
|
|
666
|
+
</script>
|
|
667
|
+
```
|
|
607
668
|
|
|
608
669
|
## Advanced Usage
|
|
609
670
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var d=document.createElement("style");d.appendChild(document.createTextNode(".mapdiv[data-v-7d660dd5]{width:100%;height:100%}.info-window-wrapper[data-v-45a4606d]{display:none}.mapdiv .info-window-wrapper[data-v-45a4606d]{display:inline-block}.custom-marker-wrapper[data-v-c7599d50]{display:none}.mapdiv .custom-marker-wrapper[data-v-c7599d50]{display:inline-block}")),document.head.appendChild(d)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
"use strict";var ke=Object.defineProperty;var Ce=(n,e,t)=>e in n?ke(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var z=(n,e,t)=>(Ce(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue"),A=Symbol("map"),T=Symbol("api"),de=Symbol("marker"),he=Symbol("markerCluster"),F=Symbol("CustomMarker"),pe=Symbol("mapTilesLoaded"),L=["click","dblclick","drag","dragend","dragstart","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"];var _e=function n(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,r,o;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(r=s;r--!==0;)if(!n(e[r],t[r]))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(r=s;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=s;r--!==0;){var a=o[r];if(!n(e[a],t[a]))return!1}return!0}return e!==e&&t!==t};const X="__googleMapsScriptId";class O{constructor({apiKey:e,channel:t,client:s,id:r=X,libraries:o=[],language:a,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=r||X,this.libraries=o,this.language=a,this.region=u,this.mapIds=h,this.nonce=d,this.retries=c,this.url=p,O.instance){if(!_e(this.options,O.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(O.instance.options)}`);return O.instance}O.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 Me(n){return class extends n.OverlayView{constructor(s){super();z(this,"element");z(this,"opts");const{element:r,...o}=s;this.element=r,this.opts=o,this.opts.map&&this.setMap(this.opts.map)}getPosition(){return this.opts.position?this.opts.position instanceof n.LatLng?this.opts.position:new n.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 r=this.getProjection().fromLatLngToDivPixel(this.getPosition());if(r){this.element.style.position="absolute";const o=this.element.offsetHeight,a=this.element.offsetWidth;let u,i;switch(this.opts.anchorPoint){case"TOP_CENTER":u=r.x-a/2,i=r.y;break;case"BOTTOM_CENTER":u=r.x-a/2,i=r.y-o;break;case"LEFT_CENTER":u=r.x,i=r.y-o/2;break;case"RIGHT_CENTER":u=r.x-a,i=r.y-o/2;break;case"TOP_LEFT":u=r.x,i=r.y;break;case"TOP_RIGHT":u=r.x-a,i=r.y;break;case"BOTTOM_LEFT":u=r.x,i=r.y-o;break;case"BOTTOM_RIGHT":u=r.x-a,i=r.y-o;break;default:u=r.x-a/2,i=r.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 Q;const ee=["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"],be=l.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:ee,setup(n,{emit:e}){const t=l.ref(),s=l.ref(!1),r=l.ref(),o=l.ref(),a=l.ref(!1);l.provide(A,r),l.provide(T,o),l.provide(pe,a);const u=()=>{const c={...n};Object.keys(c).forEach(g=>{c[g]===void 0&&delete c[g]});const f=g=>{var v;return g?{position:(v=o.value)==null?void 0:v.ControlPosition[g]}:{}},m={scaleControlOptions:n.scaleControlStyle?{style:n.scaleControlStyle}:{},panControlOptions:f(n.panControlPosition),zoomControlOptions:f(n.zoomControlPosition),rotateControlOptions:f(n.rotateControlPosition),streetViewControlOptions:f(n.streetViewControlPosition),fullscreenControlOptions:f(n.fullscreenControlPosition),disableDefaultUI:n.disableDefaultUi};return{...c,...m}},i=l.watch([o,r],([c,p])=>{const f=c,m=p;f&&m&&(f.event.addListenerOnce(m,"tilesloaded",()=>{a.value=!0}),setTimeout(i,0))},{immediate:!0}),h=()=>{try{const{apiKey:c,region:p,version:f,language:m,libraries:g}=n;Q=new O({apiKey:c,region:p,version:f,language:m,libraries:g})}catch(c){console.error(c)}},d=c=>{o.value=l.markRaw(c.maps),r.value=l.markRaw(new c.maps.Map(t.value,u()));const p=Me(o.value);o.value[F]=p,ee.forEach(m=>{var g;(g=r.value)==null||g.addListener(m,v=>e(m,v))}),s.value=!0;const f=Object.keys(n).filter(m=>!["apiPromise","apiKey","version","libraries","region","language","center","zoom"].includes(m)).map(m=>l.toRef(n,m));l.watch([()=>n.center,()=>n.zoom,...f],([m,g],[v,y])=>{var N,_,B;const{center:w,zoom:C,...x}=u();(N=r.value)==null||N.setOptions(x),g!==void 0&&g!==y&&((_=r.value)==null||_.setZoom(g));const j=!v||m.lng!==v.lng||m.lat!==v.lat;m&&j&&((B=r.value)==null||B.panTo(m))})};return l.onMounted(()=>{n.apiPromise&&n.apiPromise instanceof Promise?n.apiPromise.then(d):(h(),Q.load().then(d))}),l.onBeforeUnmount(()=>{var c;a.value=!1,r.value&&((c=o.value)==null||c.event.clearInstanceListeners(r.value))}),{mapRef:t,ready:s,map:r,api:o,mapTilesLoaded:a}}});const D=(n,e)=>{const t=n.__vccOpts||n;for(const[s,r]of e)t[s]=r;return t},Pe={ref:"mapRef",class:"mapdiv"};function Oe(n,e,t,s,r,o){return l.openBlock(),l.createElementBlock("div",null,[l.createElementVNode("div",Pe,null,512),l.renderSlot(n.$slots,"default",l.normalizeProps(l.guardReactiveProps({ready:n.ready,map:n.map,api:n.api,mapTilesLoaded:n.mapTilesLoaded})),void 0,!0)])}const Ee=D(be,[["render",Oe],["__scopeId","data-v-7d660dd5"]]);function xe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Se=function n(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,r,o;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(r=s;r--!==0;)if(!n(e[r],t[r]))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(r=s;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=s;r--!==0;){var a=o[r];if(!n(e[a],t[a]))return!1}return!0}return e!==e&&t!==t};const E=xe(Se),Le=n=>n==="Marker",Ae=n=>n===F,I=(n,e,t,s)=>{const r=l.ref(),o=l.inject(A,l.ref()),a=l.inject(T,l.ref()),u=l.inject(he,l.ref()),i=l.computed(()=>!!(u.value&&a.value&&(r.value instanceof a.value.Marker||r.value instanceof a.value[F])));return l.watch([o,t],(h,[d,c])=>{var f,m,g;const p=!E(t.value,c)||o.value!==d;!o.value||!a.value||!p||(r.value?(r.value.setOptions(t.value),i.value&&((f=u.value)==null||f.removeMarker(r.value),(m=u.value)==null||m.addMarker(r.value))):(Le(n)?r.value=l.markRaw(new a.value[n](t.value)):Ae(n)?r.value=l.markRaw(new a.value[n](t.value)):r.value=l.markRaw(new a.value[n]({...t.value,map:o.value})),i.value?(g=u.value)==null||g.addMarker(r.value):r.value.setMap(o.value),e.forEach(v=>{var y;(y=r.value)==null||y.addListener(v,w=>s(v,w))})))},{immediate:!0}),l.onBeforeUnmount(()=>{var h,d;r.value&&((h=a.value)==null||h.event.clearInstanceListeners(r.value),i.value?(d=u.value)==null||d.removeMarker(r.value):r.value.setMap(null))}),r},te=["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=l.defineComponent({name:"Marker",props:{options:{type:Object,required:!0}},emits:te,setup(n,{emit:e,expose:t,slots:s}){const r=l.toRef(n,"options"),o=I("Marker",te,r,e);return l.provide(de,o),t({marker:o}),()=>{var a;return(a=s.default)==null?void 0:a.call(s)}}}),Ie=l.defineComponent({name:"Polyline",props:{options:{type:Object,required:!0}},emits:L,setup(n,{emit:e}){const t=l.toRef(n,"options");return{polyline:I("Polyline",L,t,e)}},render:()=>null}),je=l.defineComponent({name:"Polygon",props:{options:{type:Object,required:!0}},emits:L,setup(n,{emit:e}){const t=l.toRef(n,"options");return{polygon:I("Polygon",L,t,e)}},render:()=>null}),se=L.concat(["bounds_changed"]),Be=l.defineComponent({name:"Rectangle",props:{options:{type:Object,required:!0}},emits:se,setup(n,{emit:e}){const t=l.toRef(n,"options");return{rectangle:I("Rectangle",se,t,e)}},render:()=>null}),re=L.concat(["center_changed","radius_changed"]),Re=l.defineComponent({name:"Circle",props:{options:{type:Object,required:!0}},emits:re,setup(n,{emit:e}){const t=l.toRef(n,"options");return{circle:I("Circle",re,t,e)}},render:()=>null}),$e=l.defineComponent({props:{position:{type:String,required:!0},index:{type:Number,default:1}},emits:["content:loaded"],setup(n,{emit:e}){const t=l.ref(null),s=l.inject(A,l.ref()),r=l.inject(T,l.ref()),o=l.inject(pe,l.ref(!1)),a=l.ref(!1),u=l.watch([o,r,t],([d,c,p])=>{c&&d&&p&&(i(n.position),a.value=!0,e("content:loaded"),setTimeout(u,0))},{immediate:!0}),i=d=>{if(s.value&&r.value&&t.value){const c=r.value.ControlPosition[d];s.value.controls[c].push(t.value)}},h=d=>{if(s.value&&r.value){let c=null;const p=r.value.ControlPosition[d];s.value.controls[p].forEach((f,m)=>{f===t.value&&(c=m)}),c!==null&&s.value.controls[p].removeAt(c)}};return l.onBeforeUnmount(()=>h(n.position)),l.watch(()=>n.position,(d,c)=>{h(c),i(d)}),l.watch(()=>n.index,d=>{d&&t.value&&(t.value.index=n.index)}),{controlRef:t,showContent:a}}}),qe={ref:"controlRef"};function Ne(n,e,t,s,r,o){return l.withDirectives((l.openBlock(),l.createElementBlock("div",qe,[l.renderSlot(n.$slots,"default")],512)),[[l.vShow,n.showContent]])}const Ze=D($e,[["render",Ne]]),ne=["closeclick","content_changed","domready","position_changed","visible","zindex_changed"],Ue=l.defineComponent({inheritAttrs:!1,props:{options:{type:Object,default:()=>({})}},emits:ne,setup(n,{slots:e,emit:t,expose:s}){const r=l.ref(),o=l.ref(),a=l.inject(A,l.ref()),u=l.inject(T,l.ref()),i=l.inject(de,l.ref());let h;const d=l.computed(()=>{var f;return(f=e.default)==null?void 0:f.call(e).some(m=>m.type!==l.Comment)}),c=f=>{var m;return(m=r.value)==null?void 0:m.open({map:a.value,anchor:i.value,...f})},p=()=>{var f;return(f=r.value)==null?void 0:f.close()};return l.onMounted(()=>{l.watch([a,()=>n.options],([f,m],[g,v])=>{const y=!E(m,v)||a.value!==g;a.value&&u.value&&y&&(r.value?(r.value.setOptions({...m,content:d.value?o.value:m.content}),i.value||c()):(r.value=l.markRaw(new u.value.InfoWindow({...m,content:d.value?o.value:m.content})),i.value?h=i.value.addListener("click",()=>{c()}):c(),ne.forEach(w=>{var C;(C=r.value)==null||C.addListener(w,x=>t(w,x))})))},{immediate:!0})}),l.onBeforeUnmount(()=>{var f;h&&h.remove(),r.value&&((f=u.value)==null||f.event.clearInstanceListeners(r.value),p())}),s({infoWindow:r,open:c,close:p}),{infoWindow:r,infoWindowRef:o,hasSlotContent:d,open:c,close:p}}});const Fe={key:0,class:"info-window-wrapper"};function De(n,e,t,s,r,o){return n.hasSlotContent?(l.openBlock(),l.createElementBlock("div",Fe,[l.createElementVNode("div",l.mergeProps({ref:"infoWindowRef"},n.$attrs),[l.renderSlot(n.$slots,"default",{},void 0,!0)],16)])):l.createCommentVNode("",!0)}const ze=D(Ue,[["render",De],["__scopeId","data-v-45a4606d"]]),oe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],V=1,R=8;class K{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 r=s>>4;if(r!==V)throw new Error(`Got v${r} data when expected v${V}.`);const o=oe[s&15];if(!o)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(e,2,1),[u]=new Uint32Array(e,4,1);return new K(u,a,o,e)}constructor(e,t=64,s=Float64Array,r){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=oe.indexOf(this.ArrayType),a=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}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,R,e),this.coords=new this.ArrayType(this.data,R+u+i,e*2),this._pos=e*2,this._finished=!0):(this.data=new ArrayBuffer(R+a+u+i),this.ids=new this.IndexArrayType(this.data,R,e),this.coords=new this.ArrayType(this.data,R+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 W(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,s,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:a,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 v=p;v<=c;v++){const y=a[2*v],w=a[2*v+1];y>=e&&y<=s&&w>=t&&w<=r&&h.push(o[v])}continue}const f=p+c>>1,m=a[2*f],g=a[2*f+1];m>=e&&m<=s&&g>=t&&g<=r&&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:r>=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:r,coords:o,nodeSize:a}=this,u=[0,r.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<=a){for(let v=p;v<=c;v++)ie(o[2*v],o[2*v+1],e,t)<=h&&i.push(r[v]);continue}const f=p+c>>1,m=o[2*f],g=o[2*f+1];ie(m,g,e,t)<=h&&i.push(r[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 W(n,e,t,s,r,o){if(r-s<=t)return;const a=s+r>>1;fe(n,e,a,s,r,o),W(n,e,t,s,a-1,1-o),W(n,e,t,a+1,r,1-o)}function fe(n,e,t,s,r,o){for(;r>s;){if(r-s>600){const h=r-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(r,Math.floor(t+(h-d)*p/h+f));fe(n,e,t,m,g,o)}const a=e[2*t+o];let u=s,i=r;for($(n,e,s,t),e[2*r+o]>a&&$(n,e,s,r);u<i;){for($(n,e,u,i),u++,i--;e[2*u+o]<a;)u++;for(;e[2*i+o]>a;)i--}e[2*s+o]===a?$(n,e,s,i):(i++,$(n,e,i,r)),i<=t&&(s=i+1),t<=i&&(r=i-1)}}function $(n,e,t,s){G(n,t,s),G(e,2*t,2*s),G(e,2*t+1,2*s+1)}function G(n,e,t){const s=n[e];n[e]=n[t],n[t]=s}function ie(n,e,t,s){const r=n-t,o=e-s;return r*r+o*o}const Ve={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:n=>n},ae=Math.fround||(n=>e=>(n[0]=+e,n[0]))(new Float32Array(1)),P=2,b=3,H=4,M=5,me=6;class ge{constructor(e){this.options=Object.assign(Object.create(Ve),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:r}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const a=[];for(let i=0;i<e.length;i++){const h=e[i];if(!h.geometry)continue;const[d,c]=h.geometry.coordinates,p=ae(Z(d)),f=ae(U(c));a.push(p,f,1/0,i,-1,1),this.options.reduce&&a.push(0)}let u=this.trees[r+1]=this._createTree(a);t&&console.timeEnd(o);for(let i=r;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 r=Math.max(-90,Math.min(90,e[1]));let o=e[2]===180?180:((e[2]+180)%360+360)%360-180;const a=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,r,180,a],t),p=this.getClusters([-180,r,o,a],t);return c.concat(p)}const u=this.trees[this._limitZoom(t)],i=u.range(Z(s),U(a),Z(o),U(r)),h=u.data,d=[];for(const c of i){const p=this.stride*c;d.push(h[p+M]>1?le(h,p,this.clusterProps):this.points[h[p+b]])}return d}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),r="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(r);const a=o.data;if(t*this.stride>=a.length)throw new Error(r);const u=this.options.radius/(this.options.extent*Math.pow(2,s-1)),i=a[t*this.stride],h=a[t*this.stride+1],d=o.within(i,h,u),c=[];for(const p of d){const f=p*this.stride;a[f+H]===e&&c.push(a[f+M]>1?le(a,f,this.clusterProps):this.points[a[f+b]])}if(c.length===0)throw new Error(r);return c}getLeaves(e,t,s){t=t||10,s=s||0;const r=[];return this._appendLeaves(r,e,t,s,0),r}getTile(e,t,s){const r=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:a,radius:u}=this.options,i=u/a,h=(s-i)/o,d=(s+1+i)/o,c={features:[]};return this._addTileFeatures(r.range((t-i)/o,h,(t+1+i)/o,d),r.data,t,s,o,c),t===0&&this._addTileFeatures(r.range(1-i/o,h,1,d),r.data,o,s,o,c),t===o-1&&this._addTileFeatures(r.range(0,h,i/o,d),r.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,r,o){const a=this.getChildren(t);for(const u of a){const i=u.properties;if(i&&i.cluster?o+i.point_count<=r?o+=i.point_count:o=this._appendLeaves(e,i.cluster_id,s,r,o):o<r?o++:e.push(u),e.length===s)break}return o}_createTree(e){const t=new K(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,r,o,a){for(const u of e){const i=u*this.stride,h=t[i+M]>1;let d,c,p;if(h)d=ve(t,i,this.clusterProps),c=t[i],p=t[i+1];else{const g=this.points[t[i+b]];d=g.properties;const[v,y]=g.geometry.coordinates;c=Z(v),p=U(y)}const f={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(p*o-r))]],tags:d};let m;h||this.options.generateId?m=t[i+b]:m=this.points[t[i+b]].id,m!==void 0&&(f.id=m),a.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:r,reduce:o,minPoints:a}=this.options,u=s/(r*Math.pow(2,t)),i=e.data,h=[],d=this.stride;for(let c=0;c<i.length;c+=d){if(i[c+P]<=t)continue;i[c+P]=t;const p=i[c],f=i[c+1],m=e.within(i[c],i[c+1],u),g=i[c+M];let v=g;for(const y of m){const w=y*d;i[w+P]>t&&(v+=i[w+M])}if(v>g&&v>=a){let y=p*g,w=f*g,C,x=-1;const j=((c/d|0)<<5)+(t+1)+this.points.length;for(const N of m){const _=N*d;if(i[_+P]<=t)continue;i[_+P]=t;const B=i[_+M];y+=i[_]*B,w+=i[_+1]*B,i[_+H]=j,o&&(C||(C=this._map(i,c,!0),x=this.clusterProps.length,this.clusterProps.push(C)),o(C,this._map(i,_)))}i[c+H]=j,h.push(y/v,w/v,1/0,j,-1,v),o&&h.push(x)}else{for(let y=0;y<d;y++)h.push(i[c+y]);if(v>1)for(const y of m){const w=y*d;if(!(i[w+P]<=t)){i[w+P]=t;for(let C=0;C<d;C++)h.push(i[w+C])}}}}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+M]>1){const a=this.clusterProps[e[t+me]];return s?Object.assign({},a):a}const r=this.points[e[t+b]].properties,o=this.options.map(r);return s&&o===r?Object.assign({},o):o}}function le(n,e,t){return{type:"Feature",id:n[e+b],properties:ve(n,e,t),geometry:{type:"Point",coordinates:[Ge(n[e]),He(n[e+1])]}}}function ve(n,e,t){const s=n[e+M],r=s>=1e4?`${Math.round(s/1e3)}k`:s>=1e3?`${Math.round(s/100)/10}k`:s,o=n[e+me],a=o===-1?{}:Object.assign({},t[o]);return Object.assign(a,{cluster:!0,cluster_id:n[e+b],point_count:s,point_count_abbreviated:r})}function Z(n){return n/360+.5}function U(n){const e=Math.sin(n*Math.PI/180),t=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return t<0?0:t>1?1:t}function Ge(n){return(n-.5)*360}function He(n){const e=(180-n*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */function J(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}class k{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 q{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(k.getPosition(t));return e}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(e=>k.getVisible(e)).length}push(e){this.markers.push(e)}delete(){this.marker&&(k.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}const We=(n,e,t,s)=>{const r=ye(n.getBounds(),e,s);return t.filter(o=>r.contains(k.getPosition(o)))},ye=(n,e,t)=>{const{northEast:s,southWest:r}=Ke(n,e),o=Je({northEast:s,southWest:r},t);return Ye(o,e)},ce=(n,e,t)=>{const s=ye(n,e,t),r=s.getNorthEast(),o=s.getSouthWest();return[o.lng(),o.lat(),r.lng(),r.lat()]},Ke=(n,e)=>({northEast:e.fromLatLngToDivPixel(n.getNorthEast()),southWest:e.fromLatLngToDivPixel(n.getSouthWest())}),Je=({northEast:n,southWest:e},t)=>(n.x+=t,n.y-=t,e.x-=t,e.y+=t,{northEast:n,southWest:e}),Ye=({northEast:n,southWest:e},t)=>{const s=t.fromDivPixelToLatLng(e),r=t.fromDivPixelToLatLng(n);return new google.maps.LatLngBounds(s,r)};class we{constructor({maxZoom:e=16}){this.maxZoom=e}noop({markers:e}){return Qe(e)}}class Xe extends we{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:We(t,s,e,this.viewportPadding),map:t,mapCanvasProjection:s})}}}const Qe=n=>n.map(t=>new q({position:k.getPosition(t),markers:[t]}));class et extends we{constructor(e){var{maxZoom:t,radius:s=60}=e,r=J(e,["maxZoom","radius"]);super({maxZoom:t}),this.state={zoom:-1},this.superCluster=new ge(Object.assign({maxZoom:this.maxZoom,radius:s},r))}calculate(e){let t=!1;const s={zoom:e.map.getZoom()};if(!E(e.markers,this.markers)){t=!0,this.markers=[...e.markers];const r=this.markers.map(o=>{const a=k.getPosition(o);return{type:"Feature",geometry:{type:"Point",coordinates:[a.lng(),a.lat()]},properties:{marker:o}}});this.superCluster.load(r)}return t||(this.state.zoom<=this.maxZoom||s.zoom<=this.maxZoom)&&(t=!E(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 q({markers:this.superCluster.getLeaves(s.cluster_id,1/0).map(o=>o.properties.marker),position:{lat:t,lng:e}});const r=s.marker;return new q({markers:[r],position:k.getPosition(r)})}}class tt extends Xe{constructor(e){var{maxZoom:t,radius:s=60,viewportPadding:r=60}=e,o=J(e,["maxZoom","radius","viewportPadding"]);super({maxZoom:t,viewportPadding:r}),this.superCluster=new ge(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:ce(e.map.getBounds(),e.mapCanvasProjection,this.viewportPadding)};let s=!E(this.state,t);if(!E(e.markers,this.markers)){s=!0,this.markers=[...e.markers];const r=this.markers.map(o=>{const a=k.getPosition(o);return{type:"Feature",geometry:{type:"Point",coordinates:[a.lng(),a.lat()]},properties:{marker:o}}});this.superCluster.load(r)}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:ce(e.getBounds(),t,this.viewportPadding)};return this.superCluster.getClusters(s.view,s.zoom).map(r=>this.transformCluster(r))}transformCluster({geometry:{coordinates:[e,t]},properties:s}){if(s.cluster)return new q({markers:this.superCluster.getLeaves(s.cluster_id,1/0).map(o=>o.properties.marker),position:{lat:t,lng:e}});const r=s.marker;return new q({markers:[r],position:k.getPosition(r)})}}class st{constructor(e,t){this.markers={sum:e.length};const s=t.map(o=>o.count),r=s.reduce((o,a)=>o+a,0);this.clusters={count:t.length,markers:{mean:r/t.length,sum:r,min:Math.min(...s),max:Math.max(...s)}}}}class rt{render({count:e,position:t},s,r){const a=`<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(k.isAdvancedMarkerAvailable(r)){const d=document.createElement("div");d.innerHTML=a;const c=d.firstElementChild;c.setAttribute("transform","translate(0 25)");const p={map:r,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(a)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(h)}}function nt(n,e){for(let t in e.prototype)n.prototype[t]=e.prototype[t]}class Y{constructor(){nt(Y,google.maps.OverlayView)}}var S;(function(n){n.CLUSTERING_BEGIN="clusteringbegin",n.CLUSTERING_END="clusteringend",n.CLUSTER_CLICK="click"})(S||(S={}));const ot=(n,e,t)=>{t.fitBounds(e.bounds)};class it extends Y{constructor({map:e,markers:t=[],algorithmOptions:s={},algorithm:r=new et(s),renderer:o=new rt,onClusterClick:a=ot}){super(),this.markers=[...t],this.clusters=[],this.algorithm=r,this.renderer=o,this.onClusterClick=a,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:(k.setMap(e,null),this.markers.splice(s,1),t||this.render(),!0)}removeMarkers(e,t){let s=!1;return e.forEach(r=>{s=this.removeMarker(r,!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,S.CLUSTERING_BEGIN,this);const{clusters:t,changed:s}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(s||s==null){const r=new Set;for(const a of t)a.markers.length==1&&r.add(a.markers[0]);const o=[];for(const a of this.clusters)a.marker!=null&&(a.markers.length==1?r.has(a.marker)||k.setMap(a.marker,null):o.push(a.marker));this.clusters=t,this.renderClusters(),requestAnimationFrame(()=>o.forEach(a=>k.setMap(a,null)))}google.maps.event.trigger(this,S.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=>k.setMap(e,null)),this.clusters.forEach(e=>e.delete()),this.clusters=[]}renderClusters(){const e=new st(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(r=>k.setMap(r,null)),this.onClusterClick&&s.marker.addListener("click",r=>{google.maps.event.trigger(this,S.CLUSTER_CLICK,s),this.onClusterClick(r,s,t)})),k.setMap(s.marker,t)})}}const ue=Object.values(S),at=l.defineComponent({name:"MarkerCluster",props:{options:{type:Object,default:()=>({})}},emits:ue,setup(n,{emit:e,expose:t,slots:s}){const r=l.ref(),o=l.inject(A,l.ref()),a=l.inject(T,l.ref());return l.provide(he,r),l.watch(o,()=>{o.value&&(r.value=l.markRaw(new it({map:o.value,algorithm:new tt(n.options.algorithmOptions??{}),...n.options})),ue.forEach(u=>{var i;(i=r.value)==null||i.addListener(u,h=>e(u,h))}))},{immediate:!0}),l.onBeforeUnmount(()=>{var u;r.value&&((u=a.value)==null||u.event.clearInstanceListeners(r.value),r.value.clearMarkers(),r.value.setMap(null))}),t({markerCluster:r}),()=>{var u;return(u=s.default)==null?void 0:u.call(s)}}}),lt=l.defineComponent({inheritAttrs:!1,props:{options:{type:Object,required:!0}},setup(n,{slots:e,emit:t,expose:s}){const r=l.ref(),o=l.computed(()=>{var i;return(i=e.default)==null?void 0:i.call(e).some(h=>h.type!==l.Comment)}),a=l.computed(()=>({...n.options,element:r.value})),u=I(F,[],a,t);return s({customMarker:u}),{customMarkerRef:r,customMarker:u,hasSlotContent:o}}});const ct={key:0,class:"custom-marker-wrapper"};function ut(n,e,t,s,r,o){return n.hasSlotContent?(l.openBlock(),l.createElementBlock("div",ct,[l.createElementVNode("div",l.mergeProps({ref:"customMarkerRef",style:{cursor:n.$attrs.onClick?"pointer":void 0}},n.$attrs),[l.renderSlot(n.$slots,"default",{},void 0,!0)],16)])):l.createCommentVNode("",!0)}const dt=D(lt,[["render",ut],["__scopeId","data-v-c7599d50"]]),ht=l.defineComponent({name:"HeatmapLayer",props:{options:{type:Object,default:()=>({})}},setup(n){const e=l.ref(),t=l.inject(A,l.ref()),s=l.inject(T,l.ref());return l.watch([t,()=>n.options],([r,o],[a,u])=>{var h;const i=!E(o,u)||t.value!==a;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=l.markRaw(new s.value.visualization.HeatmapLayer({...d,map:t.value}))}},{immediate:!0}),l.onBeforeUnmount(()=>{e.value&&e.value.setMap(null)}),{heatmapLayer:e}},render:()=>null});exports.Circle=Re;exports.CustomControl=Ze;exports.CustomMarker=dt;exports.GoogleMap=Ee;exports.HeatmapLayer=ht;exports.InfoWindow=ze;exports.Marker=Te;exports.MarkerCluster=at;exports.Polygon=je;exports.Polyline=Ie;exports.Rectangle=Be;
|