|
5 | 5 | @clusterclick="onClusterClick" |
6 | 6 | @clustercontextmenu="onClusterRightClick" |
7 | 7 | @spiderfied="onSpiderfied"> |
8 | | -<!-- <LMarker v-for="(p, i) in photoSuggestions" |
9 | | - v-if="p" |
10 | | - :key="i" |
11 | | - :options="{ data: p }" |
12 | | - :icon="getPhotoMarkerIcon(p, i)" |
13 | | - :draggable="draggable" |
14 | | - :lat-lng="[p.lat, p.lng]" |
15 | | - @click="onPhotoClick($event, i)" |
16 | | - @contextmenu="onPhotoRightClick($event, p)" |
17 | | - @moveend="onPhotoMoved($event, i)"> |
18 | | - <LTooltip v-if="p" |
19 | | - :class="{ |
20 | | - 'tooltip-photo-suggestion-wrapper': true, |
21 | | - 'photo-suggestion-marker-selected': photoSuggestionsSelectedIndices.includes(i) |
22 | | - }" |
23 | | - :options="{ ...tooltipOptions, opacity: draggable ? 0 : 1 }"> |
24 | | - <img class="photo-suggestion-tooltip" |
25 | | - :src="getPreviewUrl(p)"> |
26 | | - <p class="tooltip-photo-suggestion-date"> |
27 | | - {{ getPhotoFormattedDate(p) }} |
28 | | - </p> |
29 | | - <p class="tooltip-photo-suggestion-name"> |
30 | | - {{ basename(p.path) }} |
31 | | - </p> |
32 | | - </LTooltip> |
33 | | - <LPopup v-if="p" |
34 | | - class="popup-photo-suggestion-wrapper" |
35 | | - :options="popupOptions"> |
36 | | - <NcActionButton icon="icon-toggle" @click="viewPhoto(p)"> |
37 | | - {{ t('maps', 'Display picture') }} |
38 | | - </NcActionButton> |
39 | | - </LPopup> |
40 | | - </LMarker>--> |
41 | 8 | <LMarker |
42 | 9 | :lat-lng="[0, 0]" |
43 | 10 | :visible="false"> |
|
54 | 21 | {{ getPhotoFormattedDate(currentSuggestion) }} |
55 | 22 | </p> |
56 | 23 | <p class="tooltip-photo-suggestion-name"> |
57 | | - {{ currentSuggestion ? basename(currentSuggestion.path) : ''}} |
| 24 | + {{ currentSuggestion ? basename(currentSuggestion.path) : '' }} |
58 | 25 | </p> |
59 | 26 | </LTooltip> |
60 | 27 | <LPopup |
@@ -98,7 +65,7 @@ import { LMarker, LTooltip, LPopup } from 'vue2-leaflet' |
98 | 65 | import Vue2LeafletMarkerCluster from 'vue2-leaflet-markercluster' |
99 | 66 |
|
100 | 67 | import optionsController from '../../optionsController' |
101 | | -import {binSearch} from "../../utils/common"; |
| 68 | +import { binSearch } from '../../utils/common' |
102 | 69 |
|
103 | 70 | const PHOTO_MARKER_VIEW_SIZE = 40 |
104 | 71 |
|
@@ -264,6 +231,14 @@ export default { |
264 | 231 | ) |
265 | 232 | } |
266 | 233 | }, |
| 234 | + photoSuggestionsSelectedIndices(newIndices, oldIndices) { |
| 235 | + const oldSet = new Set(oldIndices) |
| 236 | + const newSet = new Set(newIndices) |
| 237 | + const removedIndices = oldIndices.filter((i) => { return !newSet.has(i) }) |
| 238 | + const addedIndices = newIndices.filter((i) => { return !oldSet.has(i) }) |
| 239 | + const changedMarkers = removedIndices.concat(addedIndices).map((i) => { return this.suggestionMarkers[i] }) |
| 240 | + this.$refs.markerCluster.mapObject.refreshClusters(changedMarkers) |
| 241 | + }, |
267 | 242 | }, |
268 | 243 |
|
269 | 244 | beforeMount() { |
@@ -329,22 +304,28 @@ export default { |
329 | 304 | }, |
330 | 305 | getClusterMarkerIcon(cluster) { |
331 | 306 | const count = cluster.getChildCount() |
332 | | - const photo = cluster.getAllChildMarkers()[0].data |
| 307 | + const markers = cluster.getAllChildMarkers() |
| 308 | + const selectedCount = markers.filter((m) => this.photoSuggestionsSelectedIndices.includes(m.i)).length |
| 309 | + const marker = markers[0] |
| 310 | + const photo = marker.data |
| 311 | + const index = marker.i |
333 | 312 | if (count === 1) { |
334 | | - return this.getPhotoMarkerIcon(photo) |
| 313 | + return this.getPhotoMarkerIcon(photo, index) |
335 | 314 | } |
336 | 315 | const iconUrl = this.getPreviewUrl(photo) |
337 | 316 | return new L.DivIcon(L.extend({ |
338 | 317 | className: 'leaflet-marker-photo-suggestion cluster-suggestion-marker', |
339 | | - html: '<div class="thumbnail" style="background-image: url(' + iconUrl + ');"></div><span class="label">' + count + '</span>', |
| 318 | + html: '<div class="thumbnail" style="background-image: url(' + iconUrl + ');"></div><span class="label">' |
| 319 | + + (selectedCount > 0 ? '<div style="color: var(--color-warning); display: inline;">' + selectedCount + '</div>/' : '') |
| 320 | + + count + '</span>', |
340 | 321 | }, cluster, { |
341 | 322 | iconSize: [PHOTO_MARKER_VIEW_SIZE, PHOTO_MARKER_VIEW_SIZE], |
342 | 323 | iconAnchor: [PHOTO_MARKER_VIEW_SIZE / 2, PHOTO_MARKER_VIEW_SIZE], |
343 | 324 | })) |
344 | 325 | }, |
345 | | - getPhotoMarkerIcon(photo) { |
| 326 | + getPhotoMarkerIcon(photo, index) { |
346 | 327 | const iconUrl = this.getPreviewUrl(photo) |
347 | | - const selectedClass = this.photoSuggestionsSelectedIndices.includes(photo.i) |
| 328 | + const selectedClass = this.photoSuggestionsSelectedIndices.includes(index) |
348 | 329 | ? '-selected' |
349 | 330 | : '' |
350 | 331 | return L.divIcon(L.extend({ |
|
0 commit comments