@abi-software/flatmapvuer 1.1.0-beta.3 → 1.1.1

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.
@@ -8,15 +8,16 @@
8
8
  trigger="manual"
9
9
  width="100"
10
10
  popper-class="flatmap-popper"
11
- :visible="hoverVisibilities[0].value"
11
+ :visible="hoverVisibilities[10].value"
12
+ ref="connectionPopover"
12
13
  >
13
14
  <template #reference>
14
15
  <map-svg-icon
15
16
  icon="connection"
16
- class="icon-button drawConnection inactive"
17
- @click="$emit('dialogDisplay', true)"
18
- @mouseover="showTooltip(0)"
19
- @mouseout="hideTooltip(0)"
17
+ class="icon-button drawConnection"
18
+ @click="drawConnectionEvent()"
19
+ @mouseover="showTooltip(10)"
20
+ @mouseout="hideTooltip(10)"
20
21
  />
21
22
  </template>
22
23
  </el-popover>
@@ -27,16 +28,17 @@
27
28
  trigger="manual"
28
29
  width="80"
29
30
  popper-class="flatmap-popper"
30
- :visible="hoverVisibilities[1].value"
31
+ :visible="hoverVisibilities[11].value"
31
32
  v-if="drawnType !== 'LineString' && drawnType !== 'Polygon'"
33
+ ref="drawPointPopover"
32
34
  >
33
35
  <template #reference>
34
36
  <map-svg-icon
35
37
  icon="drawPoint"
36
38
  class="icon-button drawPoint"
37
39
  @click="drawToolEvent('Point')"
38
- @mouseover="showTooltip(1)"
39
- @mouseout="hideTooltip(1)"
40
+ @mouseover="showTooltip(11)"
41
+ @mouseout="hideTooltip(11)"
40
42
  />
41
43
  </template>
42
44
  </el-popover>
@@ -47,16 +49,17 @@
47
49
  trigger="manual"
48
50
  width="80"
49
51
  popper-class="flatmap-popper"
50
- :visible="hoverVisibilities[2].value"
52
+ :visible="hoverVisibilities[12].value"
51
53
  v-if="drawnType !== 'Point' && drawnType !== 'Polygon'"
54
+ ref="drawLinePopover"
52
55
  >
53
56
  <template #reference>
54
57
  <map-svg-icon
55
58
  icon="drawLine"
56
59
  class="icon-button drawLineString"
57
60
  @click="drawToolEvent('LineString')"
58
- @mouseover="showTooltip(2)"
59
- @mouseout="hideTooltip(2)"
61
+ @mouseover="showTooltip(12)"
62
+ @mouseout="hideTooltip(12)"
60
63
  />
61
64
  </template>
62
65
  </el-popover>
@@ -67,16 +70,17 @@
67
70
  trigger="manual"
68
71
  width="80"
69
72
  popper-class="flatmap-popper"
70
- :visible="hoverVisibilities[3].value"
73
+ :visible="hoverVisibilities[13].value"
71
74
  v-if="drawnType !== 'Point' && drawnType !== 'LineString'"
75
+ ref="drawPolygonPopover"
72
76
  >
73
77
  <template #reference>
74
78
  <map-svg-icon
75
79
  icon="drawPolygon"
76
80
  class="icon-button drawPolygon"
77
81
  @click="drawToolEvent('Polygon')"
78
- @mouseover="showTooltip(3)"
79
- @mouseout="hideTooltip(3)"
82
+ @mouseover="showTooltip(13)"
83
+ @mouseout="hideTooltip(13)"
80
84
  />
81
85
  </template>
82
86
  </el-popover>
@@ -87,15 +91,16 @@
87
91
  trigger="manual"
88
92
  width="80"
89
93
  popper-class="flatmap-popper"
90
- :visible="hoverVisibilities[4].value"
94
+ :visible="hoverVisibilities[14].value"
95
+ ref="deletePopover"
91
96
  >
92
97
  <template #reference>
93
98
  <map-svg-icon
94
99
  icon="drawTrash"
95
100
  class="icon-button drawDelete"
96
101
  @click="drawModeEvent('Delete')"
97
- @mouseover="showTooltip(4)"
98
- @mouseout="hideTooltip(4)"
102
+ @mouseover="showTooltip(14)"
103
+ @mouseout="hideTooltip(14)"
99
104
  />
100
105
  </template>
101
106
  </el-popover>
@@ -106,15 +111,16 @@
106
111
  trigger="manual"
107
112
  width="80"
108
113
  popper-class="flatmap-popper"
109
- :visible="hoverVisibilities[5].value"
114
+ :visible="hoverVisibilities[15].value"
115
+ ref="editPopover"
110
116
  >
111
117
  <template #reference>
