@community-release/nx-ui 0.0.33 → 0.0.34
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/location/nearest.vue +15 -1
- package/dist/runtime/components/map/openlayers/index.vue +25 -8
- 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)})
|
|
@@ -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,22 @@
|
|
|
86
92
|
);
|
|
87
93
|
|
|
88
94
|
// Set coord and zoom
|
|
89
|
-
store.setCoord(
|
|
95
|
+
store.setCoord(cachedPosition, 750);
|
|
96
|
+
store.setZoom(14);
|
|
97
|
+
|
|
98
|
+
await wait(2000);
|
|
99
|
+
|
|
100
|
+
store.setCoord(nearest.coord, 1500);
|
|
90
101
|
store.setZoom(nearest?.zoom ? nearest.zoom : 14);
|
|
91
102
|
} catch (err) {
|
|
92
103
|
console.log('handleClick err', err);
|
|
104
|
+
|
|
105
|
+
emit('error', 'error-geo-not-enabled-on-device');
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
store.setSelectedMarker(null);
|
|
96
109
|
loading.value = false;
|
|
110
|
+
clickInProcess = false;
|
|
97
111
|
}
|
|
98
112
|
</script>
|
|
99
113
|
|
|
@@ -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>
|
|
@@ -86,14 +86,20 @@
|
|
|
86
86
|
|
|
87
87
|
// Watch coord
|
|
88
88
|
watch([requestCoordChange, coord], (v) => {
|
|
89
|
-
|
|
89
|
+
const req = v[0];
|
|
90
|
+
|
|
91
|
+
if (!req) return;
|
|
90
92
|
|
|
91
93
|
const coord = fromLonLat(v[1]);
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
// If req === 1 then set coord instantly
|
|
96
|
+
if (req === 1) {
|
|
94
97
|
view.setCenter(coord);
|
|
95
|
-
else
|
|
96
|
-
|
|
98
|
+
// If req === 2 then set coord in default duration, else treat req as duration time in ms
|
|
99
|
+
} else {
|
|
100
|
+
const duration = req === 2 ? 300 : req;
|
|
101
|
+
view.animate({center: coord, duration});
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
requestCoordChange.value = 0;
|
|
99
105
|
});
|
|
@@ -339,8 +345,6 @@
|
|
|
339
345
|
}, 50);
|
|
340
346
|
});
|
|
341
347
|
|
|
342
|
-
initialized = true;
|
|
343
|
-
|
|
344
348
|
// Handle map marker click
|
|
345
349
|
map.on('click', (e) => {
|
|
346
350
|
cluster.getFeatures(e.pixel).then((clickedFeatures) => {
|
|
@@ -367,7 +371,12 @@
|
|
|
367
371
|
});
|
|
368
372
|
});
|
|
369
373
|
|
|
370
|
-
map.on('loadend', () => {
|
|
374
|
+
map.on('loadend', () => {
|
|
375
|
+
if (initialized) return;
|
|
376
|
+
|
|
377
|
+
initialized = true;
|
|
378
|
+
emit('initialized', payload);
|
|
379
|
+
});
|
|
371
380
|
}
|
|
372
381
|
|
|
373
382
|
// Hooks
|
|
@@ -468,6 +477,14 @@
|
|
|
468
477
|
|
|
469
478
|
#user-position-marker {
|
|
470
479
|
.mix-pulsar;
|
|
480
|
+
|
|
481
|
+
display: none;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
&.tag-user-position {
|
|
485
|
+
#user-position-marker {
|
|
486
|
+
display: block;
|
|
487
|
+
}
|
|
471
488
|
}
|
|
472
489
|
}
|
|
473
490
|
</style>
|