@mptw/skylens-ui 1.4.99 → 1.4.101

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.
@@ -27,7 +27,7 @@ export default defineComponent({
27
27
  },
28
28
  },
29
29
  setup(props) {
30
- const { LatLngBounds, LatLng, AdvancedMarkerElement, Map } = useNuxtApp();
30
+ const { $LatLngBounds, $LatLng, $AdvancedMarkerElement, $Map } = useNuxtApp();
31
31
  const { latlons, weights, isShowMarker } = toRefs(props);
32
32
 
33
33
  const mapEl = shallowRef<HTMLElement | null>(null);
@@ -40,42 +40,35 @@ export default defineComponent({
40
40
  if (!mapEl.value) return;
41
41
 
42
42
  if (!map) {
43
- map = Map(mapEl.value, {
43
+ map = new $Map(mapEl.value, {
44
+ zoom: 11,
45
+ mapId: '160f8be79f87792deee048cf',
46
+ center: { lat: 37.77325660358167, lng: -122.41712341793448 },
44
47
  disableDefaultUI: true,
45
- styles: [
46
- {
47
- featureType: "poi",
48
- stylers: [{ visibility: "off" }],
49
- },
50
- {
51
- featureType: "transit",
52
- stylers: [{ visibility: "off" }],
53
- },
54
- ],
55
48
  });
56
49
  }
57
50
 
58
- map.setCenter({ lat: 23.586114913594802, lng: 120.87814086119803 });
59
51
  overlay = new GoogleMapsOverlay({});
60
52
  overlay.setMap(map);
61
53
 
54
+ setupMarkers();
62
55
  setupHeatmapData();
63
56
  }
64
57
 
65
58
  function setupMarkers() {
66
- const bounds = new LatLngBounds();
59
+ const bounds = new $LatLngBounds();
67
60
  markers.forEach((marker) => marker.setMap(null));
68
61
  markers = [];
69
62
 
70
63
  latlons.value.forEach((latlon) => {
71
- const position = new LatLng(
64
+ const position = new $LatLng(
72
65
  Number(latlon.lat),
73
66
  Number(latlon.lon)
74
67
  );
75
68
  bounds.extend(position);
76
69
 
77
70
  markers.push(
78
- new AdvancedMarkerElement({
71
+ new $AdvancedMarkerElement({
79
72
  position,
80
73
  map: isShowMarker.value ? map : null,
81
74
  })
@@ -100,7 +93,7 @@ export default defineComponent({
100
93
  weight: weight.weight,
101
94
  }));
102
95
 
103
- overlay.setOptions({
96
+ overlay.setProps({
104
97
  layers: [
105
98
  new HeatmapLayer({
106
99
  id: 'HeatmapLayer',
@@ -131,6 +124,10 @@ export default defineComponent({
131
124
  });
132
125
 
133
126
  onBeforeUnmount(() => {
127
+ if (overlay) {
128
+ overlay.finalize();
129
+ }
130
+ overlay = null;
134
131
  });
135
132
 
136
133
  return {
@@ -140,7 +137,7 @@ export default defineComponent({
140
137
  });
141
138
  </script>
142
139
 
143
- <style lang="stylus">
140
+ <style lang="stylus" scoped>
144
141
  .heat-map
145
142
  @apply w-full h-full
146
143
  </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: [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mptw/skylens-ui",
3
3
  "type": "module",
4
- "version": "1.4.99",
4
+ "version": "1.4.101",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",
@@ -0,0 +1,41 @@
1
+ <template lang="pug">
2
+ .main
3
+ a(href='javascript:;', @click='onClickedToggle') toggle
4
+ .container
5
+ SLHeatMap(:latlons="latlons", :weights="latlons", :is-show-marker="isShowMarker")
6
+ </template>
7
+
8
+ <script lang="ts">
9
+ export default defineComponent({
10
+ name: 'IndexPage',
11
+ setup() {
12
+ const isShowMarker = ref(false);
13
+ const latlons = computed(() => {
14
+ return [
15
+ { weight: 4, lon: -122.42177834, lat: 37.78346622 },
16
+ { weight: 2, lon: -122.414411, lat: 37.774458 },
17
+ { weight: 2, lon: -122.438887, lat: 37.772737 },
18
+ { weight: 2, lon: -122.42019976, lat: 37.75087429 },
19
+ { weight: 2, lon: -122.392606, lat: 37.779369 },
20
+ { weight: 2, lon: -122.43065953, lat: 37.77185018 },
21
+ { weight: 2, lon: -122.43065953, lat: 37.77185018 },
22
+ { weight: 4, lon: -122.418974, lat: 37.754029 },
23
+ { weight: 14, lon: -122.419014, lat: 37.780519 },
24
+ { weight: 2, lon: -122.404719, lat: 37.770128 },
25
+ { weight: 2, lon: -122.390466, lat: 37.780226 },
26
+ ];
27
+ });
28
+
29
+ function onClickedToggle() {
30
+ isShowMarker.value = !isShowMarker.value;
31
+ }
32
+
33
+ return { latlons, isShowMarker, onClickedToggle };
34
+ },
35
+ });
36
+ </script>
37
+
38
+ <style lang="stylus" scoped>
39
+ .container
40
+ @apply s('w-[600px]') s('h-[480px]')
41
+ </style>
@@ -2,15 +2,17 @@ import { setOptions, importLibrary } from '@googlemaps/js-api-loader';
2
2
 
3
3
  declare module '#app' {
4
4
  interface NuxtApp {
5
- LatLngBounds: google.maps.LatLngBounds;
6
- LatLng: google.maps.LatLng;
7
- Map: google.maps.Map;
8
- AdvancedMarkerElement: google.maps.AdvancedMarkerElement;
5
+ $LatLngBounds: google.maps.LatLngBounds;
6
+ $LatLng: google.maps.LatLng;
7
+ $Map: google.maps.Map;
8
+ $AdvancedMarkerElement: google.maps.AdvancedMarkerElement;
9
9
  }
10
10
  }
11
11
 
12
12
 
13
13
  export default defineNuxtPlugin(async (nuxtApp) => {
14
+ if (!import.meta.client) return;
15
+
14
16
  const runtimeConfig = useRuntimeConfig();
15
17
  setOptions({
16
18
  key: runtimeConfig.public.googleMapsApiKey,