-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathDrawTool_Editing.js
More file actions
3028 lines (2789 loc) · 132 KB
/
DrawTool_Editing.js
File metadata and controls
3028 lines (2789 loc) · 132 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import $ from 'jquery'
import F_ from '../../Basics/Formulae_/Formulae_'
import L_ from '../../Basics/Layers_/Layers_'
import LayerGeologic from '../../Basics/Layers_/LayerGeologic/LayerGeologic'
import Globe_ from '../../Basics/Globe_/Globe_'
import Map_ from '../../Basics/Map_/Map_'
import Viewer_ from '../../Basics/Viewer_/Viewer_'
import UserInterface_ from '../../Basics/UserInterface_/UserInterface_'
import CursorInfo from '../../Ancillary/CursorInfo'
import turf from 'turf'
import DrawTool_Templater from './DrawTool_Templater'
import calls from '../../../pre/calls'
var DrawTool = null
var Editing = {
init: function (tool) {
DrawTool = tool
DrawTool.showContextMenu = Editing.showContextMenu
DrawTool.getSnapGuides = Editing.getSnapGuides
DrawTool.cmLayerDragOn = Editing.cmLayerDragOn
DrawTool.cmLayerDragOff = Editing.cmLayerDragOff
DrawTool.cmLayerDown = Editing.cmLayerDown
DrawTool.cmLayerUp = Editing.cmLayerUp
DrawTool.cmLayerMove = Editing.cmLayerMove
},
removeContextMenu: function () {
$('.drawToolContextMenu').remove()
UserInterface_.closeRightPanel()
},
showContextMenu: function (
x,
y,
layer,
index,
fileid,
ctrl,
displayOnly,
isKind,
kindLayerName
) {
if (!DrawTool.open && !displayOnly) return
// Force corner
x = 40
y = 40
DrawTool.lastContextLayerIndexFileId = {
layer: layer,
index: index,
fileid: fileid,
}
// Don't treat the point drags and context menu clicks
if (
DrawTool.contextMenuLayer &&
DrawTool.contextMenuLayer.justDragged
) {
DrawTool.contextMenuLayer.justDragged = false
return
}
let templater
//ctrl does lots. Here, if ctrl is pressed, check whether the layer is already selected.
// If it is, remove it
var deselecting = false
if (ctrl) {
for (var c in DrawTool.contextMenuLayers) {
var cml = DrawTool.contextMenuLayers[c]
if (
cml.l_i_f.layer == layer &&
cml.l_i_f.index == index &&
cml.l_i_f.fileid == fileid
) {
//already selected
$(
'#drawToolShapeLiItem_' + layer + '_' + index
).removeClass('active')
$('#drawToolShapeLiItem_' + layer + '_' + index)
.find('.drawToolShapeLiItemCheck')
.removeClass('checked')
resetShape(c)
Map_.rmNotNull(cml.selectionLayer)
DrawTool.contextMenuLayers.splice(c, 1)
deselecting = true
}
}
} else if (DrawTool.contextMenuLayer) {
resetShape()
}
//store the last saved point position
var currentPointLatLng = null
//ctrl is for group selections. If no ctrl, reset group
// or if a user uses ctrl to select the first shape
var grouping = true
if (!ctrl || !DrawTool.contextMenuLayer) {
grouping = false
//Turn off all selectLayers
for (var c in DrawTool.contextMenuLayers)
Map_.rmNotNull(DrawTool.contextMenuLayers[c].selectionLayer)
DrawTool.contextMenuLayers = []
DrawTool.contextMenuChanges.use = false
DrawTool.contextMenuChanges.props.name = true
DrawTool.contextMenuChanges.props.description = true
DrawTool.contextMenuChanges.style.color = true
DrawTool.contextMenuChanges.style.opacity = true
DrawTool.contextMenuChanges.style.dashArray = true
DrawTool.contextMenuChanges.style.weight = true
DrawTool.contextMenuChanges.style.fillColor = true
DrawTool.contextMenuChanges.style.fillOpacity = true
DrawTool.contextMenuChanges.style.symbol = true
DrawTool.contextMenuChanges.style.radius = true
DrawTool.contextMenuChanges.style.width = true
DrawTool.contextMenuChanges.style.length = true
DrawTool.contextMenuChanges.style.lineCap = true
DrawTool.contextMenuChanges.style.lineJoin = true
DrawTool.contextMenuChanges.style.fontSize = true
} else {
grouping = true
DrawTool.contextMenuChanges.use = true
//Because we only want the changed properties applied to the group and not them all
// ie. don't set all the fillColors to one color if it wasn't changed.
DrawTool.contextMenuChanges.props.name = false
DrawTool.contextMenuChanges.props.description = false
DrawTool.contextMenuChanges.style.color = false
DrawTool.contextMenuChanges.style.opacity = false
DrawTool.contextMenuChanges.style.dashArray = false
DrawTool.contextMenuChanges.style.weight = false
DrawTool.contextMenuChanges.style.fillColor = false
DrawTool.contextMenuChanges.style.fillOpacity = false
DrawTool.contextMenuChanges.style.symbol = false
DrawTool.contextMenuChanges.style.radius = false
DrawTool.contextMenuChanges.style.width = false
DrawTool.contextMenuChanges.style.length = false
DrawTool.contextMenuChanges.style.lineCap = false
DrawTool.contextMenuChanges.style.lineJoin = false
DrawTool.contextMenuChanges.style.fontSize = false
}
var shape = layer
if (index != null) shape = L_.layers.layer[shape][index]
//Disable editing the previous drawing layer if it was being
if (!displayOnly) {
if (DrawTool.contextMenuLayer) {
DrawTool.contextMenuLayer.resetGeoJSON()
if (
typeof DrawTool.contextMenuLayer.disableEdit === 'function'
) {
DrawTool.contextMenuLayer.disableEdit()
if (DrawTool.contextMenuLayer.snapediting) {
DrawTool.contextMenuLayer.snapediting.disable()
}
} else DrawTool.cmLayerDragOff()
DrawTool.isEditing = false
}
}
if (
shape.hasOwnProperty('_layers') &&
!(
shape.hasOwnProperty('feature') &&
shape.feature.properties.arrow == true
)
) {
DrawTool.contextMenuLayer =
shape._layers[Object.keys(shape._layers)[0]]
} else {
DrawTool.contextMenuLayer = shape
currentPointLatLng = Object.assign(
{},
DrawTool.contextMenuLayer._latlng
)
}
let featureType
let hasLengthMetric = false
let hasPerimeterMetric = false
let hasAreaMetric = false
let hasStrokeColor = false
let hasStrokeOpacity = false
let hasStrokeStyle = false
let hasStrokeWeight = false
let hasFillColor = false
let hasFillOpacity = false
let hasSymbol = false
let hasRadius = false
let hasWidth = false
let hasLength = false
let hasLineCap = false
let hasLineJoin = false
let hasFontSize = false
let hasRotation = false
let hasVisibilityRange = false
if (DrawTool.contextMenuLayer.feature.properties.arrow === true) {
//Arrow
featureType = 'arrow'
hasStrokeColor = true
hasStrokeOpacity = true
hasStrokeStyle = true
hasStrokeWeight = true
hasFillColor = true
hasFillOpacity = true
hasRadius = true
hasWidth = true
hasLength = true
hasLineCap = true
hasLineJoin = true
hasVisibilityRange = true
DrawTool.contextMenuLayer.originalStart =
DrawTool.contextMenuLayer.start
DrawTool.contextMenuLayer.originalEnd =
DrawTool.contextMenuLayer.end
} else if (
DrawTool.contextMenuLayer.feature.properties.annotation === true
) {
//Annotation
featureType = 'note'
hasStrokeColor = true
hasStrokeOpacity = true
hasStrokeWeight = true
hasFillColor = true
hasFontSize = true
hasRotation = true
hasVisibilityRange = true
} else if (
DrawTool.contextMenuLayer.feature.geometry.type.toLowerCase() ===
'point'
) {
//Point
featureType = 'point'
hasStrokeColor = true
hasStrokeOpacity = true
hasStrokeStyle = true
hasStrokeWeight = true
hasFillColor = true
hasFillOpacity = true
hasSymbol = true
hasRadius = true
hasVisibilityRange = true
} else if (
DrawTool.contextMenuLayer.feature.geometry.type.toLowerCase() ===
'linestring'
) {
//Line
featureType = 'line'
hasLengthMetric = true
hasStrokeColor = true
hasStrokeOpacity = true
hasStrokeStyle = true
hasStrokeWeight = true
//hasLineCap = true
//hasLineJoin = true
hasVisibilityRange = true
} else {
//Polygon
featureType = 'polygon'
hasPerimeterMetric = true
hasAreaMetric = true
hasStrokeColor = true
hasStrokeOpacity = true
hasStrokeStyle = true
hasStrokeWeight = true
hasFillColor = true
hasFillOpacity = true
hasVisibilityRange = true
}
let hideStyle = false
if (
typeof DrawTool.contextMenuLayer.toGeoJSON !== 'function' &&
featureType !== 'note'
)
hideStyle = true
var properties, style, file
if (!deselecting) {
if (typeof DrawTool.contextMenuLayer.toGeoJSON === 'function')
DrawTool.contextMenuLayerOriginalGeoJSON =
DrawTool.contextMenuLayer.toGeoJSON(L_.GEOJSON_PRECISION)
else
DrawTool.contextMenuLayerOriginalGeoJSON =
DrawTool.contextMenuLayer.feature
DrawTool.contextMenuLayerOriginalLatLngs = F_.getLatLngs(
DrawTool.contextMenuLayer
)
properties = DrawTool.contextMenuLayer.feature.properties
properties.style = properties.style || {}
style = properties.style || {}
let fallbackStyle = {}
if (kindLayerName && L_.layers.data[kindLayerName]?.style)
fallbackStyle = L_.layers.data[kindLayerName].style
//Set blank styles to
style.color = style.color || fallbackStyle.color || 'black'
style.opacity =
style.opacity != null
? style.opacity
: fallbackStyle.opacity != null
? fallbackStyle.opacity
: '1'
style.dashArray = style.dashArray || fallbackStyle.dashArray || ''
style.weight = style.weight || fallbackStyle.weight || '4'
style.fillColor =
style.fillColor || fallbackStyle.fillColor || 'black'
style.fillOpacity =
style.fillOpacity != null
? style.fillOpacity
: fallbackStyle.fillOpacity != null
? fallbackStyle.fillOpacity
: featureType === 'note'
? '1'
: '0.6'
style.symbol = style.symbol || fallbackStyle.symbol || ''
style.radius = style.radius || fallbackStyle.radius || ''
file = DrawTool.getFileObjectWithId(fileid)
var bbox = turf.bbox(DrawTool.contextMenuLayerOriginalGeoJSON)
var bounds = [
[bbox[1], bbox[0]],
[bbox[3], bbox[2]],
]
var sl
if (bounds[0][0] == bounds[1][0] && bounds[0][1] == bounds[1][1]) {
if (properties.annotation) {
bounds[0] = [bounds[0][1], bounds[0][0]]
sl = L.circleMarker(bounds[0], {
color: 'white',
fillOpacity: 0,
weight: 2,
dashArray: '5 5',
radius: 12,
})
.addTo(Map_.map)
.bringToBack()
} else {
var radius =
(parseInt(properties.style.radius) +
parseInt(properties.style.weight) * 2) *
2
if (!isNaN(radius))
sl = L.circleMarker(bounds[0], {
color: 'white',
weight: 2,
fillOpacity: 0,
dashArray: '5 5',
radius: radius,
})
.addTo(Map_.map)
.bringToBack()
}
} else if (
bounds[0][0] != Number.POSITIVE_INFINITY &&
bounds[0][0] != Number.NEGATIVE_INFINITY
) {
sl = L.rectangle(bounds, {
color: 'white',
weight: 2,
fillOpacity: 0,
dashArray: '5 5',
})
.addTo(Map_.map)
.bringToBack()
}
var layersLayer = shape
if (shape.hasOwnProperty('_layers'))
layersLayer = shape._layers[Object.keys(shape._layers)[0]]
DrawTool.contextMenuLayers.push({
shape: shape,
layer: layersLayer,
properties: properties,
style: style,
file: file,
l_i_f: { layer: layer, index: index, fileid: fileid },
selectionLayer: sl,
})
//selecting up to 1
if (DrawTool.contextMenuLayers.length == 1) {
grouping = false
}
} else {
if (DrawTool.contextMenuLayers.length > 0) {
DrawTool.contextMenuLayer = DrawTool.contextMenuLayers[0].layer
if (typeof DrawTool.contextMenuLayer.toGeoJSON === 'function')
DrawTool.contextMenuLayerOriginalGeoJSON =
DrawTool.contextMenuLayer.toGeoJSON(
L_.GEOJSON_PRECISION
)
else
DrawTool.contextMenuLayerOriginalGeoJSON =
DrawTool.contextMenuLayer.feature
DrawTool.contextMenuLayerOriginalLatLngs = F_.getLatLngs(
DrawTool.contextMenuLayer
)
properties = DrawTool.contextMenuLayer.feature.properties
properties.style = properties.style || {}
style = properties.style || {}
let fallbackStyle = {}
if (kindLayerName && L_.layers.data[kindLayerName].style)
fallbackStyle = L_.layers.data[kindLayerName].style
//Set blank styles to
style.color = style.color || fallbackStyle.color || 'black'
style.opacity =
style.opacity != null
? style.opacity
: fallbackStyle.opacity != null
? fallbackStyle.opacity
: '1'
style.dashArray =
style.dashArray || fallbackStyle.dashArray || ''
style.weight = style.weight || fallbackStyle.weight || '4'
style.fillColor =
style.fillColor || fallbackStyle.fillColor || 'black'
style.fillOpacity =
style.fillOpacity != null
? style.fillOpacity
: fallbackStyle.fillOpacity != null
? fallbackStyle.fillOpacity
: featureType === 'note'
? '1'
: '0.6'
style.symbol = style.symbol || fallbackStyle.symbol || ''
style.radius = style.radius || fallbackStyle.radius || ''
file = DrawTool.contextMenuLayers[0].file
//deselected back down to 1
if (DrawTool.contextMenuLayers.length == 1) {
grouping = false
}
} else {
DrawTool.contextMenuLayer = null
}
}
Editing.removeContextMenu()
if (DrawTool.contextMenuLayer == null) return
DrawTool.contextMenuLayer.resetGeoJSON = function () {
if (typeof DrawTool.contextMenuLayer.editEnabled === 'function') {
var reenableEdit = false
if (typeof DrawTool.contextMenuLayer.editEnabled === 'function')
reenableEdit = DrawTool.contextMenuLayer.editEnabled()
if (typeof DrawTool.contextMenuLayer.disableEdit === 'function')
DrawTool.contextMenuLayer.disableEdit()
if (DrawTool.contextMenuLayer.snapediting) {
DrawTool.contextMenuLayer.snapediting.disable()
}
if (
typeof DrawTool.contextMenuLayer.setLatLngs === 'function'
) {
DrawTool.contextMenuLayer.setLatLngs(
JSON.parse(
JSON.stringify(
DrawTool.contextMenuLayerOriginalLatLngs
)
)
)
} else if (
typeof DrawTool.contextMenuLayer.setLatLng === 'function'
) {
DrawTool.contextMenuLayer.setLatLng(
JSON.parse(
JSON.stringify(
DrawTool.contextMenuLayerOriginalLatLngs
)
)
)
}
if (
reenableEdit &&
typeof DrawTool.contextMenuLayer.enableEdit === 'function'
)
DrawTool.contextMenuLayer.enableEdit()
} else if (
typeof DrawTool.contextMenuLayer.setLatLng === 'function'
) {
DrawTool.contextMenuLayer.setLatLng(currentPointLatLng)
}
}
var title = properties.name || 'No Name'
var titleClass = ''
var countClass = 'hide'
var defaultName = title
var deleteClass = ''
if (DrawTool.contextMenuLayers.length > 1) {
title = 'GROUP'
titleClass = 'group'
countClass = ''
defaultName = ''
deleteClass = 'hide'
}
var description = properties.description || ''
var uuid = properties.uuid || ''
var ownedByUser = true
if (displayOnly) ownedByUser = false
else {
for (var i = 0; i < DrawTool.contextMenuLayers.length; i++) {
const cfile = DrawTool.contextMenuLayers[i].file
const isListEdit =
file.public == '1' &&
file.publicity_type == 'list_edit' &&
typeof file.public_editors?.includes === 'function' &&
(file.public_editors.includes(mmgisglobal.user) ||
ownedByUser)
const isAllEdit =
file.public == '1' && file.publicity_type == 'all_edit'
if (
(cfile.file_owner == 'master' ||
(mmgisglobal.user !== cfile.file_owner &&
(cfile.file_owner_group == null ||
(cfile.file_owner_group &&
F_.diff(
cfile.file_owner_group,
DrawTool.userGroups
).length == 0)))) &&
!(isListEdit || isAllEdit)
)
ownedByUser = false
}
}
let isMaster =
DrawTool.userGroups.indexOf('mmgis-group') != -1 &&
DrawTool.contextMenuLayers[0].file.file_owner == 'group'
let isGeologic = false
for (var i = 0; i < DrawTool.contextMenuLayers.length; i++) {
if (LayerGeologic.hasGeologicStyle(DrawTool.contextMenuLayers[i])) {
isGeologic = true
break
}
}
// prettier-ignore
let markup = [
"<div class='drawToolContextMenu'>",
"<div class='drawToolContextMenuColorGround'></div>",
"<div class='drawToolContextMenuHeaderColor'></div>",
"<div class='drawToolContextMenuBottomColor'></div>",
"<div class='drawToolContextMenuHeader'>",
"<div class='flexbetween'>",
"<div class='flexbetween'>",
"<div class='drawToolContextMenuHeaderName " + titleClass + "'>" + F_.sanitize(title) + "</div>",
"<div class='drawToolContextMenuHeaderCount " + countClass + "'>",
"<span>x" + DrawTool.contextMenuLayers.length + "</span>",
"</div>",
"</div>",
`<div class='drawToolContextMenuHeaderClose' file_id='${fileid}'>`,
"<i class='mdi mdi-close mdi-24px'></i>",
"</div>",
"</div>",
"<div class='drawToolContextMenuHeader1 flexbetween'>",
"<div class='drawToolContextMenuHeaderOwner'>by <span>" + F_.sanitize(file.file_owner) + "</span></div>",
"<div class='drawToolContextMenuHeaderFile'>from<span>" + F_.sanitize(file.file_name) + "</span></div>",
"</div>",
"</div>",
"<div class='drawToolContextMenuTabBar'>",
"<div class='drawToolContextMenuTabTitle'>Properties</div>",
"<div class='drawToolContextMenuTabButtons'>",
"<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabProperties' title='Properties'>",
"<i class='mdi mdi-list-box mdi-24px'></i>",
"</div>",
(!displayOnly) ? "<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabStyle' title='Style' style='display: " + ( (hideStyle) ? 'none' : 'inherit' ) + "'><i class='mdi mdi-palette mdi-24px'></i></div>" : "",
(!displayOnly && DrawTool.plugins?.Geologic) ? "<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabGeologic' title='Geologic'><i class='mdi mdi-earth-box mdi-24px'></i></div>" : "",
(!displayOnly && DrawTool.plugins?.MTTTT) ? "<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabMTTTT' title='MTn Trail Guide'><i class='mdi mdi-image-filter-hdr mdi-24px'></i></div>" : '',
(DrawTool.plugins?.ScienceIntent && DrawTool.contextMenuLayers.length == 1) ? "<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabScienceIntent' title='Science Intent'><i class='mdi mdi-microscope mdi-24px'></i></div>" : "",
(!displayOnly && DrawTool.plugins?.SetOperations) ? "<div class='drawToolContextMenuTabButton' tab='drawToolContextMenuTabSetOperations' title='Set Operations'><i class='mdi mdi-vector-combine mdi-24px'></i></div>" : "",
"</div>",
"</div>",
"<div class='drawToolContextMenuTabs'>",
"<div class='drawToolContextMenuTab drawToolContextMenuTabProperties'>",
"<div class='drawToolContextMenuProperties'>",
"<div class='drawToolContextMenuPropertiesName flexbetween'>",
"<div class='drawToolContextMenuPropertiesTitle'>Name</div>",
"<input id='drawToolContextMenuPropertiesName' type='text' value='" + F_.sanitize(defaultName) + "'/>",
"</div>",
"<div class='drawToolContextMenuPropertiesDescription flexbetween'>",
"<div class='drawToolContextMenuPropertiesTitle'>Description</div>",
"<textarea id='drawToolContextMenuPropertiesDescription' rows='2'></textarea>",
"</div>",
(file.template != null ) ? [
"<div class='drawToolContextMenuPropertiesCollapsible'>",
`<div class='drawToolContextMenuPropertiesTitle'>`,
`<div style='display: flex;'>`,
`<div>Template (${file.template?.name})</div>`,
`</div>`,
`<i class='mdi mdi-chevron-down mdi-24px'></i>`,
`</div>`,
`<div>`,
`<div class='drawToolContextMenuPropertiesRecomputeTemplate'><div><i class='mdi mdi-restore mdi-18px'></i><div>Recompute Templated Fields</div></div></div>`,
"<div id='drawToolContextMenuPropertiesTemplate'></div>",
`</div>`,
"</div>"].join('\n') : "",
"<div class='drawToolContextMenuPropertiesCollapsible state-collapsed'>",
"<div class='drawToolContextMenuPropertiesTitle'><div>Metrics</div><i class='mdi mdi-chevron-down mdi-24px'></i></div>",
"<div>",
(hasLengthMetric) ? [
"<div class='flexbetween' style='margin: 4px 0px;'>",
"<div>Length</div>",
`<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`,
"</div>",
].join('\n') : "",
(hasPerimeterMetric) ? [
"<div class='flexbetween' style='margin: 4px 0px;'>",
"<div>Perimeter</div>",
`<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`,
"</div>",
].join('\n') : "",
(hasAreaMetric) ? [
"<div class='flexbetween' style='margin-bottom: 4px;'>",
"<div>Area</div>",
`<div>${F_.getFeatureArea(DrawTool.contextMenuLayer.feature, true)}</div>`,
"</div>",
].join('\n') : "",
(DrawTool.contextMenuLayer?.feature?.properties?._radius != null) ? [
"<div class='flexbetween' style='margin-bottom: 4px;'>",
"<div>Radius</div>",
`<div>${DrawTool.contextMenuLayer.feature.properties._radius.toFixed(3)}m</div>`,
"</div>",
].join('\n') : "",
"</div>",
"</div>",
"<div class='drawToolContextMenuPropertiesCollapsible'>",
"<div class='drawToolContextMenuPropertiesTitle'><div>Properties</div><i class='mdi mdi-chevron-down mdi-24px'></i></div>",
"<div class='drawToolContextMenuPropertiesExtended'>",
Object.keys(DrawTool.contextMenuLayer.feature.properties).sort().map((p) => {
const pv = DrawTool.contextMenuLayer.feature.properties[p]
if(p === 'uuid') return ''
if( typeof pv === 'number' || typeof pv === 'string' || typeof pv === 'boolean')
return `<li><div>${p}</div><div>${pv}</div></li>`
else return ''
}).join('\n'),
"</div>",
"</div>",
(!displayOnly) ? ["<div class='drawToolContextMenuPropertiesReassignUUID flexbetween'>",
"<div id='drawToolContextMenuPropertiesReassignUUIDValue'>" + uuid + "</div>",
"<div id='drawToolContextMenuPropertiesReassignUUID' class='drawToolButton1'>Reassign</div>",
"</div>"].join('\n') : "",
"</div>",
"</div>",
"<div class='drawToolContextMenuTab drawToolContextMenuTabStyle'>",
"<div class='drawToolContextMenuStyle'>",
isGeologic ? "<div id='drawToolContextMenuStyleGeoMessage'>This shape includes geologic symbology. Standard stylings below might be overridden.</div>" : null,
"<div class='styleprop flexbetween' style='display: " + ( (hasFillColor) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Fill Color<div class='drawToolStyleHighlight'></div></div>",
"<div class='flexbetween'>",
"<input id='drawToolContextMenuFillColorInput' class='styleInput' type='text' value='" + style.fillColor + "'/>",
"<div v='" + style.fillColor + "' pick='fillcolorpick' class='picker fillcolor stylevalue2' style='background: " + style.fillColor + "'></div>",
"</div>",
"</div>",
"<div class='picking tall fillcolorpick styleColorPicker' style='display: " + ( (hasFillColor) ? 'flex' : 'none' ) + "'>",
"<div class='fillcolorcustom'><i class='mdi mdi-water mdi-18px'></i></div>",
"<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>",
"<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>","<div></div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasFillOpacity) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Fill Opacity<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.fillOpacity + "' pick='fillopacitypick' class='picker fillopacity stylevalue'>" + ( style.fillOpacity * 100 ) + '%' + "</div>",
"</div>",
"<div class='picking fillopacitypick styleOpacityPicker' style='display: " + ( (hasFillOpacity) ? 'flex' : 'none' ) + "'>",
"<div value='0'>0%</div>",
"<div value='0.1'>10%</div>",
"<div value='0.2'>20%</div>",
"<div value='0.4'>40%</div>",
"<div value='0.6'>60%</div>",
"<div value='0.8'>80%</div>",
"<div value='1'>100%</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasStrokeColor) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Stroke Color<div class='drawToolStyleHighlight'></div></div>",
"<div class='flexbetween'>",
"<input id='drawToolContextMenuStrokeColorInput' class='styleInput' type='text' value='" + style.color + "'/>",
"<div v='" + style.color + "' pick='strokecolorpick' class='picker strokecolor stylevalue2' style='background: " + style.color + "'></div>",
"</div>",
"</div>",
"<div class='picking tall strokecolorpick styleColorPicker' style='display: " + ( (hasStrokeColor) ? 'flex' : 'none' ) + "'>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasStrokeOpacity) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Stroke Opacity<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.opacity + "' pick='strokeopacitypick' class='picker strokeopacity stylevalue'>" + ( style.opacity * 100 ) + '%' + "</div>",
"</div>",
"<div class='picking strokeopacitypick styleOpacityPicker' style='display: " + ( (hasStrokeOpacity) ? 'flex' : 'none' ) + "'>",
"<div value='0'>0%</div>",
"<div value='0.2'>20%</div>",
"<div value='0.4'>40%</div>",
"<div value='0.6'>60%</div>",
"<div value='0.8'>80%</div>",
"<div value='1'>100%</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasStrokeStyle) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Stroke Style<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.dashArray + "' pick='strokestylepick' class='picker strokestyle stylevalue'><svg width='100%' height='100%'><line x1='0' y1='20' x2='80' y2='20' stroke='#F5F5F5' stroke-width='4' stroke-dasharray='" + style.dashArray + "' /></svg></div>",
"</div>",
"<div class='picking strokestylepick strokeStylePicker column mediumsmall' style='display: " + ( (hasStrokeStyle) ? 'flex' : 'none' ) + "'>",
"<div value=''><svg width='100%' height='100%'><line x1='0' y1='12' x2='310' y2='12' stroke='#F5F5F5' stroke-width='4' /></svg></div>",
"<div value='20'><svg width='100%' height='100%'><line x1='0' y1='12' x2='310' y2='12' stroke='#F5F5F5' stroke-width='4' stroke-dasharray='20' /></svg></div>",
"<div value='1 12'><svg width='100%' height='100%'><line x1='0' y1='12' x2='310' y2='12' stroke='#F5F5F5' stroke-width='4' stroke-dasharray='1 4' /></svg></div>",
"<div value='70 15 15 15'><svg width='100%' height='100%'><line x1='0' y1='12' x2='310' y2='12' stroke='#F5F5F5' stroke-width='4' stroke-dasharray='70 15 15 15' /></svg></div>",
"<div value='1 20 1 20 40 20'><svg width='100%' height='100%'><line x1='0' y1='12' x2='310' y2='12' stroke='#F5F5F5' stroke-width='4' stroke-dasharray='1 20 1 20 40 20' /></svg></div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasStrokeWeight) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Stroke Weight<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.weight + "' pick='strokeweightpick' class='picker strokeweight stylevalue'><svg width='100%' height='100%'><line x1='0' y1='20' x2='80' y2='20' stroke='#F5F5F5' stroke-width='" + style.weight + "' /></svg></div>",
"</div>",
"<div class='picking strokeweightpick strokeWeightPicker column medium' style='display: " + ( (hasStrokeWeight) ? 'flex' : 'none' ) + "'>",
"<div value='0'>None</div>",
"<div value='1'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='1' /></svg></div>",
"<div value='2'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='2' /></svg></div>",
"<div value='4' style='display: " + ( (featureType == 'note') ? 'none' : 'inline' ) + ";'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='4' /></svg></div>",
"<div value='8' style='display: " + ( (featureType == 'note') ? 'none' : 'inline' ) + ";'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='8' /></svg></div>",
"<div value='12' style='display: " + ( (featureType == 'note') ? 'none' : 'inline' ) + ";'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='12' /></svg></div>",
"<div value='16' style='display: " + ( (featureType == 'note') ? 'none' : 'inline' ) + ";'><svg width='100%' height='100%'><line x1='0' y1='10' x2='310' y2='10' stroke='#F5F5F5' stroke-width='16' /></svg></div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasSymbol) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Symbol<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.symbol + "' pick='symbolpick' class='picker symbol stylevalue'>" + style.symbol + "</div>",
"</div>",
"<div class='picking symbolpick symbolPicker' style='display: " + ( (hasSymbol) ? 'flex' : 'none' ) + "'>",
"<div>Circle</div>",
"<div>Square</div>",
"<div>Triangle</div>",
"<div>Diamond</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasRadius) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Radius<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.radius + "' pick='radiuspick' class='picker radius stylevalue'>" + style.radius + "</div>",
"</div>",
"<div class='picking radiuspick radiusPicker' style='display: " + ( (hasRadius) ? 'flex' : 'none' ) + "'>",
"<div>" + ( (featureType == 'arrow') ? '5' : '4' ) + "</div>",
"<div>" + ( (featureType == 'arrow') ? '10' : '6' ) + "</div>",
"<div>" + ( (featureType == 'arrow') ? '20' : '8' ) + "</div>",
"<div>" + ( (featureType == 'arrow') ? '30' : '12' ) + "</div>",
"<div>" + ( (featureType == 'arrow') ? '40' : '16' ) + "</div>",
"<div>" + ( (featureType == 'arrow') ? '50' : '20' ) + "</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasWidth) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Width<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.width + "' pick='widthpick' class='picker width stylevalue'>" + style.width + "</div>",
"</div>",
"<div class='picking widthpick widthPicker' style='display: " + ( (hasWidth) ? 'flex' : 'none' ) + "'>",
"<div>2</div>",
"<div>4</div>",
"<div>6</div>",
"<div>8</div>",
"<div>12</div>",
"<div>16</div>",
"<div>20</div>",
"<div>26</div>",
"<div>32</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasLength) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Length<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.length + "' pick='lengthpick' class='picker length stylevalue'>" + style.length + "</div>",
"</div>",
"<div class='picking lengthpick lengthPicker' style='display: " + ( (hasLength) ? 'flex' : 'none' ) + "'>",
"<div>50</div>",
"<div>100</div>",
"<div>150</div>",
"<div>200</div>",
"<div>250</div>",
"<div>Full</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasLineCap) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Line Cap<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.lineCap + "' pick='linecappick' class='picker linecap stylevalue'>" + style.lineCap + "</div>",
"</div>",
"<div class='picking linecappick lineCapPicker' style='display: " + ( (hasLineCap) ? 'flex' : 'none' ) + "'>",
"<div>Round</div>",
"<div>Square</div>",
"<div>Butt</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasLineJoin) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Line Join<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + style.lineJoin + "' pick='linejoinpick' class='picker linejoin stylevalue'>" + style.lineJoin + "</div>",
"</div>",
"<div class='picking linejoinpick lineJoinPicker' style='display: " + ( (hasLineJoin) ? 'flex' : 'none' ) + "'>",
"<div>Round</div>",
"<div>Miter</div>",
"<div>Bevel</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasFontSize) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Font Size<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + (style.fontSize || '18px') + "' pick='fontsizepick' class='picker fontsize stylevalue'>" + (style.fontSize || '18px') + "</div>",
"</div>",
"<div class='picking fontsizepick fontSizePicker' style='display: " + ( (hasFontSize) ? 'flex' : 'none' ) + "'>",
"<div>14px</div>",
"<div>18px</div>",
"<div>24px</div>",
"<div>32px</div>",
"<div>42px</div>",
"<div>54px</div>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasRotation) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween'>Rotation<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + (style.rotation || '0') + "' pick='rotationpick' class='picker rotation stylevalue'>" + (style.rotation || '0') + "deg</div>",
"</div>",
"<div class='picking rotationpick rotationPicker' style='display: " + ( (hasRotation) ? 'flex' : 'none' ) + "'>",
"<input class='slider3' type='range' min='-90' max='90' step='2' value='" + (style.rotation || 0) + "'/>",
"</div>",
"<div class='styleprop flexbetween' style='display: " + ( (hasVisibilityRange) ? 'flex' : 'none' ) + "'>",
"<div class='flexbetween' title='Set which zoom levels for which this feature is visible.'>Visibility Zoom-level Range<div class='drawToolStyleHighlight'></div></div>",
"<div v='" + (style.minZoom || '0') + ',' + (style.maxZoom || '24') + "' pick='visibilityrangepick' class='picker visibilityrange stylevalue'>" + (style.minZoom || '0') + ' ➝ ' + (style.maxZoom || '24') + "</div>",
"</div>",
"<div class='picking visibilityrangepick small visibilityRangePicker' style='display: " + ( (hasVisibilityRange) ? 'flex' : 'none' ) + "'>",
"<div id='visibilityRange-slider-range' class='svelteSlider' style='width: 100%; padding: 8px; overflow: hidden; height: 100%;'></div>",
`<div>Current Map Zoom-level: <span class='map-autoset-zoom'>${Map_.map.getZoom()}</span></div>`,
"</div>",
"</div>",
"</div>",
Editing.getPluginUIs(ownedByUser,
isMaster,
displayOnly,
isKind),
"</div>",
"<div class='drawToolContextMenuSave'>",
"<div class='reg drawToolContextMenuDelete drawToolButton1 " + deleteClass + "'>",
"<i class='mdi mdi-delete mdi-18px' style='cursor: pointer;'></i>",
"</div>",
"<div class='reg drawToolContextMenuReset drawToolButton1'>Reset</div>",
"<div class='reg drawToolContextMenuSaveChanges drawToolButton1'>Save All Changes</div>",
"<div class='sure sureq'>",
"<div>",
"<i class='mdi mdi-delete mdi-24px'></i>",
"<div>Delete this shape?</div>",
"</div>",
"</div>",
"<div class='sure drawToolContextMenuDeleteYes drawToolButton1'>Yes</div>",
"<div class='sure drawToolContextMenuDeleteNo drawToolButton1'>No</div>",
"</div>",
"</div>"
].join('\n');
$('#uiRightPanel').empty()
$('#uiRightPanel').append(markup)
templater = DrawTool_Templater.renderTemplate(
'drawToolContextMenuPropertiesTemplate',
file.template,
DrawTool.contextMenuLayer?.feature?.properties
)
$(
`.drawToolContextMenuPropertiesCollapsible > .drawToolContextMenuPropertiesTitle`
).on('click', function () {
$(this).parent().toggleClass('state-collapsed')
})
$(`.drawToolContextMenuPropertiesRecomputeTemplate`).on(
'click',
async () => {
const templateDefaults =
await DrawTool_Templater.getTemplateDefaults(
file?.template?.template,
L_.layers.layer[`DrawTool_${file.file_id}`],
{
geometry: JSON.stringify(
DrawTool.contextMenuLayer?.feature?.geometry
),
}
)
$('#drawToolContextMenuPropertiesTemplate').empty()
templater = DrawTool_Templater.renderTemplate(
'drawToolContextMenuPropertiesTemplate',
file.template,
{
...DrawTool.contextMenuLayer?.feature?.properties,
...templateDefaults,
}
)
}
)
UserInterface_.openRightPanel(360)
$('#drawToolContextMenuPropertiesDescription').text(description)
//Remove if not an owner
if (!ownedByUser) {
$('.drawToolContextMenuStyleHeader').remove()
$('.drawToolContextMenuStyle').remove()
$('.drawToolContextMenuSave').remove()
}
if (!displayOnly) {
DrawTool.contextMenuLayer.off('editable:editing')
DrawTool.contextMenuLayer.on(
'editable:editing',
updateSelectionLayer
)
DrawTool.contextMenuLayer.off('editable:drag')
DrawTool.contextMenuLayer.on('editable:drag', updateSelectionLayer)
DrawTool.contextMenuLayer.off('editable:dragstart')
DrawTool.contextMenuLayer.on('editable:dragstart', () => {
$('#drawToolMouseoverText').removeClass('active')
})
DrawTool.contextMenuLayer.off('editable:dragend')
DrawTool.contextMenuLayer.on('editable:dragend', () => {
$('#drawToolMouseoverText').removeClass('active')
})
}
function updateSelectionLayer() {
if (!DrawTool.contextMenuLayers[0].selectionLayer) return
var radius =
DrawTool.contextMenuLayers[0].selectionLayer.options.radius
Map_.rmNotNull(DrawTool.contextMenuLayers[0].selectionLayer)
if (typeof DrawTool.contextMenuLayer.toGeoJSON !== 'function')
return
var bbox = turf.bbox(
DrawTool.contextMenuLayer.toGeoJSON(L_.GEOJSON_PRECISION)
)
var bounds = [
[bbox[1], bbox[0]],
[bbox[3], bbox[2]],
]
var sl
if (bounds[0][0] == bounds[1][0] && bounds[0][1] == bounds[1][1])
sl = L.circleMarker(bounds[0], {
color: 'white',
weight: 2,
fillOpacity: 0,
dashArray: '5 5',
radius: radius,
})
.addTo(Map_.map)
.bringToBack()
else {
sl = L.rectangle(bounds, {
color: 'white',
weight: 2,
fillOpacity: 0,
dashArray: '5 5',
})
.addTo(Map_.map)
.bringToBack()
}
var bounds = [
[bbox[1], bbox[0]],
[bbox[3], bbox[2]],
]
DrawTool.contextMenuLayers[0].selectionLayer = sl