112
118
  <map-svg-icon
113
119
  icon="comment"
114
120
  class="icon-button drawEdit"
115
121
  @click="drawModeEvent('Edit')"
116
- @mouseover="showTooltip(5)"
117
- @mouseout="hideTooltip(5)"
122
+ @mouseover="showTooltip(15)"
123
+ @mouseout="hideTooltip(15)"
118
124
  />
119
125
  </template>
120
126
  </el-popover>
@@ -124,12 +130,11 @@
124
130
  v-show="connectionDisplay"
125
131
  :connectionEntry="connectionEntry"
126
132
  :inDrawing="inDrawing"
127
- :connection="connection"
128
- @dialogDisplay="$emit('dialogDisplay', $event)"
133
+ :hasConnection="hasConnection"
134
+ @dialogDisplay="drawConnectionEvent()"
129
135
  @confirmDrawn="$emit('confirmDrawn', $event)"
130
136
  @cancelDrawn="$emit('cancelDrawn', $event)"
131
- @showFeatureTooltip="$emit('showFeatureTooltip', $event)"
132
- @hideFeatureTooltip="$emit('hideFeatureTooltip', $event)"
137
+ @featureTooltip="$emit('featureTooltip', $event)"
133
138
  />
134
139
  </div>
135
140
  </template>
@@ -204,91 +209,81 @@ export default {
204
209
  MapSvgIcon,
205
210
  },
