@mptw/skylens-ui 1.4.98 → 1.4.100

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.
@@ -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 { HeapmapLayer } from '@deck.gl/aggregation-layers';
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 runtimeConfig = useRuntimeConfig();
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,19 +39,9 @@ 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
- map = Map(mapEl.value, {
43
+ map = new $Map(mapEl.value, {
44
+ center: { lat: 37.77325660358167, lng: -122.41712341793448 },
59
45
  disableDefaultUI: true,
60
46
  styles: [
61
47
  {
@@ -70,27 +56,26 @@ export default defineComponent({
70
56
  });
71
57
  }
72
58
 
73
- 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();
78
63
  }
79
64
 
80
65
  function setupMarkers() {
81
- const bounds = new LatLngBounds();
66
+ const bounds = new $LatLngBounds();
82
67
  markers.forEach((marker) => marker.setMap(null));
83
68
  markers = [];
84
69
 
85
70
  latlons.value.forEach((latlon) => {
86
- const position = new LatLng(
71
+ const position = new $LatLng(
87
72
  Number(latlon.lat),
88
73
  Number(latlon.lon)
89
74
  );
90
75
  bounds.extend(position);
91
76
 
92
77
  markers.push(
93
- new AdvancedMarkerElement({
78
+ new $AdvancedMarkerElement({
94
79
  position,
95
80
  map: isShowMarker.value ? map : null,
96
81
  })
@@ -109,8 +94,8 @@ export default defineComponent({
109
94
  .filter((weight) => weight.weight > 0)
110
95
  .map((weight) => ({
111
96
  location: [
112
- Number(weight.lat),
113
- Number(weight.lon)
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
  });
@@ -154,7 +140,7 @@ export default defineComponent({
154
140
  });
155
141
  </script>
156
142
 
157
- <style lang="stylus">
143
+ <style lang="stylus" scoped>
158
144
  .heat-map
159
145
  @apply w-full h-full
160
146
  </style>
package/nuxt.config.ts CHANGED
@@ -11,7 +11,7 @@ export default defineNuxtConfig({
11
11
  public: {
12
12
  defaultMobileEndDateBeforeNow: 4,
13
13
  icoUrl: 'https://skylens-mng-dev-1087511617183.asia-east1.run.app',
14
- googleMapsApiKey: 'AIzaSyDFNjeGBtbW-BdLKMb78cUR4F_OtUl0tlg',
14
+ googleMapsApiKey: 'AIzaSyDMNNizDMizdxJd3oAhsbkx1kL5Gyicnns',
15
15
  },
16
16
  },
17
17
  components: [
@@ -23,6 +23,7 @@ export default defineNuxtConfig({
23
23
  ],
24
24
  modules: ['@nuxtjs/tailwindcss'],
25
25
  plugins: [
26
+ '~ui/plugins/googlemap.ts',
26
27
  '~ui/plugins/v-calendar.ts',
27
28
  ],
28
29
  tailwindcss: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mptw/skylens-ui",
3
3
  "type": "module",
4
- "version": "1.4.98",
4
+ "version": "1.4.100",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",
@@ -0,0 +1,15 @@
1
+ <template lang="pug">
2
+ .container
3
+ SLHeatMap
4
+ </template>
5
+
6
+ <script lang="ts">
7
+ export default defineComponent({
8
+ name: 'IndexPage',
9
+ });
10
+ </script>
11
+
12
+ <style lang="stylus" scoped>
13
+ .container
14
+ @apply s('w-[600px]') s('h-[480px]')
15
+ </style>
@@ -0,0 +1,29 @@
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
+ if (!import.meta.client) return;
15
+
16
+ const runtimeConfig = useRuntimeConfig();
17
+ setOptions({
18
+ key: runtimeConfig.public.googleMapsApiKey,
19
+ });
20
+
21
+ const { LatLngBounds, LatLng } = await importLibrary('core');
22
+ const { Map } = await importLibrary('maps');
23
+ const { AdvancedMarkerElement } = await importLibrary('marker');
24
+
25
+ nuxtApp.provide('LatLngBounds', LatLngBounds);
26
+ nuxtApp.provide('LatLng', LatLng);
27
+ nuxtApp.provide('Map', Map);
28
+ nuxtApp.provide('AdvancedMarkerElement', AdvancedMarkerElement);
29
+ });