@mptw/skylens-ui 1.4.98 → 1.4.99
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/components/SLHeatMap.vue +6 -20
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
- package/plugins/googlemap.ts +27 -0
package/components/SLHeatMap.vue
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import type { PropType } from "vue";
|
|
7
|
-
import { setOptions, importLibrary } from '@googlemaps/js-api-loader';
|
|
8
7
|
import { GoogleMapsOverlay } from '@deck.gl/google-maps';
|
|
9
|
-
import {
|
|
8
|
+
import { HeatmapLayer } from '@deck.gl/aggregation-layers';
|
|
10
9
|
|
|
11
10
|
const RADIUS = 30;
|
|
12
11
|
|
|
@@ -28,14 +27,11 @@ export default defineComponent({
|
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
setup(props) {
|
|
31
|
-
const
|
|
30
|
+
const { LatLngBounds, LatLng, AdvancedMarkerElement, Map } = useNuxtApp();
|
|
32
31
|
const { latlons, weights, isShowMarker } = toRefs(props);
|
|
33
32
|
|
|
34
33
|
const mapEl = shallowRef<HTMLElement | null>(null);
|
|
35
34
|
|
|
36
|
-
let LatLngBounds: any | null = null;
|
|
37
|
-
let LatLng: any | null = null;
|
|
38
|
-
let AdvancedMarkerElement: any | null = null;
|
|
39
35
|
let map: any | null = null;
|
|
40
36
|
let overlay: any | null = null;
|
|
41
37
|
let markers: any[] = [];
|
|
@@ -43,17 +39,6 @@ export default defineComponent({
|
|
|
43
39
|
async function initMap() {
|
|
44
40
|
if (!mapEl.value) return;
|
|
45
41
|
|
|
46
|
-
setOptions({
|
|
47
|
-
key: runtimeConfig.public.googleMapsApiKey,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const { LatLng: LatLngClass, LatLngBounds: LatLngBoundsClass } = await importLibrary("core");
|
|
51
|
-
const { Map } = await importLibrary("maps");
|
|
52
|
-
const { AdvancedMarkerElement: AdvancedMarkerElementClass } = await importLibrary('marker');
|
|
53
|
-
LatLng = LatLngClass;
|
|
54
|
-
LatLngBounds = LatLngBoundsClass;
|
|
55
|
-
AdvancedMarkerElement = AdvancedMarkerElementClass;
|
|
56
|
-
|
|
57
42
|
if (!map) {
|
|
58
43
|
map = Map(mapEl.value, {
|
|
59
44
|
disableDefaultUI: true,
|
|
@@ -71,7 +56,7 @@ export default defineComponent({
|
|
|
71
56
|
}
|
|
72
57
|
|
|
73
58
|
map.setCenter({ lat: 23.586114913594802, lng: 120.87814086119803 });
|
|
74
|
-
overlay = new GoogleMapsOverlay();
|
|
59
|
+
overlay = new GoogleMapsOverlay({});
|
|
75
60
|
overlay.setMap(map);
|
|
76
61
|
|
|
77
62
|
setupHeatmapData();
|
|
@@ -109,8 +94,8 @@ export default defineComponent({
|
|
|
109
94
|
.filter((weight) => weight.weight > 0)
|
|
110
95
|
.map((weight) => ({
|
|
111
96
|
location: [
|
|
112
|
-
Number(weight.
|
|
113
|
-
Number(weight.
|
|
97
|
+
Number(weight.lon).valueOf(),
|
|
98
|
+
Number(weight.lat).valueOf()
|
|
114
99
|
],
|
|
115
100
|
weight: weight.weight,
|
|
116
101
|
}));
|
|
@@ -123,6 +108,7 @@ export default defineComponent({
|
|
|
123
108
|
aggregation: 'SUM',
|
|
124
109
|
getPosition: (d: { location: number[], weight: number }) => d.location,
|
|
125
110
|
getWeight: (d: { location: number[], weight: number }) => d.weight,
|
|
111
|
+
radius: RADIUS,
|
|
126
112
|
}),
|
|
127
113
|
],
|
|
128
114
|
});
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { setOptions, importLibrary } from '@googlemaps/js-api-loader';
|
|
2
|
+
|
|
3
|
+
declare module '#app' {
|
|
4
|
+
interface NuxtApp {
|
|
5
|
+
LatLngBounds: google.maps.LatLngBounds;
|
|
6
|
+
LatLng: google.maps.LatLng;
|
|
7
|
+
Map: google.maps.Map;
|
|
8
|
+
AdvancedMarkerElement: google.maps.AdvancedMarkerElement;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
14
|
+
const runtimeConfig = useRuntimeConfig();
|
|
15
|
+
setOptions({
|
|
16
|
+
key: runtimeConfig.public.googleMapsApiKey,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const { LatLngBounds, LatLng } = await importLibrary('core');
|
|
20
|
+
const { Map } = await importLibrary('maps');
|
|
21
|
+
const { AdvancedMarkerElement } = await importLibrary('marker');
|
|
22
|
+
|
|
23
|
+
nuxtApp.provide('LatLngBounds', LatLngBounds);
|
|
24
|
+
nuxtApp.provide('LatLng', LatLng);
|
|
25
|
+
nuxtApp.provide('Map', Map);
|
|
26
|
+
nuxtApp.provide('AdvancedMarkerElement', AdvancedMarkerElement);
|
|
27
|
+
});
|