@community-release/nx-ui 0.0.34 → 0.0.36
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/dist/module.json +1 -1
- package/dist/runtime/components/map/index.vue +19 -9
- package/dist/runtime/components/map/location/nearest.vue +7 -4
- package/dist/runtime/components/map/openlayers/index.vue +46 -32
- package/dist/runtime/components/map/props.json +2 -1
- package/dist/runtime/components/map/store.d.ts +11 -6
- package/dist/runtime/components/map/store.mjs +21 -10
- package/dist/runtime/components/map/zoom.vue +12 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -75,17 +75,27 @@ const props = defineProps({
|
|
|
75
75
|
default: '',
|
|
76
76
|
type: String
|
|
77
77
|
},
|
|
78
|
+
clusterColor: {
|
|
79
|
+
default: comProps.clusterColor,
|
|
80
|
+
type: String
|
|
81
|
+
},
|
|
82
|
+
disabledClusterColor: {
|
|
83
|
+
default: comProps.disabledClusterColor,
|
|
84
|
+
type: String
|
|
85
|
+
},
|
|
78
86
|
});
|
|
79
87
|
|
|
80
|
-
store.
|
|
81
|
-
store.
|
|
82
|
-
store.
|
|
83
|
-
store.
|
|
84
|
-
store.
|
|
85
|
-
store.
|
|
86
|
-
store.
|
|
87
|
-
store.
|
|
88
|
-
store.
|
|
88
|
+
store.coord = props.coord;
|
|
89
|
+
store.zoom = props.zoom;
|
|
90
|
+
store.zoomMin = props.zoomMin;
|
|
91
|
+
store.zoomMax = props.zoomMax;
|
|
92
|
+
store.deviceZoom = props.deviceZoom;
|
|
93
|
+
store.markers = props.markers;
|
|
94
|
+
store.markerImage = props.markerImage;
|
|
95
|
+
store.markerActiveImage = props.markerActiveImage;
|
|
96
|
+
store.markerDisabledImage = props.markerDisabledImage;
|
|
97
|
+
store.clusterColor = props.clusterColor;
|
|
98
|
+
store.disabledClusterColor = props.disabledClusterColor;
|
|
89
99
|
|
|
90
100
|
watch(() => props.disabledMarkers, (v) => {
|
|
91
101
|
store.setDisabledMarkers(v);
|
|
@@ -71,7 +71,9 @@
|
|
|
71
71
|
async function handleClick() {
|
|
72
72
|
if (clickInProcess) return;
|
|
73
73
|
clickInProcess = true;
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
store.setSelectedMarker(null);
|
|
76
|
+
|
|
75
77
|
try {
|
|
76
78
|
// If cache not exist or it's older than 1 minute
|
|
77
79
|
if (!cachedPosition || Date.now() - cachedTime > 60000) {
|
|
@@ -92,20 +94,21 @@
|
|
|
92
94
|
);
|
|
93
95
|
|
|
94
96
|
// Set coord and zoom
|
|
97
|
+
// Pan to user location
|
|
95
98
|
store.setCoord(cachedPosition, 750);
|
|
96
|
-
store.setZoom(14);
|
|
99
|
+
store.setZoom(14, 750);
|
|
97
100
|
|
|
98
101
|
await wait(2000);
|
|
99
102
|
|
|
103
|
+
// Pan to nearest marker location
|
|
100
104
|
store.setCoord(nearest.coord, 1500);
|
|
101
|
-
store.setZoom(nearest?.zoom ? nearest.zoom : 14);
|
|
105
|
+
store.setZoom(nearest?.zoom ? nearest.zoom : 14, 1500);
|
|
102
106
|
} catch (err) {
|
|
103
107
|
console.log('handleClick err', err);
|
|
104
108
|
|
|
105
109
|
emit('error', 'error-geo-not-enabled-on-device');
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
store.setSelectedMarker(null);
|
|
109
112
|
loading.value = false;
|
|
110
113
|
clickInProcess = false;
|
|
111
114
|
}
|
|
@@ -61,8 +61,10 @@
|
|
|
61
61
|
// Store
|
|
62
62
|
const store = useMapStore();
|
|
63
63
|
const {
|
|
64
|
+
cameraDuration,
|
|
64
65
|
requestCoordChange,
|
|
65
66
|
coord,
|
|
67
|
+
requestZoomChange,
|
|
66
68
|
zoom,
|
|
67
69
|
zoomMin,
|
|
68
70
|
zoomMax,
|
|
@@ -73,6 +75,8 @@
|
|
|
73
75
|
markerActiveImage,
|
|
74
76
|
markerDisabledImage,
|
|
75
77
|
selectedMarker,
|
|
78
|
+
clusterColor,
|
|
79
|
+
disabledClusterColor,
|
|
76
80
|
userCoord
|
|
77
81
|
} = storeToRefs(store);
|
|
78
82
|
|
|
@@ -84,24 +88,21 @@
|
|
|
84
88
|
redrawMarkers();
|
|
85
89
|
});
|
|
86
90
|
|
|
87
|
-
// Watch coord
|
|
88
|
-
watch([requestCoordChange,
|
|
89
|
-
|
|
91
|
+
// Watch coord or zoom change
|
|
92
|
+
watch([requestCoordChange, requestZoomChange], () => {
|
|
93
|
+
if (!requestCoordChange.value && !requestZoomChange.value) return;
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
const options = {
|
|
96
|
+
duration: cameraDuration.value
|
|
97
|
+
};
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
if (requestCoordChange.value) options.center = fromLonLat(coord.value);
|
|
100
|
+
if (requestZoomChange.value) options.zoom = zoom.value;
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else {
|
|
100
|
-
const duration = req === 2 ? 300 : req;
|
|
101
|
-
view.animate({center: coord, duration});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
requestCoordChange.value = 0;
|
|
102
|
+
view.animate(options, () => {
|
|
103
|
+
requestCoordChange.value = false;
|
|
104
|
+
requestZoomChange.value = false;
|
|
105
|
+
});
|
|
105
106
|
});
|
|
106
107
|
|
|
107
108
|
// Watch user coord
|
|
@@ -109,20 +110,20 @@
|
|
|
109
110
|
userPositionMarker.setPosition(fromLonLat(v));
|
|
110
111
|
});
|
|
111
112
|
|
|
112
|
-
// Watch zoom
|
|
113
|
-
watch(zoom, (v) => {
|
|
114
|
-
|
|
113
|
+
// // Watch zoom
|
|
114
|
+
// watch(zoom, (v) => {
|
|
115
|
+
// const currentZoom = view.getZoom();
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
// if (currentZoom === v) return;
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
119
|
+
// if (initialized)
|
|
120
|
+
// view.animate({
|
|
121
|
+
// zoom: v,
|
|
122
|
+
// duration: 300
|
|
123
|
+
// });
|
|
124
|
+
// else
|
|
125
|
+
// view.setZoom(v);
|
|
126
|
+
// });
|
|
126
127
|
|
|
127
128
|
const payload = {
|
|
128
129
|
store,
|
|
@@ -238,18 +239,31 @@
|
|
|
238
239
|
const isSelected = markerId === selectedMarker.value?.id;
|
|
239
240
|
|
|
240
241
|
style = styleCache[isSelected ? 'active' : (isDisabled ? 'disabled' : 'default')];
|
|
242
|
+
|
|
241
243
|
// If cluster
|
|
242
244
|
} else {
|
|
245
|
+
let isDisabled = false;
|
|
246
|
+
|
|
247
|
+
// Check if cluster have disabled markers
|
|
248
|
+
for (let item of allFeatures) {
|
|
249
|
+
if (disabledMarkers.value.includes(item.attributes.id)) {
|
|
250
|
+
isDisabled = true;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const cacheId = size + (isDisabled ? 'd' : '');
|
|
256
|
+
|
|
243
257
|
// Have cache
|
|
244
|
-
if (styleCache[
|
|
245
|
-
style = styleCache[
|
|
258
|
+
if (styleCache[cacheId]) {
|
|
259
|
+
style = styleCache[cacheId];
|
|
246
260
|
// No cache
|
|
247
261
|
} else {
|
|
248
262
|
style = new Style({
|
|
249
263
|
image: new CircleStyle({
|
|
250
264
|
radius: 14,
|
|
251
265
|
fill: new Fill({
|
|
252
|
-
color:
|
|
266
|
+
color: isDisabled ? disabledClusterColor.value : clusterColor.value,
|
|
253
267
|
}),
|
|
254
268
|
}),
|
|
255
269
|
text: new Text({
|
|
@@ -261,7 +275,7 @@
|
|
|
261
275
|
}),
|
|
262
276
|
});
|
|
263
277
|
|
|
264
|
-
styleCache[
|
|
278
|
+
styleCache[cacheId] = style;
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
|
|
@@ -373,7 +387,7 @@
|
|
|
373
387
|
|
|
374
388
|
map.on('loadend', () => {
|
|
375
389
|
if (initialized) return;
|
|
376
|
-
|
|
390
|
+
|
|
377
391
|
initialized = true;
|
|
378
392
|
emit('initialized', payload);
|
|
379
393
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
2
|
-
|
|
2
|
+
cameraDuration: number;
|
|
3
|
+
requestCoordChange: boolean;
|
|
3
4
|
coord: never[];
|
|
5
|
+
requestZoomChange: boolean;
|
|
4
6
|
zoom: number;
|
|
5
7
|
zoomMin: number;
|
|
6
8
|
zoomMax: number;
|
|
@@ -11,6 +13,8 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
|
11
13
|
markers: never[];
|
|
12
14
|
selectedMarker: null;
|
|
13
15
|
disabledMarkers: never[];
|
|
16
|
+
clusterColor: string;
|
|
17
|
+
disabledClusterColor: string;
|
|
14
18
|
userCoord: never[];
|
|
15
19
|
}, {
|
|
16
20
|
/**
|
|
@@ -22,9 +26,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
|
22
26
|
}, {
|
|
23
27
|
/**
|
|
24
28
|
* Set map zoom
|
|
25
|
-
* @param {number}
|
|
29
|
+
* @param {number} zoom
|
|
30
|
+
* @param {number} duration
|
|
26
31
|
*/
|
|
27
|
-
setZoom(
|
|
32
|
+
setZoom(zoom: number, duration?: number): void;
|
|
28
33
|
/**
|
|
29
34
|
* Set min map zoom
|
|
30
35
|
* @param {number} v
|
|
@@ -41,10 +46,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
|
41
46
|
zoomOut(): void;
|
|
42
47
|
/**
|
|
43
48
|
* Set map coord
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {number}
|
|
49
|
+
* @param {number} coord
|
|
50
|
+
* @param {number} duration
|
|
46
51
|
*/
|
|
47
|
-
setCoord(
|
|
52
|
+
setCoord(coord: number, duration?: number): void;
|
|
48
53
|
/**
|
|
49
54
|
* Set user coord
|
|
50
55
|
* @param {MapCoord} v
|
|
@@ -18,9 +18,10 @@ import { defineStore } from 'pinia';
|
|
|
18
18
|
export const useMapStore = defineStore('map', {
|
|
19
19
|
state: () => {
|
|
20
20
|
return {
|
|
21
|
-
|
|
21
|
+
cameraDuration: 0,
|
|
22
|
+
requestCoordChange: false,
|
|
22
23
|
coord: [],
|
|
23
|
-
|
|
24
|
+
requestZoomChange: false,
|
|
24
25
|
zoom: 8,
|
|
25
26
|
zoomMin: 8,
|
|
26
27
|
zoomMax: 18,
|
|
@@ -33,6 +34,8 @@ export const useMapStore = defineStore('map', {
|
|
|
33
34
|
markers: [],
|
|
34
35
|
selectedMarker: null,
|
|
35
36
|
disabledMarkers: [],
|
|
37
|
+
clusterColor: '',
|
|
38
|
+
disabledClusterColor: '',
|
|
36
39
|
|
|
37
40
|
userCoord: []
|
|
38
41
|
}
|
|
@@ -41,10 +44,13 @@ export const useMapStore = defineStore('map', {
|
|
|
41
44
|
actions: {
|
|
42
45
|
/**
|
|
43
46
|
* Set map zoom
|
|
44
|
-
* @param {number}
|
|
47
|
+
* @param {number} zoom
|
|
48
|
+
* @param {number} duration
|
|
45
49
|
*/
|
|
46
|
-
setZoom(
|
|
47
|
-
this.zoom =
|
|
50
|
+
setZoom(zoom, duration = 300) {
|
|
51
|
+
this.zoom = zoom;
|
|
52
|
+
this.cameraDuration = duration;
|
|
53
|
+
this.requestZoomChange = true;
|
|
48
54
|
},
|
|
49
55
|
|
|
50
56
|
/**
|
|
@@ -72,6 +78,8 @@ export const useMapStore = defineStore('map', {
|
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
this.zoom++;
|
|
81
|
+
this.cameraDuration = 300;
|
|
82
|
+
this.requestZoomChange = true;
|
|
75
83
|
},
|
|
76
84
|
|
|
77
85
|
/** Map zoom out */
|
|
@@ -83,16 +91,19 @@ export const useMapStore = defineStore('map', {
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
this.zoom--;
|
|
94
|
+
this.cameraDuration = 300;
|
|
95
|
+
this.requestZoomChange = true;
|
|
86
96
|
},
|
|
87
97
|
|
|
88
98
|
/**
|
|
89
99
|
* Set map coord
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {number}
|
|
100
|
+
* @param {number} coord
|
|
101
|
+
* @param {number} duration
|
|
92
102
|
*/
|
|
93
|
-
setCoord(
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
103
|
+
setCoord(coord, duration = 300) {
|
|
104
|
+
this.coord = coord;
|
|
105
|
+
this.cameraDuration = duration;
|
|
106
|
+
this.requestCoordChange = true;
|
|
96
107
|
},
|
|
97
108
|
|
|
98
109
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="component-ui-map-zoom">
|
|
3
3
|
<div class="prepend"><slot /></div>
|
|
4
|
-
<ui-button @click="store.zoomIn" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
|
|
4
|
+
<ui-button @click="store.zoomIn" class="plus" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
|
|
5
5
|
<div class="separator"></div>
|
|
6
|
-
<ui-button @click="store.zoomOut" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
|
|
6
|
+
<ui-button @click="store.zoomOut" class="minus" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
@@ -54,6 +54,16 @@ const props = defineProps(['store']);
|
|
|
54
54
|
font-size: @com-text-large;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
.component-ui-button.plus .button-bg {
|
|
58
|
+
border-top-left-radius: @com-border-radius-default;
|
|
59
|
+
border-top-right-radius: @com-border-radius-default;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.component-ui-button.minus .button-bg {
|
|
63
|
+
border-bottom-left-radius: @com-border-radius-default;
|
|
64
|
+
border-bottom-right-radius: @com-border-radius-default;
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
.separator {
|
|
58
68
|
border-bottom: 1px solid @com-color-border;
|
|
59
69
|
}
|