-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmpty.qml
More file actions
882 lines (700 loc) · 37.3 KB
/
Empty.qml
File metadata and controls
882 lines (700 loc) · 37.3 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
//------------------------------------------------------------------------------
//Author: vladimir.strukelj@guest.skogsstyrelsen.se
import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0
import QtPositioning 5.3
import QtQuick.Layouts 1.1
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import ArcGIS.AppFramework.Runtime 1.0
import ArcGIS.AppFramework.Runtime.Controls 1.0
import ArcGIS.AppFramework.Runtime 1.0
import "./Components"
App {
id: app
width: 800
height: 640
property real displayScaleFactor : AppFramework.displayScaleFactor
property bool isLandscape : width > height
property double scaleFactor: AppFramework.displayScaleFactor
property string appVisaSkogkulturnaturhansyn_2_0: "http://gedpagstest.skogsstyrelsen.se/arcgis/rest/services/App/AppVisaSkogkulturnaturhansyn_2_0/MapServer"
property var checkBoxes: []
property var mapCheckBoxes: []
property string skogsTiledMapService: "https://geodata.skogsstyrelsen.se/arcgis/rest/services/SkogligaGrunddata/ImageServer"
property string esriTiledMapServer: "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer"
ColumnLayout {
anchors.fill: parent
anchors.margins: 5 * displayScaleFactor;
GridLayout {
id: grid
Layout.fillHeight: true
Layout.fillWidth: true
columns: app.isLandscape ? children.length : 1
rows: app.isLandscape ? 1 : children.length
// LayoutMirroring.enabled: app.isLandscape
// LayoutMirroring.childrenInherit: true
// SidePanel {
// itemRotation: isPanelMinimised ? 180 : 0
// }
ContentBlock {
Map {
id: mainMap
anchors.fill: parent
extent: usExtent
focus: true
anchors.centerIn: parent
positionDisplay {
positionSource: PositionSource {
}
}
ZoomButtons {
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
margins: 30
}
}
//preloaded basemaps
ArcGISTiledMapServiceLayer {
id: baseMap
url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
name: "Esris"
visible: true
}
ArcGISImageServiceLayer{
id: skogsMapComponent
name: "Skogstyrelsens"
url: skogsTiledMapService
visible: false
}
//preloaded mapservice-layers
ArcGISDynamicMapServiceLayer {
url: appVisaSkogkulturnaturhansyn_2_0
id: appVisaSkogkulturnaturhansyn_2_0_Map
visible: true
}
// Starting map extent
Envelope {
id: usExtent
xMin: 850000
yMin: 8700000
xMax: 2800000
yMax: 9500000
spatialReference: mainMap.spatialReference
}
SimpleMarkerSymbol {
id: simpleMarkerSymbolIdentifyLocation
color: "blue"
style: Enums.SimpleLineSymbolStyleDashDot
size: 16
}
Graphic {
id: identifyGraphic
symbol: simpleMarkerSymbolIdentifyLocation
}
GraphicsLayer {
id: graphicsLayer
}
// Initiation of the identify task
onMouseClicked: {
resultsRow.visible = false;
identifyDialog.visible = false;
progressBar.visible = true;
graphicsLayer.removeAllGraphics();
var graphic1 = identifyGraphic.clone();
graphic1.geometry = mouse.mapPoint;
graphicsLayer.addGraphic(graphic1);
identifyParameters.geometry = mouse.mapPoint;
identifyParameters.mapExtent = mainMap.extent;
identifyParameters.mapHeight = mainMap.height;
identifyParameters.mapWidth = mainMap.width;
identifyParameters.layerMode = Enums.LayerModeVisibleLayers;
identifyParameters.DPI = Screen.pixelDensity * 25.4;
identifyTask.execute(identifyParameters);
}
//A Combobox for addition of entirely new maps or turn on/off current ones.
// Rectangle {
// anchors {
// fill: controlsColumn
// margins: -10
// }
// color: "lightgrey"
// radius: 5
// border.color: "black"
// opacity: 0.77
// }
// Column {
// id: controlsColumn
// anchors {
// left: parent.left
// top: parent.top
// margins: 20 * scaleFactor
// }
// spacing: 10 * scaleFactor
// Button {
// id: loadButton
// text: "Välj karta"
// style: okButton.style
// opacity: loadButton.hovered ? 1 : 0.5
// onClicked: {
// loadBack.visible = true
// loadLayerColumn.visible = true
// }
// }
// }
// Rectangle {
// anchors.fill: parent
// id: overlay
// color: "#000000"
// opacity: 0.6
// MouseArea {
// anchors.fill: parent
// }
// visible: loadLayerColumn.visible
// Rectangle {
// id: loadBack
// anchors {
// horizontalCenter: parent.horizontalCenter
// verticalCenter: parent.verticalCenter
// }
// clip: true
// width: loadLayerColumn.width + 30 * scaleFactor
// height: loadLayerColumn.height + 30 * scaleFactor
// color: "white"
// radius: 5 * scaleFactor
// border.color: "white"
// visible: loadLayerColumn.visible
// }
// }
// Column {
// id: loadLayerColumn
// anchors {
// horizontalCenter: parent.horizontalCenter
// verticalCenter: parent.verticalCenter
// }
// spacing: 10 * scaleFactor
// visible: false
// Text {
// text: "Välj karta:"
// font.pixelSize: 14 * scaleFactor
// }
// ComboBox{
// id: choseMapComboBox
// width: 180 * scaleFactor
// height: 40 * scaleFactor
// style: ComboBoxStyle{
// label: Text {
// verticalAlignment: Text.AlignVCenter
// horizontalAlignment: Text.AlignHCenter
// font.pointSize: 10 * scaleFactor
// font.capitalization: Font.SmallCaps
// color: "black"
// text: control.currentText
// }
// }
// model: [baseMap.name, skogsMapComponent.name]
// }
// Row {
// spacing: 10 * scaleFactor
// Button {
// id: okButtonMap
// text: "Ok"
// style: okButton.style
// opacity: okButtonMap.hovered ? 1 :0.5
// onClicked: {
// loadLayerColumn.visible = false;
// // mainMap.reset();
// // var tiledMapService = choseMapComboBox.currentIndex === 0 ? ArcGISRuntime.createObject("ArcGISTiledMapServiceLayer") : ArcGISRuntime.createObject("ArcGISImageServiceLayer");
// // tiledMapService.url = choseMapComboBox.currentIndex === 0 ? baseMap.url : skogsMapComponent.url;
// skogsMapComponent.visible = choseMapComboBox.currentIndex === 0 ? false : true;
// // mainMap.addLayer(tiledMapService);
// }
// }
// Button {
// id: cancelMapButton
// text: "Cancel"
// style: okButton.style
// opacity: cancelMapButton.hovered ? 1 : 0.5
// onClicked: loadLayerColumn.visible = false
// }
// }
// }
//SettingsButton
Rectangle {
id: feedbackRectangle
anchors {
fill: messageColumn
margins: -10 * scaleFactor
}
color: "#31cc3b"
radius: 5 * scaleFactor
border.color: "white"
border.width: 3
opacity: feedbackRectangle.activeFocus ? 1 : 0.75
Text {
id: infoText
text: qsTr("Knacka här för inställningar.")
color: "white"
anchors.centerIn: feedbackRectangle
font.pixelSize: 12 * scaleFactor
font.bold: true
}
}
//identifyDialog, where all the results are shown
Item {
id: identifyDialog
visible: false
anchors.fill: parent
Rectangle {
id: dialogRectangle
color: "#31cc3b"
width : parent.width
height: parent.height
anchors.fill: app
ListView {
model: fieldsModel
id: fieldsView
//flickableData: elem
anchors.fill: parent
anchors.bottomMargin: 80
contentWidth: parent.width
contentHeight: parent.height
clip: true
delegate: Text {
text: {
if(name=== "error")
text = "Inget objekt hittat!";
else
text = name + ": " + value;
}
color: "white"
font.pixelSize: 14 * scaleFactor
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
}
}
Button {
id: infoButton
anchors {
bottomMargin: 20 * scaleFactor
horizontalCenter: parent.horizontalCenter
top: fieldsView.bottom
}
text: "<b>OK</b>"
style: loginButton.style
opacity: infoButton.hovered ? 1 : 0.5
onClicked: identifyDialog.visible = false;
}
}
}
// Progress bar
Row {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 5 * scaleFactor
}
ProgressBar {
id: progressBar
indeterminate: true
visible: false
}
}
Flickable{
id: flickServices
width: parent.width
height: parent.height
contentHeight: 30*50*scaleFactor
contentWidth: parent.width
visible: false
Rectangle{
id: mapServiceRec
anchors.fill: parent
color: "#31cc3b"
visible: parent.visible
Text{
text: qsTr("Välj bort eller lägg till genom att knacka.")
color: "white"
anchors{
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: 10* scaleFactor
}
font.pixelSize: 14 * scaleFactor
font.bold: true
}
onVisibleChanged: {
if(mapServiceRec.visible === true)
createCheckBoxes();
}
}//mapServiceRec
}
Rectangle{
id: mapOptionRec
anchors.fill: parent
color: "#31cc3b"
visible: false
Column{
id: mapOptionCol
anchors{
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
visible: parent.visible
onVisibleChanged: {
if(mapOptionRec.visible === true){
var checkBoxDef = "import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
CheckBox{
id: checkBSkogsStyrelsen
checked: mainMap.layerByName('Skogstyrelsens').visible ? true : false;
visible: parent.visible
Text{
text: '<b>SkogligaGrunddata<b>'
font.pixelSize: 14 * scaleFactor
color: '#FFFFFF'
anchors.centerIn: parent
wrapMode: Text.WrapAnywhere
}
style: CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 250 * scaleFactor
implicitHeight: 50 * scaleFactor
radius: 3
border.color: control.activeFocus ? 'darkblue' : 'gray'
border.width: 1
Rectangle{
visible: control.checked
color: '#228e29'
border.color: '#333'
radius: 1
anchors.margins: 4
anchors.fill: parent
}
Rectangle{
visible: !control.checked
color: 'grey'
radius: 1
anchors.margins: 4
anchors.fill: parent
}
}
}
onCheckedChanged: {
updateMapVisibility(mainMap.layerByName('Skogstyrelsens').name,checked);
}
onVisibleChanged: {
if(this.visible === false)
this.destroy();
}
}";
var currentBox = Qt.createQmlObject(checkBoxDef, mapOptionCol, 'objSkogsStyrelsens');
mapCheckBoxes.push(currentBox);
}
}
}
Text{
text: qsTr("Välj bort eller lägg till genom att knacka.")
color: "white"
anchors{
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: 10* scaleFactor
}
font.pixelSize: 14 * scaleFactor
font.bold: true
}
}//mapOptionRec
//Settings/Options
Rectangle{
id: optionsRec
visible: false
anchors.fill: parent
color: "#31cc3b"
Column{
anchors{
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
visible: parent.visible
Button{
id: mapChoiceButton
text: "<b>Baskartor</b>"
visible: parent.visible
style: loginButton.style
onClicked: {
mapOptionRec.visible = true;
optionsRec.visible = false;
}
}
Button{
id: servicesChoiceButton
text: "<b>Karttjänster</b>"
visible: parent.visible
style: loginButton.style
onClicked: {
flickServices.visible = true;
optionsRec.visible = false;
}
}
}
}
Button{
id: okButton
text: "<b>Till kartläge</b>"
visible: false
anchors{
margins: 10 * scaleFactor
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
}
style: loginButton.style
opacity: okButton.hovered ? 1 : 0.7
onClicked: {
flickServices.visible = false;
okButton.visible = false;
optionsRec.visible = false;
mapOptionRec.visible = false;
}
}
MouseArea{
id: infoRecArea
anchors.fill: feedbackRectangle
hoverEnabled: true
onClicked:{
okButton.visible = true;
optionsRec.visible = true;
}
}
Column {
id: messageColumn
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
margins: 20 * scaleFactor
}
width: 280 * scaleFactor
spacing: 10 * scaleFactor
Row {
id: intructionsRow
spacing: 10 * scaleFactor
visible: true
width: parent.width
Text {
text: qsTr("")
font.pixelSize: 14 * scaleFactor
width: parent.width
wrapMode: Text.WordWrap
visible: true
}
}
Row {
id: resultsRow
spacing: 10 * scaleFactor
visible: false
width: parent.width
Text {
id: resultText
text: qsTr("")
font.pixelSize: 14 * scaleFactor
width: parent.width
wrapMode: Text.WordWrap
visible: true
anchors.centerIn: app
}
}
}
}
ListModel {
id:fieldsModel
}
// Identify task components
IdentifyParameters {
id: identifyParameters
}
IdentifyTask {
id: identifyTask
url: appVisaSkogkulturnaturhansyn_2_0
onIdentifyTaskStatusChanged: {
if (identifyTaskStatus === Enums.IdentifyTaskStatusCompleted) {
resultText.text = "";
fieldsModel.clear();
for (var index in identifyResult) {
var result = identifyResult[index];
var attributeNameDisplayed;
var checkVisLayer = "";
for(var attributeIndex in result.feature.attributeNames){
var attributeName = result.feature.attributeNames[attributeIndex];
if(appVisaSkogkulturnaturhansyn_2_0_Map.subLayerByName(result.layerName).visible){
var attributeValue = result.feature.attributeValue(attributeName);
if(attributeName !== attributeNameDisplayed && attributeName !== "shape"){
fieldsModel.append({"name": attributeName, "value" : attributeValue});
attributeNameDisplayed = attributeName;
}
}
}
}
if(fieldsModel.count === 0)
fieldsModel.append({"name": "error", "value": ""});
identifyDialog.visible = true;
if(Qt.platform.os !== "ios" && Qt.platform.os != "android") {
identifyDialog.width = 365 * scaleFactor
identifyDialog.height = 400 * scaleFactor
}
progressBar.visible = false;
} else if (identifyTaskStatus === Enums.IdentifyTaskStatusErrored) {
resultText.text = identifyError.message;
resultsRow.visible = true;
identifyDialog.visible = false;
progressBar.visible = false;
}
}
}//IdentifyTask
Rectangle{
id: loginRec
anchors.fill: parent
color: "#31cc3b"
visible: true
Image {
id: loginImage
source: "front.jpg"
anchors.horizontalCenter: parent.horizontalCenter
}
Text{
text:"Här finns registrerade hänsynskrävande skogsområden och kulturlämningar i svenska skogar. Dessutom kan du via GPS se din egen position i kartan på telefonen eller plattan."
color: "white"
anchors{
top: loginImage.bottom
right: parent.right
left: parent.left
margins: 15* scaleFactor
}
wrapMode: Text.Wrap
font.pixelSize: 20 * scaleFactor
font.bold: true
}
Row {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 5 * scaleFactor
}
ProgressBar {
id: loginBar
indeterminate: true
visible: false
}
}
Button {
id: loginButton
anchors {
bottomMargin: 40 * scaleFactor
horizontalCenter: loginRec.horizontalCenter
bottom: loginRec.bottom
}
text: "<b>OK</b>"
style: ButtonStyle {
background:Rectangle {
implicitWidth: 150 * scaleFactor
implicitHeight: 50 * scaleFactor
border.width: control.activeFocus ? 2 : 1
border.color: "#888"
radius: 5
color: "white"
opacity: control.hovered ? 0.8 : 0.5
}
label: Text {
text: control.text
color:"white"
font.pixelSize: 14 * scaleFactor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
onClicked:{
loginBar.visible = true;
if(baseMap.status === 2){
loginBar.visible = false;
loginRec.visible = false;
loginButton.visible = false;
}
else{
loginButton.text = "Försök igen!";
}
}
}//loginButton
}//loginRec
}//ContentBlock
}//GridLayout
}
//Creates a new checkbox for each layer.
function createCheckBoxes(){
for(var i in appVisaSkogkulturnaturhansyn_2_0_Map.layers){
var margin = 50 * scaleFactor;
var checkBoxDef = "import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
CheckBox{
id: checkB"+i+"
checked: appVisaSkogkulturnaturhansyn_2_0_Map.layers["+i+"].visible ? true : false;
visible: parent.visible
Text{
text: '<b>' + appVisaSkogkulturnaturhansyn_2_0_Map.layers["+i+"].name + '<b>'
font.pixelSize: 14 * scaleFactor
color: '#FFFFFF'
anchors.centerIn: parent
wrapMode: Text.WrapAnywhere
}
style: CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 250 * scaleFactor
implicitHeight: 50 * scaleFactor
radius: 3
border.color: control.activeFocus ? 'darkblue' : 'gray'
border.width: 1
Rectangle{
visible: control.checked
color: '#228e29'
border.color: '#333'
radius: 1
anchors.margins: 4
anchors.fill: parent
}
Rectangle{
visible: !control.checked
color: 'grey'
radius: 1
anchors.margins: 4
anchors.fill: parent
}
}
}
anchors{
top: parent.top
topMargin: "+ (margin + margin * i)+"
horizontalCenter: parent.horizontalCenter
}
onCheckedChanged: {
updateVisibility("+i+",checked);
}
onVisibleChanged: {
if(this.visible === false)
this.destroy();
}
}";
var currentBox = Qt.createQmlObject(checkBoxDef, mapServiceRec, 'obj' + i);
checkBoxes.push(currentBox);
}//forloop
}
function updateMapVisibility(layerName, visible){
mainMap.layerByName(layerName).visible = visible;
}
function updateVisibility(layerIndex, visible) {
appVisaSkogkulturnaturhansyn_2_0_Map.layers[layerIndex].visible = visible;
appVisaSkogkulturnaturhansyn_2_0_Map.refresh();
}
}