@community-release/nx-ui 0.0.33 → 0.0.35
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.d.mts +0 -1
- package/dist/module.d.ts +0 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +0 -1
- package/dist/runtime/components/helpers/wait.d.ts +2 -0
- package/dist/runtime/components/helpers/wait.mjs +1 -0
- package/dist/runtime/components/map/index.vue +9 -9
- package/dist/runtime/components/map/location/nearest.vue +18 -2
- package/dist/runtime/components/map/openlayers/index.vue +43 -25
- package/dist/runtime/components/map/store.d.ts +9 -6
- package/dist/runtime/components/map/store.mjs +19 -10
- package/dist/runtime/components/map/zoom.vue +12 -2
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (ms = 0) => new Promise(r => {setTimeout(r, ms)})
|
|
@@ -77,15 +77,15 @@ const props = defineProps({
|
|
|
77
77
|
},
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
store.
|
|
81
|
-
store.
|
|
82
|
-
store.
|
|
83
|
-
store.
|
|
84
|
-
store.
|
|
85
|
-
store.
|
|
86
|
-
store.
|
|
87
|
-
store.
|
|
88
|
-
store.
|
|
80
|
+
store.coord = props.coord;
|
|
81
|
+
store.zoom = props.zoom;
|
|
82
|
+
store.zoomMin = props.zoomMin;
|
|
83
|
+
store.zoomMax = props.zoomMax;
|
|
84
|
+
store.deviceZoom = props.deviceZoom;
|
|
85
|
+
store.markers = props.markers;
|
|
86
|
+
store.markerImage = props.markerImage;
|
|
87
|
+
store.markerActiveImage = props.markerActiveImage;
|
|
88
|
+
store.markerDisabledImage = props.markerDisabledImage;
|
|
89
89
|
|
|
90
90
|
watch(() => props.disabledMarkers, (v) => {
|
|
91
91
|
store.setDisabledMarkers(v);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { ref } from 'vue';
|
|
13
13
|
import UiLoading from '../../loading.vue';
|
|
14
14
|
import { useMapStore } from '../store';
|
|
15
|
+
import wait from '../../helpers/wait';
|
|
15
16
|
|
|
16
17
|
// Data
|
|
17
18
|
const props = defineProps({
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
type: Array
|
|
29
30
|
},
|
|
30
31
|
});
|
|
32
|
+
const emit = defineEmits(['error']);
|
|
31
33
|
const store = useMapStore();
|
|
32
34
|
const loading = ref(false);
|
|
33
35
|
let cachedPosition = null;
|
|
@@ -65,7 +67,11 @@
|
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
let clickInProcess = false;
|
|
68
71
|
async function handleClick() {
|
|
72
|
+
if (clickInProcess) return;
|
|
73
|
+
clickInProcess = true;
|
|
74
|
+
|
|
69
75
|
try {
|
|
70
76
|
// If cache not exist or it's older than 1 minute
|
|
71
77
|
if (!cachedPosition || Date.now() - cachedTime > 60000) {
|
|
@@ -86,14 +92,24 @@
|
|
|
86
92
|
);
|
|
87
93
|
|
|
88
94
|
// Set coord and zoom
|
|
89
|
-
|
|
90
|
-
store.
|
|
95
|
+
// Pan to user location
|
|
96
|
+
store.setCoord(cachedPosition, 750);
|
|
97
|
+
store.setZoom(14, 750);
|
|
98
|
+
|
|
99
|
+
await wait(2000);
|
|
100
|
+
|
|
101
|
+
// Pan to nearest marker location
|
|
102
|
+
store.setCoord(nearest.coord, 1500);
|
|
103
|
+
store.setZoom(nearest?.zoom ? nearest.zoom : 14, 1500);
|
|
91
104
|
} catch (err) {
|
|
92
105
|
console.log('handleClick err', err);
|
|
106
|
+
|
|
107
|
+
emit('error', 'error-geo-not-enabled-on-device');
|
|
93
108
|
}
|
|
94
109
|
|
|
95
110
|
store.setSelectedMarker(null);
|
|
96
111
|
loading.value = false;
|
|
112
|
+
clickInProcess = false;
|
|
97
113
|
}
|
|
98
114
|
</script>
|
|
99
115
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="component-ui-map-openlayer component-ui-map-engine">
|
|
2
|
+
<div class="component-ui-map-openlayer component-ui-map-engine" :class="{'tag-user-position': userCoord.length}">
|
|
3
3
|
<div class="map" ref="refMap"></div>
|
|
4
4
|
<div style="display:none">
|
|
5
5
|
<div id="user-position-marker"></div>
|
|
@@ -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,
|
|
@@ -84,18 +86,23 @@
|
|
|
84
86
|
redrawMarkers();
|
|
85
87
|
});
|
|
86
88
|
|
|
87
|
-
// Watch coord
|
|
88
|
-
watch([requestCoordChange,
|
|
89
|
-
if (!
|
|
89
|
+
// Watch coord or zoom change
|
|
90
|
+
watch([requestCoordChange, requestZoomChange], () => {
|
|
91
|
+
if (!requestCoordChange.value && !requestZoomChange.value) return;
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
console.log('Watch coord or zoom change');
|
|
92
94
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
view.animate({center: coord, duration: 300});
|
|
95
|
+
const options = {
|
|
96
|
+
duration: cameraDuration.value
|
|
97
|
+
};
|
|
97
98
|
|
|
98
|
-
requestCoordChange.value =
|
|
99
|
+
if (requestCoordChange.value) options.center = fromLonLat(coord.value);
|
|
100
|
+
if (requestZoomChange.value) options.zoom = zoom.value;
|
|
101
|
+
|
|
102
|
+
view.animate(options, () => {
|
|
103
|
+
requestCoordChange.value = false;
|
|
104
|
+
requestZoomChange.value = false;
|
|
105
|
+
});
|
|
99
106
|
});
|
|
100
107
|
|
|
101
108
|
// Watch user coord
|
|
@@ -103,20 +110,20 @@
|
|
|
103
110
|
userPositionMarker.setPosition(fromLonLat(v));
|
|
104
111
|
});
|
|
105
112
|
|
|
106
|
-
// Watch zoom
|
|
107
|
-
watch(zoom, (v) => {
|
|
108
|
-
|
|
113
|
+
// // Watch zoom
|
|
114
|
+
// watch(zoom, (v) => {
|
|
115
|
+
// const currentZoom = view.getZoom();
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
// if (currentZoom === v) return;
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
119
|
+
// if (initialized)
|
|
120
|
+
// view.animate({
|
|
121
|
+
// zoom: v,
|
|
122
|
+
// duration: 300
|
|
123
|
+
// });
|
|
124
|
+
// else
|
|
125
|
+
// view.setZoom(v);
|
|
126
|
+
// });
|
|
120
127
|
|
|
121
128
|
const payload = {
|
|
122
129
|
store,
|
|
@@ -339,8 +346,6 @@
|
|
|
339
346
|
}, 50);
|
|
340
347
|
});
|
|
341
348
|
|
|
342
|
-
initialized = true;
|
|
343
|
-
|
|
344
349
|
// Handle map marker click
|
|
345
350
|
map.on('click', (e) => {
|
|
346
351
|
cluster.getFeatures(e.pixel).then((clickedFeatures) => {
|
|
@@ -367,7 +372,12 @@
|
|
|
367
372
|
});
|
|
368
373
|
});
|
|
369
374
|
|
|
370
|
-
map.on('loadend', () => {
|
|
375
|
+
map.on('loadend', () => {
|
|
376
|
+
if (initialized) return;
|
|
377
|
+
|
|
378
|
+
initialized = true;
|
|
379
|
+
emit('initialized', payload);
|
|
380
|
+
});
|
|
371
381
|
}
|
|
372
382
|
|
|
373
383
|
// Hooks
|
|
@@ -468,6 +478,14 @@
|
|
|
468
478
|
|
|
469
479
|
#user-position-marker {
|
|
470
480
|
.mix-pulsar;
|
|
481
|
+
|
|
482
|
+
display: none;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
&.tag-user-position {
|
|
486
|
+
#user-position-marker {
|
|
487
|
+
display: block;
|
|
488
|
+
}
|
|
471
489
|
}
|
|
472
490
|
}
|
|
473
491
|
</style>
|
|
@@ -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;
|
|
@@ -22,9 +24,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
|
22
24
|
}, {
|
|
23
25
|
/**
|
|
24
26
|
* Set map zoom
|
|
25
|
-
* @param {number}
|
|
27
|
+
* @param {number} zoom
|
|
28
|
+
* @param {number} duration
|
|
26
29
|
*/
|
|
27
|
-
setZoom(
|
|
30
|
+
setZoom(zoom: number, duration?: number): void;
|
|
28
31
|
/**
|
|
29
32
|
* Set min map zoom
|
|
30
33
|
* @param {number} v
|
|
@@ -41,10 +44,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
|
41
44
|
zoomOut(): void;
|
|
42
45
|
/**
|
|
43
46
|
* Set map coord
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {number}
|
|
47
|
+
* @param {number} coord
|
|
48
|
+
* @param {number} duration
|
|
46
49
|
*/
|
|
47
|
-
setCoord(
|
|
50
|
+
setCoord(coord: number, duration?: number): void;
|
|
48
51
|
/**
|
|
49
52
|
* Set user coord
|
|
50
53
|
* @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,
|
|
@@ -41,10 +42,13 @@ export const useMapStore = defineStore('map', {
|
|
|
41
42
|
actions: {
|
|
42
43
|
/**
|
|
43
44
|
* Set map zoom
|
|
44
|
-
* @param {number}
|
|
45
|
+
* @param {number} zoom
|
|
46
|
+
* @param {number} duration
|
|
45
47
|
*/
|
|
46
|
-
setZoom(
|
|
47
|
-
this.zoom =
|
|
48
|
+
setZoom(zoom, duration = 300) {
|
|
49
|
+
this.zoom = zoom;
|
|
50
|
+
this.cameraDuration = duration;
|
|
51
|
+
this.requestZoomChange = true;
|
|
48
52
|
},
|
|
49
53
|
|
|
50
54
|
/**
|
|
@@ -72,6 +76,8 @@ export const useMapStore = defineStore('map', {
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
this.zoom++;
|
|
79
|
+
this.cameraDuration = 300;
|
|
80
|
+
this.requestZoomChange = true;
|
|
75
81
|
},
|
|
76
82
|
|
|
77
83
|
/** Map zoom out */
|
|
@@ -83,16 +89,19 @@ export const useMapStore = defineStore('map', {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
this.zoom--;
|
|
92
|
+
this.cameraDuration = 300;
|
|
93
|
+
this.requestZoomChange = true;
|
|
86
94
|
},
|
|
87
95
|
|
|
88
96
|
/**
|
|
89
97
|
* Set map coord
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {number}
|
|
98
|
+
* @param {number} coord
|
|
99
|
+
* @param {number} duration
|
|
92
100
|
*/
|
|
93
|
-
setCoord(
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
101
|
+
setCoord(coord, duration = 300) {
|
|
102
|
+
this.coord = coord;
|
|
103
|
+
this.cameraDuration = duration;
|
|
104
|
+
this.requestCoordChange = true;
|
|
96
105
|
},
|
|
97
106
|
|
|
98
107
|
/**
|
|
@@ -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
|
}
|