206
211
  props: {
207
- flatmapCanvas: undefined,
208
- inDrawing: {
209
- type: Boolean,
210
- },
211
- activeDrawTool: {
212
- type: String,
212
+ flatmapCanvas: {
213
+ type: Object,
214
+ default: null,
213
215
  },
214
216
  drawnType: {
215
217
  type: String,
216
218
  },
217
- drawnTypes: {
218
- type: Array,
219
+ activeDrawTool: {
220
+ type: String,
219
221
  },
220
222
  activeDrawMode: {
221
223
  type: String,
222
224
  },
223
- drawModes: {
224
- type: Array,
225
- },
226
- connectionDisplay: {
227
- type: Boolean,
225
+ drawnCreatedEvent: {
226
+ type: Object,
228
227
  },
229
228
  connectionEntry: {
230
229
  type: Object,
231
230
  },
232
- helpMode: {
233
- type: Boolean,
234
- default: false,
231
+ hoverVisibilities: {
232
+ type: Array,
235
233
  },
236
234
  },
237
235
  data: function () {
238
236
  return {
239
237
  activeTool: undefined,
240
238
  activeMode: undefined,
241
- hoverVisibilities: [
242
- { value: false },
243
- { value: false },
244
- { value: false },
245
- { value: false },
246
- { value: false },
247
- { value: false },
248
- ],
239
+ connectionDisplay: false,
249
240
  dialogPosition: {
250
241
  offsetX: 0,
251
242
  offsetY: 0,
252
243
  x: undefined,
253
244
  y: undefined,
254
245
  },
246
+ toolbarIcons: [
247
+ { name: "Connection", active: false, disabled: true },
248
+ { name: "Point", active: false, disabled: false },
249
+ { name: "LineString", active: false, disabled: false },
250
+ { name: "Polygon", active: false, disabled: false },
251
+ { name: "Edit", active: false, disabled: false },
252
+ { name: "Delete", active: false, disabled: false },
253
+ ],
255
254
  };
256
255
  },
257
256
  computed: {
258
- connection: function () {
257
+ inDrawing: function () {
258
+ return this.activeDrawTool !== undefined;
259
+ },
260
+ isFeatureDrawn: function () {
261
+ return this.drawnCreatedEvent !== undefined;
262
+ },
263
+ hasConnection: function () {
259
264
  return Object.keys(this.connectionEntry).length > 0;
260
265
  },
261
266
  },
262
267
  watch: {
263
- helpMode: function (newVal, oldVal) {
264
- if (newVal !== oldVal) {
265
- this.setHelpMode(newVal);
266
- }
268
+ activeDrawTool: function (value) {
269
+ this.updateToolbarIcons(value);
270
+ if (!value) this.connectionDisplay = false;
267
271
  },
268
- activeDrawTool: function () {
269
- this.drawIconCssHacks();
272
+ activeDrawMode: function (value) {
273
+ this.updateToolbarIcons(value);
274
+ if (value === "Delete") this.connectionDisplay = false;
270
275
  },
271
- activeDrawMode: function () {
272
- this.drawIconCssHacks();
276
+ hasConnection: function (value) {
277
+ this.updateToolbarConnectionIcon(value, "disabled");
278
+ if (!value) this.connectionDisplay = false;
273
279
  },
274
- connection: function (value) {
275
- const connectionIcon = this.$el.querySelector(".drawConnection");
276
- if (!value) {
277
- this.$emit("connection", false);
278
- connectionIcon.classList.add("inactive");
279
- } else {
280
- connectionIcon.classList.remove("inactive");
281
- }
280
+ isFeatureDrawn: function (value) {
281
+ if (value) this.connectionDisplay = true;
282
282
  },
283
- connectionDisplay: function (display) {
284
- const connectionIcon = this.$el.querySelector(".drawConnection");
285
- if (display) {
286
- connectionIcon.classList.add("iconSelected");
287
- this.dialogCssHacks();
288
- } else {
289
- connectionIcon.classList.remove("iconSelected");
290
- }
291
- this.drawIconCssHacks();
283
+ connectionDisplay: function (value) {
284
+ this.updateToolbarConnectionIcon(value, "active");
285
+ if (value) this.dialogCssHacks();
286
+ else this.$emit("featureTooltip", undefined);
292
287
  },
293
288
  dialogPosition: {
294
289
  handler: function () {
@@ -301,8 +296,54 @@ export default {
301
296
  },
302
297
  },
303
298
  methods: {
299
+ drawConnectionEvent: function () {
300
+ if (
301
+ this.hasConnection &&
302
+ !this.activeDrawTool && // disable connection icon in drawing
303
+ this.activeDrawMode !== "Delete" // disable connection icon in delete mode
304
+ ) {
305
+ this.connectionDisplay = !this.connectionDisplay;
306
+ }
307
+ },
308
+ updateToolbarConnectionIcon: function (value, type) {
309
+ this.toolbarIcons
310
+ .filter((icon) => icon.name === "Connection")
311
+ .map((icon) => {
312
+ // Disable connection icon when delete mode is on
313
+ if (this.activeDrawMode === "Delete") {
314
+ icon.disabled = true;
315
+ } else {
316
+ if (type === "active") {
317
+ if (value) icon.active = true;
318
+ else icon.active = false;
319
+ }
320
+ if (type === "disabled") {
321
+ if (value) icon.disabled = false;
322
+ else icon.disabled = true;
323
+ }
324
+ }
325
+ });
326
+ this.toolbarCssHacks();
327
+ },
328
+ updateToolbarIcons: function (value) {
329
+ this.toolbarIcons.map((icon) => {
330
+ if (icon.name === value) icon.active = true;
331
+ else icon.active = false;
332
+ });
333
+ this.toolbarIcons
334
+ .filter((icon) => icon.name !== "Connection" && icon.name !== value)
335
+ .map((icon) => {
336
+ if (value) icon.disabled = true;
337
+ else icon.disabled = false;
338
+ });
339
+ this.toolbarCssHacks();
340
+ },
304
341
  drawToolEvent: function (type) {
305
- if (!this.activeDrawMode && !this.connectionDisplay) {
342
+ if (
343
+ (!this.activeDrawTool || this.activeDrawTool === type) && // disable other tool icon when one is on
344
+ !this.activeDrawMode && // disable tool icon in edit or delete mode
345
+ !this.connectionDisplay // disable tool icon when connection displayed
346
+ ) {
306
347
  if (type === "Point") {
307
348
  const point = this.flatmapCanvas.querySelector(
308
349
  ".mapbox-gl-draw_point"
@@ -330,44 +371,25 @@ export default {
330
371
  }
331
372
  },
332
373
  drawModeEvent: function (type) {
333
- if (!this.activeDrawTool) {
374
+ if (
375
+ (!this.activeDrawMode || this.activeDrawMode === type) && // disable other mode icon when one is on
376
+ !this.activeDrawTool // disable tool icon in drawing
377
+ ) {
334
378
  this.activeMode = type;
335
379
  this.$emit("drawToolbarEvent", this.activeMode);
336
380
  }
337
381
  },
338
- drawIconCssHacks: function () {
339
- // set tool/mode icon status
340
- if (this.$el.querySelector(".iconSelected") || !this.connectionDisplay) {
341
- this.drawnTypes.map((t) => {
342
- const dtype = this.$el.querySelector(`.draw${t}`);
343
- if (dtype) {
344
- dtype.classList.remove("iconSelected");
345
- dtype.classList.remove("inactive");
346
- }
347
- });
348
- this.drawModes.map((m) => {
349
- this.$el.querySelector(`.draw${m}`).classList.remove("iconSelected");
350
- this.$el.querySelector(`.draw${m}`).classList.remove("inactive");
351
- });
352
- }
353
- if (this.activeDrawTool) {
354
- this.$el
355
- .querySelector(`.draw${this.activeDrawTool}`)
356
- .classList.add("iconSelected");
357
- this.drawModes.map((m) => {
358
- this.$el.querySelector(`.draw${m}`).classList.add("inactive");
359
- });
360
- } else if (this.activeDrawMode || this.connectionDisplay) {
361
- if (this.activeDrawMode) {
362
- this.$el
363
- .querySelector(`.draw${this.activeDrawMode}`)
364
- .classList.add("iconSelected");
382
+ toolbarCssHacks: function () {
383
+ // set toolbar icon style
384
+ this.toolbarIcons.map((icon) => {
385
+ const iconElement = this.$el.querySelector(`.draw${icon.name}`);
386
+ if (iconElement) {
387
+ if (icon.active) iconElement.classList.add("active");
388
+ else iconElement.classList.remove("active");
389
+ if (icon.disabled) iconElement.classList.add("disabled");
390
+ else iconElement.classList.remove("disabled");
365
391
  }
366
- this.drawnTypes.map((t) => {
367
- const dtype = this.$el.querySelector(`.draw${t}`);
368
- if (dtype) dtype.classList.add("inactive");
369
- });
370
- }
392
+ });
371
393
  },
372
394
  dialogCssHacks: function () {
373
395
  this.$nextTick(() => {
@@ -393,64 +415,35 @@ export default {
393
415
  }px, ${posY - this.dialogPosition.offsetY}px)`;
394
416
  });
395
417
  },
396
- /**
397
- * @vuese
398
- * Function to show tooltip
399
- * by providing ``tooltipNumber``.
400
- * @arg tooltipNumber
401
- */
402
418
  showTooltip: function (tooltipNumber) {
403
- if (!this.inHelp) {
404
- clearTimeout(this.tooltipWait[tooltipNumber]);
405
- this.tooltipWait[tooltipNumber] = setTimeout(() => {
406
- this.hoverVisibilities[tooltipNumber].value = true;
407
- }, 500);
408
- }
419
+ this.$emit("showTooltip", tooltipNumber);
409
420
  },
410
- /**
411
- * @vuese
412
- * Function to hide tooltip
413
- * by providing ``tooltipNumber``.
414
- * @arg tooltipNumber
415
- */
416
421
  hideTooltip: function (tooltipNumber) {
417
- if (!this.inHelp) {
418
- clearTimeout(this.tooltipWait[tooltipNumber]);
419
- this.tooltipWait[tooltipNumber] = setTimeout(() => {
420
- this.hoverVisibilities[tooltipNumber].value = false;
421
- }, 500);
422
- }
422
+ this.$emit("hideTooltip", tooltipNumber);
423
423
  },
424
- setHelpMode: function (helpMode) {
425
- if (helpMode) {
426
- this.inHelp = true;
427
- this.hoverVisibilities.forEach((item) => {
428
- item.value = true;
429
- });
430
- } else {
431
- this.inHelp = false;
432
- this.hoverVisibilities.forEach((item) => {
433
- item.value = false;
434
- });
424
+ clickHandler: function (e) {
425
+ e.preventDefault();
426
+ this.dialogPosition.x = e.clientX;
427
+ this.dialogPosition.y = e.clientY;
428
+ if (this.activeDrawTool === "Point") {
429
+ this.dialogCssHacks();
435
430
  }
436
431
  },
437
432
  },
438
433
  mounted: function () {
439
- this.tooltipWait = [];
440
- this.tooltipWait.length = this.hoverVisibilities.length;
441
- this.flatmapCanvas.querySelector(".maplibregl-canvas").addEventListener(
442
- "click",
443
- (e) => {
444
- e.preventDefault();
445
- this.dialogPosition.x = e.clientX;
446
- this.dialogPosition.y = e.clientY;
447
- // use to fix the draw point pop up position issue
448
- if (this.activeDrawTool === "Point") {
449
- this.dialogCssHacks();
450
- }
451
- },
452
- false
453
- );
434
+ this.toolbarCssHacks();
435
+ if (this.flatmapCanvas) {
436
+ this.flatmapCanvas
437
+ .querySelector(".maplibregl-canvas")
438
+ .addEventListener("click", this.clickHandler, false);
439
+ }
440
+ },
441
+ destroyed: function () {
442
+ if (this.flatmapCanvas) {
443
+ this.flatmapCanvas
444
+ .querySelector(".maplibregl-canvas")
445
+ .removeEventListener("click", this.clickHandler, false);
446
+ }
454
447
  },
455
448
  };
456
449
  </script>
@@ -492,11 +485,11 @@ export default {
492
485
  }
493
486
  }
494
487
 
495
- .iconSelected {
488
+ .active {
496
489
  color: var(--el-color-primary) !important;
497
490
  }
498
491
 
499
- .inactive {
492
+ .disabled {
500
493
  color: #dddddd !important;
501
494
  cursor: not-allowed !important;
502
495
  }