@community-release/nx-ui 0.0.4 → 0.0.7
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 +7 -0
- package/dist/module.d.ts +7 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +230 -9
- package/dist/runtime/components/accordion.vue +221 -0
- package/dist/runtime/components/animated-number/animateValue.d.ts +13 -0
- package/dist/runtime/components/animated-number/animateValue.mjs +56 -0
- package/dist/runtime/components/animated-number/index.vue +43 -0
- package/dist/runtime/components/button/index.vue +360 -0
- package/dist/runtime/components/button/index.vue.d.ts +81 -0
- package/dist/runtime/components/button/props.json +6 -0
- package/dist/runtime/components/card.vue +138 -0
- package/dist/runtime/components/checkbox.vue +227 -0
- package/dist/runtime/components/countdown/index.vue +64 -0
- package/dist/runtime/components/countdown/props.json +6 -0
- package/dist/runtime/components/filter/index.vue +140 -0
- package/dist/runtime/components/filter/props.json +4 -0
- package/dist/runtime/components/grid.vue +169 -0
- package/dist/runtime/components/grid.vue.d.ts +56 -0
- package/dist/runtime/components/helpers/Countdown.d.ts +0 -0
- package/dist/runtime/components/helpers/Countdown.mjs +143 -0
- package/dist/runtime/components/helpers/getEventCoord.d.ts +7 -0
- package/dist/runtime/components/helpers/getEventCoord.mjs +16 -0
- package/dist/runtime/components/helpers/isImageExist.d.ts +6 -0
- package/dist/runtime/components/helpers/isImageExist.mjs +20 -0
- package/dist/runtime/components/helpers/isMobileDevice.d.ts +5 -0
- package/dist/runtime/components/helpers/isMobileDevice.mjs +12 -0
- package/dist/runtime/components/helpers/isWebKit.d.ts +5 -0
- package/dist/runtime/components/helpers/isWebKit.mjs +12 -0
- package/dist/runtime/components/helpers/uniq.d.ts +2 -0
- package/dist/runtime/components/helpers/uniq.mjs +1 -0
- package/dist/runtime/components/icons/check.svg +1 -0
- package/dist/runtime/components/icons/check.white.svg +1 -0
- package/dist/runtime/components/impulse-indicator.vue +139 -0
- package/dist/runtime/components/impulse-indicator.vue.d.ts +21 -0
- package/dist/runtime/components/input/index.vue +241 -0
- package/dist/runtime/components/input/props.json +5 -0
- package/dist/runtime/components/label.vue +33 -0
- package/dist/runtime/components/loading.vue +91 -0
- package/dist/runtime/components/map/device-zoom-switch.vue +160 -0
- package/dist/runtime/components/map/index.vue +135 -0
- package/dist/runtime/components/map/location/index.vue +109 -0
- package/dist/runtime/components/map/location/list.vue +54 -0
- package/dist/runtime/components/map/location/nearest.vue +88 -0
- package/dist/runtime/components/map/openlayers/index.vue +355 -0
- package/dist/runtime/components/map/props.json +5 -0
- package/dist/runtime/components/map/store.d.ts +114 -0
- package/dist/runtime/components/map/store.mjs +166 -0
- package/dist/runtime/components/map/zoom.vue +61 -0
- package/dist/runtime/components/notice/index.vue +63 -0
- package/dist/runtime/components/notice/item.vue +118 -0
- package/dist/runtime/components/notice/store.d.ts +27 -0
- package/dist/runtime/components/notice/store.mjs +46 -0
- package/dist/runtime/components/radio.vue +215 -0
- package/dist/runtime/components/select.vue +303 -0
- package/dist/runtime/components/static-map.vue +345 -0
- package/dist/runtime/components/styles/components.less +3 -0
- package/dist/runtime/components/styles/mixins.less +6 -0
- package/dist/runtime/components/textarea/index.vue +166 -0
- package/dist/runtime/components/textarea/props.json +4 -0
- package/dist/runtime/components/tooltip.vue +137 -0
- package/dist/runtime/plugins/methods.d.ts +2 -0
- package/dist/runtime/plugins/methods.mjs +20 -0
- package/dist/runtime/plugins/variables.d.ts +2 -0
- package/dist/runtime/plugins/variables.mjs +17 -0
- package/dist/types.d.mts +2 -11
- package/dist/types.d.ts +2 -11
- package/package.json +2 -2
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="component-ui-map-openlayer component-ui-map-engine">
|
|
3
|
+
<div class="map" ref="refMap"></div>
|
|
4
|
+
<slot />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
// import 'ol/ol.css';
|
|
10
|
+
|
|
11
|
+
// Imports
|
|
12
|
+
// Pinia store
|
|
13
|
+
import { storeToRefs } from 'pinia';
|
|
14
|
+
import { useMapStore } from '../store';
|
|
15
|
+
|
|
16
|
+
// Openlayers
|
|
17
|
+
import Feature from 'ol/Feature.js';
|
|
18
|
+
import Point from 'ol/geom/Point.js';
|
|
19
|
+
import {
|
|
20
|
+
Circle as CircleStyle,
|
|
21
|
+
Fill,
|
|
22
|
+
Style,
|
|
23
|
+
Text,
|
|
24
|
+
Icon
|
|
25
|
+
} from 'ol/style.js';
|
|
26
|
+
import { Cluster, OSM, Vector as VectorSource } from 'ol/source.js';
|
|
27
|
+
import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer.js';
|
|
28
|
+
import { boundingExtent } from 'ol/extent.js';
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
import Map from 'ol/Map.js';
|
|
32
|
+
import View from 'ol/View.js';
|
|
33
|
+
import { fromLonLat } from 'ol/proj.js';
|
|
34
|
+
import {
|
|
35
|
+
defaults as defaultInteractions,
|
|
36
|
+
MouseWheelZoom as mouseWheelZoomInteraction,
|
|
37
|
+
DragPan
|
|
38
|
+
} from 'ol/interaction.js';
|
|
39
|
+
import { platformModifierKeyOnly } from 'ol/events/condition.js';
|
|
40
|
+
import Kinetic from 'ol/Kinetic.js';
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// Data
|
|
44
|
+
const emit = defineEmits('initialized');
|
|
45
|
+
const refMap = ref(null);
|
|
46
|
+
let map = null;
|
|
47
|
+
let view = null;
|
|
48
|
+
let interactions = null;
|
|
49
|
+
let mouseWheelInt = null;
|
|
50
|
+
let initialized = false;
|
|
51
|
+
let features = [];
|
|
52
|
+
let cluster = null;
|
|
53
|
+
|
|
54
|
+
// Store
|
|
55
|
+
const store = useMapStore();
|
|
56
|
+
const {
|
|
57
|
+
coord,
|
|
58
|
+
zoom,
|
|
59
|
+
zoomMin,
|
|
60
|
+
zoomMax,
|
|
61
|
+
deviceZoom,
|
|
62
|
+
markers,
|
|
63
|
+
disabledMarkers,
|
|
64
|
+
markerImage,
|
|
65
|
+
markerActiveImage,
|
|
66
|
+
markerDisabledImage,
|
|
67
|
+
selectedMarker
|
|
68
|
+
} = storeToRefs(store);
|
|
69
|
+
|
|
70
|
+
watch(() => selectedMarker.value, (v) => {
|
|
71
|
+
redrawMarkers();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
watch(() => disabledMarkers.value, (v) => {
|
|
75
|
+
redrawMarkers();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Watch coord
|
|
79
|
+
watch(coord, (v) => { view.setCenter(fromLonLat(v)); });
|
|
80
|
+
|
|
81
|
+
// Watch zoom
|
|
82
|
+
watch(zoom, (v) => {
|
|
83
|
+
const currentZoom = view.getZoom();
|
|
84
|
+
|
|
85
|
+
if (currentZoom === v) return;
|
|
86
|
+
|
|
87
|
+
if (initialized)
|
|
88
|
+
view.animate({
|
|
89
|
+
zoom: v,
|
|
90
|
+
duration: 300
|
|
91
|
+
});
|
|
92
|
+
else
|
|
93
|
+
view.setZoom(v);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const payload = {
|
|
97
|
+
store,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Methods
|
|
101
|
+
function getMarkerData(id) {
|
|
102
|
+
let result = null;
|
|
103
|
+
|
|
104
|
+
if (id !== null) {
|
|
105
|
+
for (let item of markers.value) {
|
|
106
|
+
if (item.id === id) {
|
|
107
|
+
result = item;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Forced markers redraw */
|
|
117
|
+
async function redrawMarkers() {
|
|
118
|
+
await cluster.setStyle(cluster.getStyle());
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Create markers
|
|
123
|
+
* @returns {array} - features array (markers)
|
|
124
|
+
*/
|
|
125
|
+
function createMarkers() {
|
|
126
|
+
const result = [];
|
|
127
|
+
|
|
128
|
+
for (let item of markers.value) {
|
|
129
|
+
const feature = new Feature(new Point(fromLonLat(item.coord)));
|
|
130
|
+
|
|
131
|
+
feature.attributes = { id: item.id }; // Add payload data to markers
|
|
132
|
+
result.push(feature);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Create cluster
|
|
140
|
+
* @property {array} - features array (markers)
|
|
141
|
+
* @returns {VectorLayer} - Open Layers VectorLayer that work as cluster
|
|
142
|
+
*/
|
|
143
|
+
function createCluster(features) {
|
|
144
|
+
const clusterSource = new Cluster({
|
|
145
|
+
distance: 30,
|
|
146
|
+
minDistance: 15,
|
|
147
|
+
source: new VectorSource({
|
|
148
|
+
features // Markers
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const styleCache = {};
|
|
153
|
+
|
|
154
|
+
// Cache markers
|
|
155
|
+
if (markerImage.value) {
|
|
156
|
+
styleCache.default = new Style({
|
|
157
|
+
image: new Icon({ src: markerImage.value })
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
if (markerActiveImage.value) {
|
|
161
|
+
styleCache.active = new Style({
|
|
162
|
+
image: new Icon({ src: markerActiveImage.value })
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
styleCache.active = styleCache.default;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (markerDisabledImage.value) {
|
|
169
|
+
styleCache.disabled = new Style({
|
|
170
|
+
image: new Icon({ src: markerDisabledImage.value })
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
styleCache.disabled = styleCache.default;
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
styleCache.default = new Style({
|
|
177
|
+
image: new CircleStyle({
|
|
178
|
+
radius: 14,
|
|
179
|
+
fill: new Fill({ color: 'red' })
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
styleCache.active = new Style({
|
|
183
|
+
image: new CircleStyle({
|
|
184
|
+
radius: 14,
|
|
185
|
+
fill: new Fill({ color: 'green' })
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
styleCache.disabled = new Style({
|
|
189
|
+
image: new CircleStyle({
|
|
190
|
+
radius: 14,
|
|
191
|
+
fill: new Fill({ color: 'gray' })
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Markers style function
|
|
197
|
+
function style(feature) {
|
|
198
|
+
const allFeatures = feature.get('features');
|
|
199
|
+
const size = allFeatures.length;
|
|
200
|
+
|
|
201
|
+
let style;
|
|
202
|
+
|
|
203
|
+
// If one
|
|
204
|
+
if (size == 1) {
|
|
205
|
+
const markerId = allFeatures[0].attributes.id;
|
|
206
|
+
const isDisabled = disabledMarkers.value.includes(markerId);
|
|
207
|
+
const isSelected = markerId === selectedMarker.value?.id;
|
|
208
|
+
|
|
209
|
+
style = styleCache[isSelected ? 'active' : (isDisabled ? 'disabled' : 'default')];
|
|
210
|
+
// If cluster
|
|
211
|
+
} else {
|
|
212
|
+
// Have cache
|
|
213
|
+
if (styleCache[size]) {
|
|
214
|
+
style = styleCache[size];
|
|
215
|
+
// No cache
|
|
216
|
+
} else {
|
|
217
|
+
style = new Style({
|
|
218
|
+
image: new CircleStyle({
|
|
219
|
+
radius: 14,
|
|
220
|
+
fill: new Fill({
|
|
221
|
+
color: '#4b3aaa',
|
|
222
|
+
}),
|
|
223
|
+
}),
|
|
224
|
+
text: new Text({
|
|
225
|
+
font: '14px Arial, sans-serif',
|
|
226
|
+
text: size.toString(),
|
|
227
|
+
fill: new Fill({
|
|
228
|
+
color: '#fff',
|
|
229
|
+
}),
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
styleCache[size] = style;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return style;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return new VectorLayer({
|
|
241
|
+
source: clusterSource,
|
|
242
|
+
style
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Init map */
|
|
247
|
+
function initMap() {
|
|
248
|
+
features = createMarkers();
|
|
249
|
+
|
|
250
|
+
cluster = createCluster(features);
|
|
251
|
+
|
|
252
|
+
const raster = new TileLayer({
|
|
253
|
+
source: new OSM(),
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
view = new View({
|
|
257
|
+
center: fromLonLat(coord.value),
|
|
258
|
+
zoom: zoom.value,
|
|
259
|
+
minZoom: zoomMin.value,
|
|
260
|
+
maxZoom: zoomMax.value,
|
|
261
|
+
enableRotation: false,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
interactions = defaultInteractions({
|
|
265
|
+
mouseWheelZoom: false,
|
|
266
|
+
dragPan: false
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
interactions.extend([
|
|
270
|
+
new DragPan({
|
|
271
|
+
kinetic: new Kinetic(-0.005, 0.05, 100),
|
|
272
|
+
condition(e) {
|
|
273
|
+
if (e.originalEvent.pointerType !== 'touch') return true;
|
|
274
|
+
|
|
275
|
+
return deviceZoom.value || this.getPointerCount() === 2;
|
|
276
|
+
//return this.getPointerCount() === 2 || platformModifierKeyOnly(event);
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
]);
|
|
280
|
+
|
|
281
|
+
// Create map
|
|
282
|
+
map = new Map({
|
|
283
|
+
layers: [raster, cluster],
|
|
284
|
+
target: refMap.value,
|
|
285
|
+
interactions,
|
|
286
|
+
view,
|
|
287
|
+
projection: 'EPSG:3857',
|
|
288
|
+
controls: []
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Add mouse wheel interaction
|
|
292
|
+
mouseWheelInt = new mouseWheelZoomInteraction({
|
|
293
|
+
condition(e) {
|
|
294
|
+
return deviceZoom.value || platformModifierKeyOnly(e);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
map.addInteraction(mouseWheelInt);
|
|
298
|
+
|
|
299
|
+
// Watch map zoom
|
|
300
|
+
let t;
|
|
301
|
+
view.on('change:resolution', (e) => {
|
|
302
|
+
clearTimeout(t);
|
|
303
|
+
t = setTimeout(() => {
|
|
304
|
+
store.setZoom(view.getZoom());
|
|
305
|
+
}, 50);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
initialized = true;
|
|
309
|
+
|
|
310
|
+
// Handle map marker click
|
|
311
|
+
map.on('click', (e) => {
|
|
312
|
+
cluster.getFeatures(e.pixel).then((clickedFeatures) => {
|
|
313
|
+
let clickedOnMarker = false;
|
|
314
|
+
|
|
315
|
+
if (clickedFeatures.length) {
|
|
316
|
+
const features = clickedFeatures[0].get('features'); // Get clustered Coordinates
|
|
317
|
+
|
|
318
|
+
if (features.length > 1) {
|
|
319
|
+
// Zoom in
|
|
320
|
+
const extent = boundingExtent(
|
|
321
|
+
features.map((r) => r.getGeometry().getCoordinates()),
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
map.getView().fit(extent, { duration: 1000, padding: [100, 150, 100, 150] });
|
|
325
|
+
// Save marker id if clicked on marker
|
|
326
|
+
} else if (features.length == 1) {
|
|
327
|
+
store.setSelectedMarker(getMarkerData(features[0].attributes.id));
|
|
328
|
+
clickedOnMarker = true;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!clickedOnMarker) store.setSelectedMarker(null);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
map.on('loadend', () => { emit('initialized', payload); });
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Hooks
|
|
340
|
+
onMounted(() => {
|
|
341
|
+
initMap();
|
|
342
|
+
});
|
|
343
|
+
</script>
|
|
344
|
+
|
|
345
|
+
<style lang="less">
|
|
346
|
+
.component-ui-map-openlayer {
|
|
347
|
+
position: relative;
|
|
348
|
+
|
|
349
|
+
.map {
|
|
350
|
+
position: absolute;
|
|
351
|
+
inset: 0;
|
|
352
|
+
background: #add19e;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
</style>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export const useMapStore: import("pinia").StoreDefinition<"map", {
|
|
2
|
+
coord: never[];
|
|
3
|
+
zoom: number;
|
|
4
|
+
zoomMin: number;
|
|
5
|
+
zoomMax: number;
|
|
6
|
+
deviceZoom: boolean;
|
|
7
|
+
markerImage: string;
|
|
8
|
+
markerActiveImage: string;
|
|
9
|
+
markerDisabledImage: string;
|
|
10
|
+
markers: never[];
|
|
11
|
+
selectedMarker: null;
|
|
12
|
+
disabledMarkers: never[];
|
|
13
|
+
}, {
|
|
14
|
+
/**
|
|
15
|
+
* Get marker by id
|
|
16
|
+
* @param {string|number} id
|
|
17
|
+
* @returns MapMarker
|
|
18
|
+
*/
|
|
19
|
+
getMarker(state: {
|
|
20
|
+
coord: never[];
|
|
21
|
+
zoom: number;
|
|
22
|
+
zoomMin: number;
|
|
23
|
+
zoomMax: number;
|
|
24
|
+
deviceZoom: boolean;
|
|
25
|
+
markerImage: string;
|
|
26
|
+
markerActiveImage: string;
|
|
27
|
+
markerDisabledImage: string;
|
|
28
|
+
markers: never[];
|
|
29
|
+
selectedMarker: null;
|
|
30
|
+
disabledMarkers: never[];
|
|
31
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
32
|
+
coord: never[];
|
|
33
|
+
zoom: number;
|
|
34
|
+
zoomMin: number;
|
|
35
|
+
zoomMax: number;
|
|
36
|
+
deviceZoom: boolean;
|
|
37
|
+
markerImage: string;
|
|
38
|
+
markerActiveImage: string;
|
|
39
|
+
markerDisabledImage: string;
|
|
40
|
+
markers: never[];
|
|
41
|
+
selectedMarker: null;
|
|
42
|
+
disabledMarkers: never[];
|
|
43
|
+
}>): (id: any) => null;
|
|
44
|
+
}, {
|
|
45
|
+
/**
|
|
46
|
+
* Set map zoom
|
|
47
|
+
* @param {number} v
|
|
48
|
+
*/
|
|
49
|
+
setZoom(v: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set min map zoom
|
|
52
|
+
* @param {number} v
|
|
53
|
+
*/
|
|
54
|
+
setZoomMin(v: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* Set max map zoom
|
|
57
|
+
* @param {number} v
|
|
58
|
+
*/
|
|
59
|
+
setZoomMax(v: number): void;
|
|
60
|
+
/** Map zoom in */
|
|
61
|
+
zoomIn(): void;
|
|
62
|
+
/** Map zoom out */
|
|
63
|
+
zoomOut(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set map coord
|
|
66
|
+
* @param {MapCoord} v
|
|
67
|
+
*/
|
|
68
|
+
setCoord(v: any[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Enable/disable device zoom, if call withour params then toggle current state
|
|
71
|
+
* @param {boolean=} v
|
|
72
|
+
*/
|
|
73
|
+
setDeviceZoom(v?: boolean | undefined): void;
|
|
74
|
+
/**
|
|
75
|
+
* Set markers
|
|
76
|
+
* @param {MapMarker[]} v
|
|
77
|
+
*/
|
|
78
|
+
setMarkers(v: MapMarker[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Set selected marker
|
|
81
|
+
* @param {MapMarker} v
|
|
82
|
+
*/
|
|
83
|
+
setSelectedMarker(v: MapMarker): void;
|
|
84
|
+
/**
|
|
85
|
+
* Set disabled markers
|
|
86
|
+
* @param {MapMarker[]} v
|
|
87
|
+
*/
|
|
88
|
+
setDisabledMarkers(v: MapMarker[]): void;
|
|
89
|
+
/**
|
|
90
|
+
* Set marker image
|
|
91
|
+
* @param {string} v
|
|
92
|
+
*/
|
|
93
|
+
setMarkerImage(v: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Set marker active image
|
|
96
|
+
* @param {string} v
|
|
97
|
+
*/
|
|
98
|
+
setMarkerActiveImage(v: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Set marker disabled image
|
|
101
|
+
* @param {string} v
|
|
102
|
+
*/
|
|
103
|
+
setMarkerDisabledImage(v: string): void;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Map Coord
|
|
107
|
+
*/
|
|
108
|
+
export type MapCoord = any[];
|
|
109
|
+
/**
|
|
110
|
+
* Map Marker
|
|
111
|
+
*/
|
|
112
|
+
export type MapMarker = {
|
|
113
|
+
coord: any[];
|
|
114
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Coord
|
|
3
|
+
* @typedef MapCoord
|
|
4
|
+
* @type {array}
|
|
5
|
+
* @property {string|number} 0 - Longitude
|
|
6
|
+
* @property {string|number} 1 - Latitude
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Map Marker
|
|
11
|
+
* @typedef MapMarker
|
|
12
|
+
* @type {object}
|
|
13
|
+
* @property {MapCoord} coord
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { defineStore } from 'pinia';
|
|
17
|
+
|
|
18
|
+
export const useMapStore = defineStore('map', {
|
|
19
|
+
state: () => {
|
|
20
|
+
return {
|
|
21
|
+
coord: [],
|
|
22
|
+
|
|
23
|
+
zoom: 8,
|
|
24
|
+
zoomMin: 8,
|
|
25
|
+
zoomMax: 18,
|
|
26
|
+
|
|
27
|
+
deviceZoom: true, // enable/disable mouse wheel or gesture zoom
|
|
28
|
+
|
|
29
|
+
markerImage: '',
|
|
30
|
+
markerActiveImage: '',
|
|
31
|
+
markerDisabledImage: '',
|
|
32
|
+
markers: [],
|
|
33
|
+
selectedMarker: null,
|
|
34
|
+
disabledMarkers: []
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
actions: {
|
|
39
|
+
/**
|
|
40
|
+
* Set map zoom
|
|
41
|
+
* @param {number} v
|
|
42
|
+
*/
|
|
43
|
+
setZoom(v) {
|
|
44
|
+
this.zoom = v;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Set min map zoom
|
|
49
|
+
* @param {number} v
|
|
50
|
+
*/
|
|
51
|
+
setZoomMin(v) {
|
|
52
|
+
this.zoomMin = v;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Set max map zoom
|
|
57
|
+
* @param {number} v
|
|
58
|
+
*/
|
|
59
|
+
setZoomMax(v) {
|
|
60
|
+
this.zoomMax = v;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/** Map zoom in */
|
|
64
|
+
zoomIn() {
|
|
65
|
+
if (this.zoom + 1 > this.zoomMax) {
|
|
66
|
+
if (this.zoom !== this.zoomMax) this.zoom = this.zoomMax;
|
|
67
|
+
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.zoom++;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/** Map zoom out */
|
|
75
|
+
zoomOut() {
|
|
76
|
+
if (this.zoom - 1 < this.zoomMin) {
|
|
77
|
+
if (this.zoom !== this.zoomMin) this.zoom = this.zoomMin;
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.zoom--;
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Set map coord
|
|
87
|
+
* @param {MapCoord} v
|
|
88
|
+
*/
|
|
89
|
+
setCoord(v) {
|
|
90
|
+
this.coord = v;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Enable/disable device zoom, if call withour params then toggle current state
|
|
95
|
+
* @param {boolean=} v
|
|
96
|
+
*/
|
|
97
|
+
setDeviceZoom(v = null) {
|
|
98
|
+
this.deviceZoom = v !== null ? v : !this.deviceZoom;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Set markers
|
|
103
|
+
* @param {MapMarker[]} v
|
|
104
|
+
*/
|
|
105
|
+
setMarkers(v) {
|
|
106
|
+
this.markers = v;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Set selected marker
|
|
111
|
+
* @param {MapMarker} v
|
|
112
|
+
*/
|
|
113
|
+
setSelectedMarker(v) {
|
|
114
|
+
this.selectedMarker = v;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Set disabled markers
|
|
119
|
+
* @param {MapMarker[]} v
|
|
120
|
+
*/
|
|
121
|
+
setDisabledMarkers(v) {
|
|
122
|
+
this.disabledMarkers = v;
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Set marker image
|
|
127
|
+
* @param {string} v
|
|
128
|
+
*/
|
|
129
|
+
setMarkerImage(v) {
|
|
130
|
+
this.markerImage = v;
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Set marker active image
|
|
135
|
+
* @param {string} v
|
|
136
|
+
*/
|
|
137
|
+
setMarkerActiveImage(v) {
|
|
138
|
+
this.markerActiveImage = v;
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Set marker disabled image
|
|
143
|
+
* @param {string} v
|
|
144
|
+
*/
|
|
145
|
+
setMarkerDisabledImage(v) {
|
|
146
|
+
this.markerDisabledImage = v;
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
getters: {
|
|
151
|
+
/**
|
|
152
|
+
* Get marker by id
|
|
153
|
+
* @param {string|number} id
|
|
154
|
+
* @returns MapMarker
|
|
155
|
+
*/
|
|
156
|
+
getMarker(state) {
|
|
157
|
+
return (id) => {
|
|
158
|
+
for (let item of state.markers) {
|
|
159
|
+
if (item.id === id) return item;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="component-ui-map-zoom">
|
|
3
|
+
<div class="prepend"><slot /></div>
|
|
4
|
+
<ui-button @click="store.zoomIn" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
|
|
5
|
+
<div class="separator"></div>
|
|
6
|
+
<ui-button @click="store.zoomOut" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
const props = defineProps(['store']);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<style lang="less">
|
|
15
|
+
@com-width: var(--ui-input-height-default);
|
|
16
|
+
@com-border-radius-default: var(--ui-border-radius-default);
|
|
17
|
+
|
|
18
|
+
// Padding
|
|
19
|
+
@com-map-padding: var(--ui-map-padding);
|
|
20
|
+
@com-space-mini: var(--ui-space-mini);
|
|
21
|
+
|
|
22
|
+
// Colors
|
|
23
|
+
@com-color-surface: var(--ui-color-surface);
|
|
24
|
+
@com-color-border: var(--ui-color-border);
|
|
25
|
+
|
|
26
|
+
// Box shadow
|
|
27
|
+
@com-bs-1: var(--ui-bs-1);
|
|
28
|
+
|
|
29
|
+
// Font-size
|
|
30
|
+
@com-text-large: var(--ui-text-large);
|
|
31
|
+
|
|
32
|
+
.component-ui-map-zoom {
|
|
33
|
+
position: absolute;
|
|
34
|
+
right: @com-map-padding;
|
|
35
|
+
bottom: @com-map-padding;
|
|
36
|
+
|
|
37
|
+
width: @com-width;
|
|
38
|
+
height: calc(calc(@com-width * 2) + 1);
|
|
39
|
+
|
|
40
|
+
background: @com-color-surface;
|
|
41
|
+
box-shadow: @com-bs-1;
|
|
42
|
+
border-radius: @com-border-radius-default;
|
|
43
|
+
|
|
44
|
+
.prepend {
|
|
45
|
+
position: absolute;
|
|
46
|
+
bottom: 100%;
|
|
47
|
+
left: 0;
|
|
48
|
+
right: 0;
|
|
49
|
+
margin-bottom: @com-space-mini;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.component-ui-button {
|
|
53
|
+
height: @com-width;
|
|
54
|
+
font-size: @com-text-large;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.separator {
|
|
58
|
+
border-bottom: 1px solid @com-color-border;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</style>
|