-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathInfoTool.js
More file actions
754 lines (695 loc) · 28.4 KB
/
InfoTool.js
File metadata and controls
754 lines (695 loc) · 28.4 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
import $ from 'jquery'
import * as d3 from 'd3'
import F_ from '../../Basics/Formulae_/Formulae_'
import L_ from '../../Basics/Layers_/Layers_'
import Map_ from '../../Basics/Map_/Map_'
import { Kinds } from '../../../pre/tools'
import Dropy from '../../../external/Dropy/dropy'
import MetadataCapturer from '../../Basics/Layers_/MetadataCapturer'
import Help from '../../Ancillary/Help'
import ConfirmationModal from '../../Ancillary/ConfirmationModal'
import tippy from 'tippy.js'
import './InfoTool.css'
const helpKey = 'InfoTool'
//Add the tool markup if you want to do it this way
// prettier-ignore
var markup = [
"<div id='infoTool'>",
"<div id='infoToolHeader'>",
"<div class='left'>",
"<div id='infoToolTitle'>Info</div>",
Help.getComponent(helpKey),
"<div id='infoToolEquiv' title='Number of overlapping features'></div>",
"</div>",
"<div class='right'>",
"<div id='infoToolUnhideAll' title='Reshow All Hidden Features'>",
"<i class='mdi mdi-eye-check mdi-18px'></i>",
"</div>",
"<div id='infoToolHide' title='Hide/Show Feature'>",
"<i class='mdi mdi-eye mdi-18px'></i>",
"</div>",
"<div id='infoToolDownload' title='Copy Feature to Clipboard'>",
"<i class='mdi mdi-clipboard-outline mdi-18px'></i>",
"</div>",
"<div id='infoToolLocate' title='Locate on Map'>",
"<i class='mdi mdi-crosshairs-gps mdi-18px'></i>",
"</div>",
"</div>",
"</div>",
"<div id='infoToolSelected'>",
"<div id='infoToolSelectedDropdown'></div>",
"</div>",
"<div id='infoToolFilter'>",
"<input type='text' placeholder='Filter'>",
"<i class='mdi mdi-filter-variant mdi-18px'></i>",
"<div id='infoToolShowHidden' title='Toggle Hidden Properties'>",
"<i class='mdi mdi-book-outline mdi-18px'></i>",
"</div>",
"</div>",
"<div id='infoToolSelectedGeoDataset'>",
"<div id='infoToolSelectedGeoDatasetLeft'>",
"<i class='mdi mdi-chevron-left mdi-18px'></i>",
"</div>",
"<div id='infoToolSelectedGeoDatasetDropdown'></div>",
"<div id='infoToolSelectedGeoDatasetDropdownTotal'></div>",
"<div id='infoToolSelectedGeoDatasetRight'>",
"<i class='mdi mdi-chevron-right mdi-18px'></i>",
"</div>",
"</div>",
"<div id='infoToolSelectedDataset'>",
"<div id='infoToolSelectedDatasetLeft'>",
"<i class='mdi mdi-chevron-left mdi-18px'></i>",
"</div>",
"<div id='infoToolSelectedDatasetDropdown'></div>",
"<div id='infoToolSelectedDatasetDropdownTotal'></div>",
"<div id='infoToolSelectedDatasetRight'>",
"<i class='mdi mdi-chevron-right mdi-18px'></i>",
"</div>",
"</div>",
"<div id='infoToolContent'>",
"<ul id='infoToolData'></ul>",
"<div id='infoToolNoneSelected'>No feature selected</div>",
"</div>",
"</div>"
].join('\n');
var InfoTool = {
height: 0,
width: 350,
currentLayer: null,
currentLayerName: null,
info: null,
variables: null,
activeFeatureI: null,
activeDatasetI: null,
activeGeoDatasetI: null,
featureLayers: [],
filterString: '',
hiddenShown: false,
featureHidden: false,
hiddenRootFields: ['_', 'style', 'images', 'coord_properties'],
vars: {},
MMGISInterface: null,
make: function () {
this.MMGISInterface = new interfaceWithMMGIS()
},
destroy: function () {
this.MMGISInterface.separateFromMMGIS()
},
getUrlString: function () {
return ''
},
//We might get multiple features if vector layers overlap
use: function (
currentLayer,
currentLayerName,
features,
variables,
activeI,
open,
initialEvent,
additional,
featureLayers
) {
let toolActive = $('#InfoTool').hasClass('active')
if (!open && toolActive) open = true
//In the very least, update the info
if (open && !toolActive) {
$('#InfoTool').click()
}
if (additional && additional.idx) activeI = additional.idx
if (currentLayer != null && currentLayerName != null) {
this.currentLayer = currentLayer
this.currentLayerName = currentLayerName
if (this.currentLayer.options == null) {
this.currentLayer.options = {}
}
if (this.currentLayer.options.layerName == null) {
this.currentLayer.options.layerName = this.currentLayerName
}
this.info = features
this.variables = variables
let activeIndex = activeI
if (activeI == null) {
let foundI = this.findFeature(currentLayer, features)
activeIndex = foundI != -1 ? foundI : 0
}
this.activeFeatureI = activeIndex
this.activeDatasetI = 0
this.activeGeoDatasetI = 0
this.initialEvent = initialEvent
// Always highlight even if redundant
// Maintain feature visibility state
// Has to be on to click anyway
InfoTool.featureHidden = false
$('#infoToolHide > i').removeClass('mdi-eye-off')
$('#infoToolHide > i').addClass('mdi-eye-on')
}
this.featureLayers = featureLayers || []
if (open != true) return
// MMGIS should always have a div with id 'tools'
let tools = d3.select('#toolPanel')
tools.style('background', 'var(--color-k)')
//Clear it
tools.selectAll('*').remove()
//Add a semantic container
tools = tools.append('div').style('height', '100%')
//Add the markup to tools or do it manually
tools.html(markup)
tippy('#infoToolSelected', {
content: 'Select An Overlapping Feature (Shift + ⇆)',
placement: 'right',
theme: 'blue',
})
tippy('#infoToolSelectedGeoDataset', {
content: 'Select An Associated Dataset (Ctrl/Cmd + ⇆)',
placement: 'right',
theme: 'blue',
})
tippy('#infoToolSelectedDataset', {
content: 'Select An Associated Dataset (Ctrl/Cmd + ⇆)',
placement: 'right',
theme: 'blue',
})
Help.finalize(helpKey)
$('#infoToolUnhideAll').css(
'display',
L_.toggledOffFeatures.length > 0 ? 'block' : 'none'
)
if (this.info == null || this.info.length == 0) {
$('#infoToolHeader > .right').css('display', 'none')
$('#infoToolSelected').css('display', 'none')
$('#infoToolSelectedDataset').css('display', 'none')
$('#infoToolSelectedGeoDataset').css('display', 'none')
$('#infoToolFilter').css('display', 'none')
$('#infoToolNoneSelected').css('display', 'block')
return
}
$('#infoToolHeader > .right').css('display', 'inherit')
$('#infoToolSelected').css('display', 'inherit')
$('#infoToolFilter').css('display', 'inherit')
$('#infoToolNoneSelected').css('display', 'none')
// Update number of equivalent features
if (this.info.length > 1) {
$('#infoToolEquiv').text(
`${this.activeFeatureI + 1} of ${this.info.length}`
)
$('#infoToolEquiv').css('display', 'block')
} else {
$('#infoToolEquiv').text(`1`)
$('#infoToolEquiv').css('display', 'none')
}
// Populate Dropdown
let nameItems = []
for (let i = 0; i < this.info.length; i++) {
if (!this.info[i].properties) {
if (this.info[i].feature) this.info[i] = this.info[i].feature
}
let key = this.variables
? this.variables.useKeyAsName || 'name'
: 'name'
if (
!(
typeof this.info[i].properties[key] === 'string' ||
typeof this.info[i].properties[key] === 'number'
)
) {
const propKeys = Object.keys(this.info[i].properties)
for (let j = 0; j < propKeys.length; j++) {
if (
typeof this.info[i].properties[propKeys[j]] ===
'string' ||
typeof this.info[i].properties[propKeys[j]] === 'number'
) {
key = propKeys[j]
break
}
}
}
const name =
this.info[i].properties[key] != null
? this.info[i].properties[key]
: 'Unk'
nameItems.push(this.info.length > 1 ? `${i + 1}. ${name}` : name)
}
$('#infoToolSelectedDropdown').html(
Dropy.construct(
nameItems,
`Feature${
this.info.length > 1 ? `s (${this.info.length})` : ''
}`,
this.activeFeatureI
)
)
Dropy.init($('#infoToolSelectedDropdown'), function (idx) {
InfoTool.selectedDropdownChange(idx)
})
InfoTool.createInfo()
// Add button/icon/filter events
// Copy to Clipboard
$('#infoToolDownload').on('click', function () {
const feature = L_.convertGeoJSONLngLatsToPrimaryCoordinates(
InfoTool.info[InfoTool.activeFeatureI]
)
F_.copyToClipboard(JSON.stringify(feature, null, 2))
const icon = $(this).find('i')
icon.removeClass('mdi-clipboard-outline')
icon.addClass('mdi-check-bold')
icon.css('color', 'var(--color-green)')
setTimeout(() => {
icon.removeClass('mdi-check-bold')
icon.css('color', 'inherit')
icon.addClass('mdi-clipboard-outline')
}, 3000)
})
// Locate
$('#infoToolLocate').on('click', function () {
try {
if (typeof InfoTool.currentLayer.getBounds === 'function')
Map_.map.fitBounds(InfoTool.currentLayer.getBounds())
else Map_.map.panTo(InfoTool.currentLayer._latlng)
} catch (err) {}
})
// Unhide all hidden Features
$('#infoToolUnhideAll').on('click', function () {
ConfirmationModal.prompt(
`You have hidden ${L_.toggledOffFeatures.length} feature(s).<br>Do you want to reveal them all?`,
(proceed) => {
if (proceed) {
L_.unhideAllFeatures()
InfoTool.featureHidden = false
$('#infoToolHide > i').removeClass('mdi-eye-off')
$('#infoToolHide > i').addClass('mdi-eye')
if (L_.toggledOffFeatures)
$('#infoToolUnhideAll').css(
'display',
L_.toggledOffFeatures.length > 0
? 'block'
: 'none'
)
}
}
)
})
// Hide/Show Feature
$('#infoToolHide').on('click', function () {
InfoTool.featureHidden = !InfoTool.featureHidden
$(this).find('i').toggleClass('mdi-eye-off')
$(this).find('i').toggleClass('mdi-eye')
L_.toggleFeature(InfoTool.currentLayer, !InfoTool.featureHidden)
if (L_.toggledOffFeatures)
$('#infoToolUnhideAll').css(
'display',
L_.toggledOffFeatures.length > 0 ? 'block' : 'none'
)
})
// Filter
$('#infoToolFilter > input').on('input', function () {
InfoTool.filterString = $(this).val()
InfoTool.filterList()
})
// Toggle hidden
$('#infoToolShowHidden').on('click', function () {
InfoTool.hiddenShown = !InfoTool.hiddenShown
$(this).find('i').toggleClass('mdi-book-outline')
$(this).find('i').toggleClass('mdi-book-open-variant')
InfoTool.createInfo()
})
},
createInfo: function () {
$('#infoToolData').empty()
// Fill out Info
const depthMultiplier = 10
let lastWasAHeader = false
const geometryType = this.info[this.activeFeatureI].geometry.type
? this.info[this.activeFeatureI].geometry.type.toLowerCase()
: null
if (geometryType === 'point') {
const names = L_.Coordinates.states[L_.Coordinates.mainType].names
// Convert coords to main coordinate type; if already lnglat, don't reconvert
const coords =
L_.Coordinates.mainType === 'll'
? this.info[this.activeFeatureI].geometry.coordinates
: L_.Coordinates.convertLngLat(
this.info[this.activeFeatureI].geometry
.coordinates[0],
this.info[this.activeFeatureI].geometry
.coordinates[1],
null,
true
)
depthTraversal(
{
Coordinates: {
[names[0]]: coords[0],
[names[1]]: coords[1],
Elevation:
this.info[this.activeFeatureI].geometry
.coordinates[2] || 'unk',
},
},
[],
0
)
}
let props = JSON.parse(
JSON.stringify(this.info[this.activeFeatureI].properties)
)
if (!InfoTool.hiddenShown) {
InfoTool.hiddenRootFields.forEach((element) => {
delete props[element]
})
}
if (geometryType === 'linestring' || geometryType === 'multilinestring')
props.Metrics = {
Length: F_.getFeatureLength(
this.info[this.activeFeatureI],
true
),
}
else if (geometryType === 'polygon')
props.Metrics = {
Perimeter: F_.getFeatureLength(
this.info[this.activeFeatureI],
true
),
Area: F_.getFeatureArea(this.info[this.activeFeatureI], true),
}
InfoTool.hasGeoDatasetMetadata = props._geodataset != null
if (InfoTool.hasGeoDatasetMetadata) {
$('#infoToolSelectedGeoDataset').css('display', 'inherit')
const geodatasetNames = []
props._geodataset.results.forEach((d) => {
let propSplit = props._geodataset.prop.split(',')
let name = []
for (let i = 0; i < propSplit.length; i++) {
name.push(F_.getIn(d, propSplit[i].split('.')))
}
geodatasetNames.push(
`${
propSplit[0] === '_.idx' ? 'ID' : propSplit[0]
}: ${name.join('_')}`
)
})
$('#infoToolSelectedGeoDatasetDropdown').html(
Dropy.construct(
geodatasetNames,
`GeoDataset`,
InfoTool.activeGeoDatasetI
)
)
Dropy.init(
$('#infoToolSelectedGeoDatasetDropdown'),
function (idx) {
InfoTool.activeGeoDatasetI = idx
$('#infoToolSelectedGeoDatasetDropdownTotal').text(
`${InfoTool.activeGeoDatasetI + 1} of ${
geodatasetNames.length
}`
)
InfoTool.createInfo()
}
)
$('#infoToolSelectedGeoDatasetDropdownTotal').text(
`${InfoTool.activeGeoDatasetI + 1} of ${geodatasetNames.length}`
)
$('#infoToolSelectedGeoDatasetLeft').off('click')
$('#infoToolSelectedGeoDatasetLeft').on('click', () => {
if (InfoTool.activeGeoDatasetI > 0) {
InfoTool.activeGeoDatasetI--
InfoTool.createInfo()
}
})
$('#infoToolSelectedGeoDatasetRight').off('click')
$('#infoToolSelectedGeoDatasetRight').on('click', () => {
if (InfoTool.activeGeoDatasetI < geodatasetNames.length - 1) {
InfoTool.activeGeoDatasetI++
InfoTool.createInfo()
}
})
props.GeoDataset =
props._geodataset.results[InfoTool.activeGeoDatasetI]
} else {
$('#infoToolSelectedGeoDataset').css('display', 'none')
}
InfoTool.hasDataset = props._dataset != null
if (InfoTool.hasDataset) {
$('#infoToolSelectedDataset').css('display', 'inherit')
const datasetNames = []
props._dataset.results.forEach((d) => {
let name = F_.getIn(d, props._dataset.prop.split('.'))
if (name != null)
datasetNames.push(
`${props._dataset.prop.split('.').slice(-1)}: ${name}`
)
})
$('#infoToolSelectedDatasetDropdown').html(
Dropy.construct(
datasetNames,
`Dataset`,
InfoTool.activeDatasetI
)
)
Dropy.init($('#infoToolSelectedDatasetDropdown'), function (idx) {
InfoTool.activeDatasetI = idx
$('#infoToolSelectedDatasetDropdownTotal').text(
`${InfoTool.activeDatasetI + 1} of ${datasetNames.length}`
)
InfoTool.createInfo()
})
$('#infoToolSelectedDatasetDropdownTotal').text(
`${InfoTool.activeDatasetI + 1} of ${datasetNames.length}`
)
$('#infoToolSelectedDatasetLeft').off('click')
$('#infoToolSelectedDatasetLeft').on('click', () => {
if (InfoTool.activeDatasetI > 0) {
InfoTool.activeDatasetI--
InfoTool.createInfo()
}
})
$('#infoToolSelectedDatasetRight').off('click')
$('#infoToolSelectedDatasetRight').on('click', () => {
if (InfoTool.activeDatasetI < datasetNames.length - 1) {
InfoTool.activeDatasetI++
InfoTool.createInfo()
}
})
props.Dataset = props._dataset.results[InfoTool.activeDatasetI]
} else {
$('#infoToolSelectedDataset').css('display', 'none')
}
depthTraversal(
props,
0,
[],
this.vars.sortAlphabetically === false ? false : true
)
function depthTraversal(node, depth, path, sort) {
path = path || []
const keys = Object.keys(node)
if (sort) keys.sort()
let type = 'infoTool_property'
if (InfoTool.hiddenRootFields.indexOf(path[0]) != -1)
type = 'infoTool_hidden'
else if (path[0] == 'Coordinates') type = 'infoTool_geometry'
else if (path[0] == 'Metrics') type = 'infoTool_metrics'
else if (path[0] == '_dataset') return
else if (path[0] == '_geodataset') return
for (var i = 0; i < keys.length; i++) {
if (path.length == 0) {
if (InfoTool.hiddenRootFields.indexOf(keys[i]) != -1)
type = 'infoTool_hidden'
else if (keys[i] == 'Coordinates')
type = 'infoTool_geometry'
else if (keys[i] == 'Metrics') type = 'infoTool_metrics'
else type = 'infoTool_property'
}
if (keys[i] == '_dataset' || keys[i] == '_geodataset') {
// do nothing
} else if (
typeof node[keys[i]] === 'object' &&
node[keys[i]] !== null
) {
// prettier-ignore
$('#infoToolData').append(
[
`<li class="${type}" style="margin-left: ${depth * depthMultiplier}px;" depth=${depth}>`,
'<div>',
`${keys[i]}`,
'</div>',
'<div>',
'</div>',
'</li>'
].join('\n'))
if (
!Array.isArray(node[keys[i]]) ||
node[keys[i]].length > 0
)
lastWasAHeader = true
depthTraversal(
node[keys[i]],
depth + 1,
path.concat([keys[i]])
)
} else {
// prettier-ignore
$('#infoToolData').append(
[
`<li class="${type}" style="margin-left: ${depth * depthMultiplier}px;" depth=${depth}>`,
'<div>',
`${keys[i]}:`,
'</div>',
'<div>',
F_.isValidUrl(node[keys[i]]) ?
`<a href="${node[keys[i]]}" target="_blank">${node[keys[i]]}</a><i class='mdi mdi-open-in-new mdi-14px' style='margin-left: 2px;'></i>`
: node[keys[i]],
'</div>',
'</li>'
].join('\n'))
lastWasAHeader = false
}
}
}
$('#infoToolData li').off('click')
$('#infoToolData li').on('click', function () {
$(this).toggleClass('expand')
})
$('#infoToolFilter > input').val(InfoTool.filterString)
if (InfoTool.filterString.length > 0) {
InfoTool.filterList()
}
},
findFeature: function (l, featureArray) {
if (l.feature && featureArray) {
let f = JSON.stringify(l.feature)
for (let i = 0; i < featureArray.length; i++) {
if (JSON.stringify(featureArray[i]) == f) {
return i
}
}
}
return -1
},
filterList: function () {
const filterString = InfoTool.filterString.toLowerCase()
$('#infoToolData > li').each(function (idx) {
let show = false
$(this)
.find('div')
.each(function (idx2) {
if (
$(this).text().toLowerCase().indexOf(filterString) != -1
)
show = true
})
if (filterString == null || filterString.length == 0) show = true
$(this).css('display', show ? 'flex' : 'none')
const currentDepth = parseInt($(this).attr('depth'))
// Show all parents too even if they don't match
if (show && currentDepth != 0) {
let hit0 = false
$(this)
.prevAll()
.each(function (idx3) {
if (
parseInt($(this).attr('depth')) < currentDepth &&
!hit0
)
$(this).css('display', 'flex')
if (!hit0 && $(this).attr('depth') == 0) hit0 = true
})
}
})
},
clearInfo: function () {
this.currentLayer = null
this.currentLayerName = null
this.info = null
this.variables = null
this.activeFeatureI = null
// Clear the InfoTools data
$('#infoToolData').empty()
$('#infoToolHeader > .right').css('display', 'none')
$('#infoToolSelected').css('display', 'none')
$('#infoToolSelectedDataset').css('display', 'none')
$('#infoToolSelectedGeoDataset').css('display', 'none')
$('#infoToolFilter').css('display', 'none')
$('#infoToolNoneSelected').css('display', 'block')
},
selectedDropdownChange: function (idx) {
let e = JSON.parse(JSON.stringify(InfoTool.initialEvent))
MetadataCapturer.populateMetadata(
InfoTool.featureLayers[idx] || InfoTool.currentLayer,
() => {
Kinds.use(
L_.layers.data[InfoTool.currentLayerName]?.kind || null,
Map_,
InfoTool.info[idx],
InfoTool.featureLayers[idx] || InfoTool.currentLayer,
InfoTool.currentLayerName,
null,
e,
{ idx: idx },
InfoTool.info,
InfoTool.featureLayers[idx] ? InfoTool.featureLayers : null
)
}
)
},
hotKeyEvents: function (event) {
if (event.shiftKey && !event.ctrlKey && !event.metaKey) {
// Shift
// Nav Overlap
if (event.key === 'ArrowLeft') {
if (InfoTool.activeFeatureI > 0)
InfoTool.selectedDropdownChange(InfoTool.activeFeatureI - 1)
} else if (event.key === 'ArrowRight') {
if (InfoTool.activeFeatureI < InfoTool.info.length - 1)
InfoTool.selectedDropdownChange(InfoTool.activeFeatureI + 1)
}
} else if ((event.ctrlKey || event.metaKey) && !event.shiftKey) {
// Ctrl/Cmd
if (InfoTool.hasDataset) {
// Nav Dataset
if (event.key === 'ArrowLeft') {
$('#infoToolSelectedDatasetLeft').trigger('click')
} else if (event.key === 'ArrowRight') {
$('#infoToolSelectedDatasetRight').trigger('click')
}
} else if (InfoTool.hasGeoDatasetMetadata) {
// Nav Geodataset
if (event.key === 'ArrowLeft') {
$('#infoToolSelectedGeoDatasetLeft').trigger('click')
} else if (event.key === 'ArrowRight') {
$('#infoToolSelectedGeoDatasetRight').trigger('click')
}
}
}
},
}
//
function interfaceWithMMGIS() {
this.separateFromMMGIS = function () {
separateFromMMGIS()
}
InfoTool.vars = L_.getToolVars('info')
//Add event functions and whatnot
InfoTool.use(
null,
null,
InfoTool.info,
InfoTool.variables,
null,
true,
null,
null,
InfoTool.featureLayers
)
document.addEventListener('keydown', InfoTool.hotKeyEvents)
//Share everything. Don't take things that aren't yours.
// Put things back where you found them.
function separateFromMMGIS() {
document.removeEventListener('keydown', InfoTool.hotKeyEvents)
}
}
//Other functions
export default InfoTool