@mixd-id/web-scaffold 0.1.2301231367 → 0.1.2301231369

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.2301231367",
4
+ "version": "0.1.2301231369",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div :class="$style.comp">
3
- <div ref="map" class="flex-1"></div>
3
+ <div v-if="apiKey" ref="map" class="flex-1"></div>
4
+ <div v-else class="flex-1 flex items-center justify-center text-text-400">{{ $t('Google maps api required') }}</div>
4
5
  </div>
5
6
  </template>
6
7
 
@@ -12,7 +13,8 @@ export default{
12
13
 
13
14
  props: {
14
15
  data: Array,
15
- radius: Number
16
+ config: Object,
17
+ apiKey: String
16
18
  },
17
19
 
18
20
  data(){
@@ -28,26 +30,122 @@ export default{
28
30
  methods: {
29
31
 
30
32
  load(){
33
+ if(!this.apiKey) return
31
34
 
32
35
  if(!Array.isArray(this.data) || this.data.length < 1)
33
36
  return
34
37
 
35
38
  const loader = new Loader({
36
- apiKey: "AIzaSyBmzMlmrR5St-njtN--64y_oLTa9FDLYfQ"
39
+ apiKey: this.apiKey // "AIzaSyBmzMlmrR5St-njtN--64y_oLTa9FDLYfQ"
37
40
  })
38
41
 
39
42
  loader.load()
40
43
  .then(async () => {
44
+
41
45
  const { Map } = await google.maps.importLibrary([ "maps" ]);
42
46
  await google.maps.importLibrary("visualization", ["HeatmapLayer"]);
43
47
 
44
- var center = new google.maps.LatLng(-6.2088, 106.8456);
48
+ var center = new google.maps.LatLng(
49
+ this.config.center ? this.config.center[0] : -6.2088,
50
+ this.config.center ? this.config.center[1] : 106.8456);
45
51
 
46
52
  this.map = new Map(this.$refs.map, {
47
53
  center: center,
48
- zoom: 7,
54
+ zoom: this.config.zoom ?? 7,
49
55
  mapTypeId: 'roadmap',
50
- streetViewControl: false
56
+ streetViewControl: false,
57
+ keyboardShortcuts: false,
58
+ styles: [
59
+ { elementType: "geometry", stylers: [{ color: "#242f3e" }] },
60
+ { elementType: "labels.text.stroke", stylers: [{ color: "#242f3e" }] },
61
+ { elementType: "labels.text.fill", stylers: [{ color: "#746855" }] },
62
+ {
63
+ featureType: "administrative.locality",
64
+ elementType: "labels.text.fill",
65
+ stylers: [{ color: "#d59563" }],
66
+ },
67
+ {
68
+ featureType: "poi",
69
+ elementType: "labels.text.fill",
70
+ stylers: [{ color: "#d59563" }],
71
+ },
72
+ {
73
+ featureType: "poi.park",
74
+ elementType: "geometry",
75
+ stylers: [{ color: "#263c3f" }],
76
+ },
77
+ {
78
+ featureType: "poi.park",
79
+ elementType: "labels.text.fill",
80
+ stylers: [{ color: "#6b9a76" }],
81
+ },
82
+ {
83
+ featureType: "road",
84
+ elementType: "geometry",
85
+ stylers: [{ color: "#38414e" }],
86
+ },
87
+ {
88
+ featureType: "road",
89
+ elementType: "geometry.stroke",
90
+ stylers: [{ color: "#212a37" }],
91
+ },
92
+ {
93
+ featureType: "road",
94
+ elementType: "labels.text.fill",
95
+ stylers: [{ color: "#9ca5b3" }],
96
+ },
97
+ {
98
+ featureType: "road.highway",
99
+ elementType: "geometry",
100
+ stylers: [{ color: "#746855" }],
101
+ },
102
+ {
103
+ featureType: "road.highway",
104
+ elementType: "geometry.stroke",
105
+ stylers: [{ color: "#1f2835" }],
106
+ },
107
+ {
108
+ featureType: "road.highway",
109
+ elementType: "labels.text.fill",
110
+ stylers: [{ color: "#f3d19c" }],
111
+ },
112
+ {
113
+ featureType: "transit",
114
+ elementType: "geometry",
115
+ stylers: [{ color: "#2f3948" }],
116
+ },
117
+ {
118
+ featureType: "transit.station",
119
+ elementType: "labels.text.fill",
120
+ stylers: [{ color: "#d59563" }],
121
+ },
122
+ {
123
+ featureType: "water",
124
+ elementType: "geometry",
125
+ stylers: [{ color: "#17263c" }],
126
+ },
127
+ {
128
+ featureType: "water",
129
+ elementType: "labels.text.fill",
130
+ stylers: [{ color: "#515c6d" }],
131
+ },
132
+ {
133
+ featureType: "water",
134
+ elementType: "labels.text.stroke",
135
+ stylers: [{ color: "#17263c" }],
136
+ },
137
+ ]
138
+ });
139
+
140
+ google.maps.event.addListener(this.map, 'zoom_changed', () => {
141
+ this.config.zoom = this.map.getZoom();
142
+ });
143
+
144
+ google.maps.event.addListener(this.map, 'center_changed', () => {
145
+ this.config.center = [
146
+ this.map.getCenter().lat(),
147
+ this.map.getCenter().lng()
148
+ ]
51
149
  });
52
150
 
53
151
  var heatMapData = [
@@ -69,17 +167,19 @@ export default{
69
167
  ];
70
168
 
71
169
  this.data.forEach((item) => {
72
- heatMapData.push({
73
- location: new google.maps.LatLng(item[0], item[1]),
74
- weight: item[2]
75
- })
170
+ if(item[0] && item[1] && item[2]){
171
+ heatMapData.push({
172
+ location: new google.maps.LatLng(item[0], item[1]),
173
+ weight: item[2]
174
+ })
175
+ }
76
176
  })
77
177
 
78
178
  var heatmap = new google.maps.visualization.HeatmapLayer({
79
179
  data: heatMapData,
80
180
  dissipating: true
81
181
  });
82
- heatmap.set('radius', this.radius ?? 12)
182
+ heatmap.set('radius', parseInt(this.config.mapRadius ?? 12))
83
183
  heatmap.setMap(this.map);
84
184
 
85
185
  const gradient = [
@@ -100,10 +200,18 @@ export default{
100
200
  ];
101
201
  heatmap.set("gradient", gradient);
102
202
 
103
- console.log('Gmap, data count:', this.data.length)
203
+ //console.log('Gmap, data count:', this.data.length)
104
204
  });
105
205
  }
106
206
 
207
+ },
208
+
209
+ watch: {
210
+
211
+ data(){
212
+ this.load()
213
+ }
214
+
107
215
  }
108
216
 
109
217
  }