@abi-software/flatmapvuer 1.2.0 → 1.3.1-beta.0
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/flatmapvuer.js +25060 -28716
- package/dist/flatmapvuer.umd.cjs +164 -164
- package/dist/style.css +1 -1
- package/package.json +3 -2
- package/src/App.vue +5 -6
- package/src/components/FlatmapVuer.vue +233 -103
- package/src/components/MultiFlatmapVuer.vue +17 -1
- package/src/components/index.js +3 -5
- package/src/components.d.ts +0 -18
- package/src/services/flatmapQueries.js +6 -5
- package/vite.config.js +3 -2
- package/src/components/AnnotationTool.vue +0 -501
- package/src/components/ConnectionDialog.vue +0 -134
- package/src/components/DrawTool.vue +0 -502
- package/src/components/ExternalResourceCard.vue +0 -109
- package/src/components/HelpModeDialog.vue +0 -360
- package/src/components/ProvenancePopup.vue +0 -530
- package/src/components/Tooltip.vue +0 -50
- package/src/components/TreeControls.vue +0 -236
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="dialog-container">
|
|
3
|
-
<el-row>
|
|
4
|
-
<el-col>
|
|
5
|
-
<span class="dialog-title">Visualise connection</span>
|
|
6
|
-
<el-row v-if="inDrawing">
|
|
7
|
-
<span class="dialog-subtitle">Finalise drawing</span>
|
|
8
|
-
<el-button-group>
|
|
9
|
-
<el-button
|
|
10
|
-
type="primary"
|
|
11
|
-
plain
|
|
12
|
-
@click="$emit('confirmDrawn', true)"
|
|
13
|
-
>
|
|
14
|
-
Confirm
|
|
15
|
-
</el-button>
|
|
16
|
-
<el-button type="primary" plain @click="$emit('cancelDrawn', true)">
|
|
17
|
-
Cancel
|
|
18
|
-
</el-button>
|
|
19
|
-
</el-button-group>
|
|
20
|
-
</el-row>
|
|
21
|
-
<el-row v-else>
|
|
22
|
-
<el-button
|
|
23
|
-
type="primary"
|
|
24
|
-
plain
|
|
25
|
-
@click="$emit('dialogDisplay', false)"
|
|
26
|
-
>
|
|
27
|
-
Close
|
|
28
|
-
</el-button>
|
|
29
|
-
</el-row>
|
|
30
|
-
</el-col>
|
|
31
|
-
</el-row>
|
|
32
|
-
<el-row v-if="hasConnection">
|
|
33
|
-
<el-col>
|
|
34
|
-
<b><span>Related Features</span></b>
|
|
35
|
-
<el-row v-for="(value, key) in connectionEntry" :key="key">
|
|
36
|
-
<el-card :shadow="shadowDisplay(key)" @click="handleTooltip(key)">
|
|
37
|
-
<span>{{ capitalise(value.label) }}</span>
|
|
38
|
-
</el-card>
|
|
39
|
-
</el-row>
|
|
40
|
-
</el-col>
|
|
41
|
-
</el-row>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
|
|
45
|
-
<script>
|
|
46
|
-
/* eslint-disable no-alert, no-console */
|
|
47
|
-
import {
|
|
48
|
-
ElRow as Row,
|
|
49
|
-
ElCol as Col,
|
|
50
|
-
ElCard as Card,
|
|
51
|
-
ElButton as Button,
|
|
52
|
-
ElButtonGroup as ButtonGroup,
|
|
53
|
-
} from "element-plus";
|
|
54
|
-
|
|
55
|
-
export default {
|
|
56
|
-
name: "ConnectionDialog",
|
|
57
|
-
components: {
|
|
58
|
-
Row,
|
|
59
|
-
Col,
|
|
60
|
-
ButtonGroup,
|
|
61
|
-
Button,
|
|
62
|
-
Card,
|
|
63
|
-
},
|
|
64
|
-
props: {
|
|
65
|
-
connectionEntry: {
|
|
66
|
-
type: Object,
|
|
67
|
-
},
|
|
68
|
-
inDrawing: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: false,
|
|
71
|
-
},
|
|
72
|
-
hasConnection: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: false,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
data: function () {
|
|
78
|
-
return {
|
|
79
|
-
tooltipId: undefined,
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
methods: {
|
|
83
|
-
shadowDisplay: function (value) {
|
|
84
|
-
return this.tooltipId === value ? "always" : "hover";
|
|
85
|
-
},
|
|
86
|
-
capitalise: function (label) {
|
|
87
|
-
return label[0].toUpperCase() + label.slice(1);
|
|
88
|
-
},
|
|
89
|
-
handleTooltip: function (value) {
|
|
90
|
-
this.tooltipId = this.tooltipId === value ? undefined : value;
|
|
91
|
-
this.$emit("featureTooltip", this.tooltipId);
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
</script>
|
|
96
|
-
|
|
97
|
-
<style lang="scss" scoped>
|
|
98
|
-
.dialog-container {
|
|
99
|
-
width: 200px;
|
|
100
|
-
height: fit-content;
|
|
101
|
-
text-align: justify;
|
|
102
|
-
border-radius: 4px;
|
|
103
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
104
|
-
pointer-events: auto;
|
|
105
|
-
background: #fff;
|
|
106
|
-
border: 1px solid $app-primary-color;
|
|
107
|
-
display: flex;
|
|
108
|
-
flex-direction: column;
|
|
109
|
-
padding: 0.8em;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.dialog-title {
|
|
113
|
-
font-size: 18px;
|
|
114
|
-
font-weight: bold;
|
|
115
|
-
color: rgb(131, 0, 191);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.dialog-subtitle {
|
|
119
|
-
margin-top: 5px;
|
|
120
|
-
font-size: 15px;
|
|
121
|
-
color: rgb(131, 0, 191);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.el-button {
|
|
125
|
-
margin: 5px 0px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
:deep(.el-card) {
|
|
129
|
-
width: 100%;
|
|
130
|
-
--el-card-padding: 8px;
|
|
131
|
-
border: 0;
|
|
132
|
-
cursor: pointer;
|
|
133
|
-
}
|
|
134
|
-
</style>
|
|
@@ -1,502 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="drawtool-container">
|
|
4
|
-
<el-popover
|
|
5
|
-
content="Connection"
|
|
6
|
-
placement="left"
|
|
7
|
-
:teleported="false"
|
|
8
|
-
trigger="manual"
|
|
9
|
-
width="100"
|
|
10
|
-
popper-class="flatmap-popper"
|
|
11
|
-
:visible="hoverVisibilities[10].value"
|
|
12
|
-
ref="connectionPopover"
|
|
13
|
-
>
|
|
14
|
-
<template #reference>
|
|
15
|
-
<map-svg-icon
|
|
16
|
-
icon="connection"
|
|
17
|
-
class="icon-button drawConnection"
|
|
18
|
-
@click="drawConnectionEvent()"
|
|
19
|
-
@mouseover="showTooltip(10)"
|
|
20
|
-
@mouseout="hideTooltip(10)"
|
|
21
|
-
/>
|
|
22
|
-
</template>
|
|
23
|
-
</el-popover>
|
|
24
|
-
<el-popover
|
|
25
|
-
content="Draw Point"
|
|
26
|
-
placement="top"
|
|
27
|
-
:teleported="false"
|
|
28
|
-
trigger="manual"
|
|
29
|
-
width="80"
|
|
30
|
-
popper-class="flatmap-popper"
|
|
31
|
-
:visible="hoverVisibilities[11].value"
|
|
32
|
-
v-if="drawnType !== 'LineString' && drawnType !== 'Polygon'"
|
|
33
|
-
ref="drawPointPopover"
|
|
34
|
-
>
|
|
35
|
-
<template #reference>
|
|
36
|
-
<map-svg-icon
|
|
37
|
-
icon="drawPoint"
|
|
38
|
-
class="icon-button drawPoint"
|
|
39
|
-
@click="drawToolEvent('Point')"
|
|
40
|
-
@mouseover="showTooltip(11)"
|
|
41
|
-
@mouseout="hideTooltip(11)"
|
|
42
|
-
/>
|
|
43
|
-
</template>
|
|
44
|
-
</el-popover>
|
|
45
|
-
<el-popover
|
|
46
|
-
content="Draw Line"
|
|
47
|
-
placement="top"
|
|
48
|
-
:teleported="false"
|
|
49
|
-
trigger="manual"
|
|
50
|
-
width="80"
|
|
51
|
-
popper-class="flatmap-popper"
|
|
52
|
-
:visible="hoverVisibilities[12].value"
|
|
53
|
-
v-if="drawnType !== 'Point' && drawnType !== 'Polygon'"
|
|
54
|
-
ref="drawLinePopover"
|
|
55
|
-
>
|
|
56
|
-
<template #reference>
|
|
57
|
-
<map-svg-icon
|
|
58
|
-
icon="drawLine"
|
|
59
|
-
class="icon-button drawLineString"
|
|
60
|
-
@click="drawToolEvent('LineString')"
|
|
61
|
-
@mouseover="showTooltip(12)"
|
|
62
|
-
@mouseout="hideTooltip(12)"
|
|
63
|
-
/>
|
|
64
|
-
</template>
|
|
65
|
-
</el-popover>
|
|
66
|
-
<el-popover
|
|
67
|
-
content="Draw Polygon"
|
|
68
|
-
placement="top"
|
|
69
|
-
:teleported="false"
|
|
70
|
-
trigger="manual"
|
|
71
|
-
width="80"
|
|
72
|
-
popper-class="flatmap-popper"
|
|
73
|
-
:visible="hoverVisibilities[13].value"
|
|
74
|
-
v-if="drawnType !== 'Point' && drawnType !== 'LineString'"
|
|
75
|
-
ref="drawPolygonPopover"
|
|
76
|
-
>
|
|
77
|
-
<template #reference>
|
|
78
|
-
<map-svg-icon
|
|
79
|
-
icon="drawPolygon"
|
|
80
|
-
class="icon-button drawPolygon"
|
|
81
|
-
@click="drawToolEvent('Polygon')"
|
|
82
|
-
@mouseover="showTooltip(13)"
|
|
83
|
-
@mouseout="hideTooltip(13)"
|
|
84
|
-
/>
|
|
85
|
-
</template>
|
|
86
|
-
</el-popover>
|
|
87
|
-
<el-popover
|
|
88
|
-
content="Delete"
|
|
89
|
-
placement="top"
|
|
90
|
-
:teleported="false"
|
|
91
|
-
trigger="manual"
|
|
92
|
-
width="80"
|
|
93
|
-
popper-class="flatmap-popper"
|
|
94
|
-
:visible="hoverVisibilities[14].value"
|
|
95
|
-
ref="deletePopover"
|
|
96
|
-
>
|
|
97
|
-
<template #reference>
|
|
98
|
-
<map-svg-icon
|
|
99
|
-
icon="drawTrash"
|
|
100
|
-
class="icon-button drawDelete"
|
|
101
|
-
@click="drawModeEvent('Delete')"
|
|
102
|
-
@mouseover="showTooltip(14)"
|
|
103
|
-
@mouseout="hideTooltip(14)"
|
|
104
|
-
/>
|
|
105
|
-
</template>
|
|
106
|
-
</el-popover>
|
|
107
|
-
<el-popover
|
|
108
|
-
content="Edit"
|
|
109
|
-
placement="top"
|
|
110
|
-
:teleported="false"
|
|
111
|
-
trigger="manual"
|
|
112
|
-
width="80"
|
|
113
|
-
popper-class="flatmap-popper"
|
|
114
|
-
:visible="hoverVisibilities[15].value"
|
|
115
|
-
ref="editPopover"
|
|
116
|
-
>
|
|
117
|
-
<template #reference>
|
|
118
|
-
<map-svg-icon
|
|
119
|
-
icon="comment"
|
|
120
|
-
class="icon-button drawEdit"
|
|
121
|
-
@click="drawModeEvent('Edit')"
|
|
122
|
-
@mouseover="showTooltip(15)"
|
|
123
|
-
@mouseout="hideTooltip(15)"
|
|
124
|
-
/>
|
|
125
|
-
</template>
|
|
126
|
-
</el-popover>
|
|
127
|
-
</div>
|
|
128
|
-
<ConnectionDialog
|
|
129
|
-
class="connection-dialog"
|
|
130
|
-
v-show="connectionDisplay"
|
|
131
|
-
:connectionEntry="connectionEntry"
|
|
132
|
-
:inDrawing="inDrawing"
|
|
133
|
-
:hasConnection="hasConnection"
|
|
134
|
-
@dialogDisplay="drawConnectionEvent()"
|
|
135
|
-
@confirmDrawn="$emit('confirmDrawn', $event)"
|
|
136
|
-
@cancelDrawn="$emit('cancelDrawn', $event)"
|
|
137
|
-
@featureTooltip="$emit('featureTooltip', $event)"
|
|
138
|
-
/>
|
|
139
|
-
</div>
|
|
140
|
-
</template>
|
|
141
|
-
|
|
142
|
-
<script>
|
|
143
|
-
import { MapSvgIcon } from "@abi-software/svg-sprite";
|
|
144
|
-
import "@abi-software/svg-sprite/dist/style.css";
|
|
145
|
-
import ConnectionDialog from "./ConnectionDialog.vue";
|
|
146
|
-
/* eslint-disable no-alert, no-console */
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @param scopeElement Draggable scope area (Optional)
|
|
150
|
-
* @param dragElement Draggable element
|
|
151
|
-
*/
|
|
152
|
-
const draggable = (scopeElement, dragElement) => {
|
|
153
|
-
let startX, startY, clickX, clickY, posX, posY;
|
|
154
|
-
// reset position in case previous pupped up dialog is dragged
|
|
155
|
-
dragElement.style.left = "";
|
|
156
|
-
dragElement.style.top = "";
|
|
157
|
-
// const scopeRect = scopeElement.getBoundingClientRect()
|
|
158
|
-
// const dragRect = dragElement.getBoundingClientRect()
|
|
159
|
-
|
|
160
|
-
dragElement.addEventListener(
|
|
161
|
-
"mousedown",
|
|
162
|
-
(e) => {
|
|
163
|
-
e.preventDefault();
|
|
164
|
-
startX = dragElement.offsetLeft;
|
|
165
|
-
startY = dragElement.offsetTop;
|
|
166
|
-
clickX = e.clientX;
|
|
167
|
-
clickY = e.clientY;
|
|
168
|
-
|
|
169
|
-
dragElement.addEventListener("mousemove", drag, false);
|
|
170
|
-
document.addEventListener(
|
|
171
|
-
"mouseup",
|
|
172
|
-
() => {
|
|
173
|
-
dragElement.removeEventListener("mousemove", drag, false);
|
|
174
|
-
},
|
|
175
|
-
false
|
|
176
|
-
);
|
|
177
|
-
},
|
|
178
|
-
false
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
function drag(e) {
|
|
182
|
-
e.preventDefault();
|
|
183
|
-
posX = startX - (clickX - e.clientX);
|
|
184
|
-
posY = startY - (clickY - e.clientY);
|
|
185
|
-
// if (
|
|
186
|
-
// (posX > scopeRect.left && ((posX + dragRect.width) < scopeRect.right)) &&
|
|
187
|
-
// (posY > scopeRect.top && ((posY + dragRect.height) < scopeRect.bottom))
|
|
188
|
-
// ) {
|
|
189
|
-
dragElement.style.left = `${posX}px`;
|
|
190
|
-
dragElement.style.top = `${posY}px`;
|
|
191
|
-
// } else {
|
|
192
|
-
// if (posX <= scopeRect.left) {
|
|
193
|
-
// dragElement.style.left = '0px';
|
|
194
|
-
// } else if (posX + dragRect.width >= scopeRect.right) {
|
|
195
|
-
// dragElement.style.left = `${scopeRect.right - dragRect.width}px`;
|
|
196
|
-
// }
|
|
197
|
-
// if (posY <= scopeRect.top) {
|
|
198
|
-
// dragElement.style.top = '0px';
|
|
199
|
-
// } else if (posY + dragRect.height >= scopeRect.bottom) {
|
|
200
|
-
// dragElement.style.top = `${scopeRect.bottom - dragRect.height}px`;
|
|
201
|
-
// }
|
|
202
|
-
// }
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export default {
|
|
207
|
-
name: "DrawTool",
|
|
208
|
-
components: {
|
|
209
|
-
MapSvgIcon,
|
|
210
|
-
},
|
|
211
|
-
props: {
|
|
212
|
-
flatmapCanvas: {
|
|
213
|
-
type: Object,
|
|
214
|
-
default: null,
|
|
215
|
-
},
|
|
216
|
-
drawnType: {
|
|
217
|
-
type: String,
|
|
218
|
-
},
|
|
219
|
-
activeDrawTool: {
|
|
220
|
-
type: String,
|
|
221
|
-
},
|
|
222
|
-
activeDrawMode: {
|
|
223
|
-
type: String,
|
|
224
|
-
},
|
|
225
|
-
drawnCreatedEvent: {
|
|
226
|
-
type: Object,
|
|
227
|
-
},
|
|
228
|
-
connectionEntry: {
|
|
229
|
-
type: Object,
|
|
230
|
-
},
|
|
231
|
-
hoverVisibilities: {
|
|
232
|
-
type: Array,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
data: function () {
|
|
236
|
-
return {
|
|
237
|
-
activeTool: undefined,
|
|
238
|
-
activeMode: undefined,
|
|
239
|
-
connectionDisplay: false,
|
|
240
|
-
dialogPosition: {
|
|
241
|
-
offsetX: 0,
|
|
242
|
-
offsetY: 0,
|
|
243
|
-
x: undefined,
|
|
244
|
-
y: undefined,
|
|
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
|
-
],
|
|
254
|
-
};
|
|
255
|
-
},
|
|
256
|
-
computed: {
|
|
257
|
-
inDrawing: function () {
|
|
258
|
-
return this.activeDrawTool !== undefined;
|
|
259
|
-
},
|
|
260
|
-
isFeatureDrawn: function () {
|
|
261
|
-
return this.drawnCreatedEvent !== undefined;
|
|
262
|
-
},
|
|
263
|
-
hasConnection: function () {
|
|
264
|
-
return Object.keys(this.connectionEntry).length > 0;
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
watch: {
|
|
268
|
-
activeDrawTool: function (value) {
|
|
269
|
-
this.updateToolbarIcons(value);
|
|
270
|
-
if (!value) this.connectionDisplay = false;
|
|
271
|
-
},
|
|
272
|
-
activeDrawMode: function (value) {
|
|
273
|
-
this.updateToolbarIcons(value);
|
|
274
|
-
if (value === "Delete") this.connectionDisplay = false;
|
|
275
|
-
},
|
|
276
|
-
hasConnection: function (value) {
|
|
277
|
-
this.updateToolbarConnectionIcon(value, "disabled");
|
|
278
|
-
if (!value) this.connectionDisplay = false;
|
|
279
|
-
},
|
|
280
|
-
isFeatureDrawn: function (value) {
|
|
281
|
-
if (value) this.connectionDisplay = true;
|
|
282
|
-
},
|
|
283
|
-
connectionDisplay: function (value) {
|
|
284
|
-
this.updateToolbarConnectionIcon(value, "active");
|
|
285
|
-
if (value) this.dialogCssHacks();
|
|
286
|
-
else this.$emit("featureTooltip", undefined);
|
|
287
|
-
},
|
|
288
|
-
dialogPosition: {
|
|
289
|
-
handler: function () {
|
|
290
|
-
const containerRect = this.$el.getBoundingClientRect();
|
|
291
|
-
this.dialogPosition.offsetX = containerRect.x;
|
|
292
|
-
this.dialogPosition.offsetY = containerRect.y;
|
|
293
|
-
},
|
|
294
|
-
deep: true,
|
|
295
|
-
once: true,
|
|
296
|
-
},
|
|
297
|
-
},
|
|
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
|
-
},
|
|
341
|
-
drawToolEvent: function (type) {
|
|
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
|
-
) {
|
|
347
|
-
if (type === "Point") {
|
|
348
|
-
const point = this.flatmapCanvas.querySelector(
|
|
349
|
-
".mapbox-gl-draw_point"
|
|
350
|
-
);
|
|
351
|
-
point.click();
|
|
352
|
-
this.activeTool = point.classList.contains("active")
|
|
353
|
-
? "Point"
|
|
354
|
-
: undefined;
|
|
355
|
-
} else if (type === "LineString") {
|
|
356
|
-
const line = this.flatmapCanvas.querySelector(".mapbox-gl-draw_line");
|
|
357
|
-
line.click();
|
|
358
|
-
this.activeTool = line.classList.contains("active")
|
|
359
|
-
? "LineString"
|
|
360
|
-
: undefined;
|
|
361
|
-
} else if (type === "Polygon") {
|
|
362
|
-
const polygon = this.flatmapCanvas.querySelector(
|
|
363
|
-
".mapbox-gl-draw_polygon"
|
|
364
|
-
);
|
|
365
|
-
polygon.click();
|
|
366
|
-
this.activeTool = polygon.classList.contains("active")
|
|
367
|
-
? "Polygon"
|
|
368
|
-
: undefined;
|
|
369
|
-
}
|
|
370
|
-
this.$emit("drawToolbarEvent", this.activeTool);
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
drawModeEvent: function (type) {
|
|
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
|
-
) {
|
|
378
|
-
this.activeMode = type;
|
|
379
|
-
this.$emit("drawToolbarEvent", this.activeMode);
|
|
380
|
-
}
|
|
381
|
-
},
|
|
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");
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
},
|
|
394
|
-
dialogCssHacks: function () {
|
|
395
|
-
this.$nextTick(() => {
|
|
396
|
-
const dialog = this.$el.querySelector(".connection-dialog");
|
|
397
|
-
draggable(this.flatmapCanvas, dialog);
|
|
398
|
-
// dialog popup at the click position
|
|
399
|
-
// slightly change x or y if close to boundary
|
|
400
|
-
let posX, posY;
|
|
401
|
-
const containerRect = this.flatmapCanvas.getBoundingClientRect();
|
|
402
|
-
const dialogRect = dialog.getBoundingClientRect();
|
|
403
|
-
if (this.dialogPosition.x > containerRect.width / 2) {
|
|
404
|
-
posX = this.dialogPosition.x - dialogRect.width;
|
|
405
|
-
} else {
|
|
406
|
-
posX = this.dialogPosition.x;
|
|
407
|
-
}
|
|
408
|
-
if (this.dialogPosition.y > containerRect.height / 2) {
|
|
409
|
-
posY = this.dialogPosition.y - dialogRect.height;
|
|
410
|
-
} else {
|
|
411
|
-
posY = this.dialogPosition.y;
|
|
412
|
-
}
|
|
413
|
-
dialog.style.transform = `translate(${
|
|
414
|
-
posX - this.dialogPosition.offsetX
|
|
415
|
-
}px, ${posY - this.dialogPosition.offsetY}px)`;
|
|
416
|
-
});
|
|
417
|
-
},
|
|
418
|
-
showTooltip: function (tooltipNumber) {
|
|
419
|
-
this.$emit("showTooltip", tooltipNumber);
|
|
420
|
-
},
|
|
421
|
-
hideTooltip: function (tooltipNumber) {
|
|
422
|
-
this.$emit("hideTooltip", tooltipNumber);
|
|
423
|
-
},
|
|
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();
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
mounted: function () {
|
|
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
|
-
}
|
|
447
|
-
},
|
|
448
|
-
};
|
|
449
|
-
</script>
|
|
450
|
-
|
|
451
|
-
<style lang="scss" scoped>
|
|
452
|
-
.drawtool-container {
|
|
453
|
-
background-color: var(--el-color-primary-light-9);
|
|
454
|
-
padding: 4px 4px 2px 4px;
|
|
455
|
-
border-style: solid;
|
|
456
|
-
border-color: var(--el-color-primary-light-5);
|
|
457
|
-
border-radius: 1rem;
|
|
458
|
-
position: absolute;
|
|
459
|
-
right: calc(50vw - 100px);
|
|
460
|
-
bottom: 16px;
|
|
461
|
-
z-index: 10;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.drawPoint,
|
|
465
|
-
.drawLineString,
|
|
466
|
-
.drawPolygon,
|
|
467
|
-
.drawDelete,
|
|
468
|
-
.drawEdit,
|
|
469
|
-
.drawConnection {
|
|
470
|
-
padding: 4px;
|
|
471
|
-
color: var(--el-color-primary-light-5) !important;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
.icon-button {
|
|
475
|
-
height: 24px !important;
|
|
476
|
-
width: 24px !important;
|
|
477
|
-
color: $app-primary-color;
|
|
478
|
-
|
|
479
|
-
&.open-map-button {
|
|
480
|
-
margin-bottom: 4px;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
&:hover {
|
|
484
|
-
cursor: pointer;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
.active {
|
|
489
|
-
color: var(--el-color-primary) !important;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.disabled {
|
|
493
|
-
color: #dddddd !important;
|
|
494
|
-
cursor: not-allowed !important;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
.connection-dialog {
|
|
498
|
-
position: absolute;
|
|
499
|
-
z-index: 10;
|
|
500
|
-
cursor: move;
|
|
501
|
-
}
|
|
502
|
-
</style>
|