-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.qml
153 lines (126 loc) · 4.72 KB
/
test.qml
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
// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//
import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.0
ApplicationWindow {
id: appWindow
width: 800
height: 600
title: "Quick"
property var featureTableHouses: null
property var featureTableSchools: null
property var schoolGeometry: null
onFeatureTableHousesChanged: {
if (featureTableHouses === null)
return;
featureTableHouses.queryFeaturesStatusChanged.connect(function() {
if (featureTableHouses.queryFeaturesStatus === Enums.TaskStatusCompleted) {
if (!featureTableHouses.queryFeaturesResult.iterator.hasNext) {
errorMsgDialog.visible = true;
return;
}
// clear any previous selection
map.operationalLayers.get(0).layers[0].clearSelection();
var features = []
// get the features
while (featureTableHouses.queryFeaturesResult.iterator.hasNext) {
features.push(featureTableHouses.queryFeaturesResult.iterator.next());
}
map.operationalLayers.get(0).layers[0].selectionWidth = 15;
console.log("Query returned", features.length, "results")
map.operationalLayers.get(0).layers[0].selectFeatures(features);
}
});
}
onFeatureTableSchoolsChanged: {
if (featureTableSchools === null)
return;
featureTableSchools.queryFeaturesStatusChanged.connect(function() {
if (featureTableSchools.queryFeaturesStatus === Enums.TaskStatusCompleted) {
if (!featureTableSchools.queryFeaturesResult.iterator.hasNext) {
errorMsgDialog.visible = true;
return;
}
// clear any previous selection
map.operationalLayers.get(1).layers[0].clearSelection();
var features = []
// get the features
while (featureTableSchools.queryFeaturesResult.iterator.hasNext) {
var feature = featureTableSchools.queryFeaturesResult.iterator.next();
features.push(feature);
schoolGeometry = feature.geometry;
}
map.operationalLayers.get(1).layers[0].selectionWidth = 15;
console.log("Query returned", features.length, "results")
map.operationalLayers.get(1).layers[0].selectFeatures(features);
}
});
}
// add a mapView component
MapView {
anchors.fill: parent
// add a map to the mapview
Map {
id: map
initUrl: "http://www.arcgis.com/home/item.html?id=a95963333bf84055b7115dc60d10443e"
onLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded)
return;
// this one is not loaded wwhen the map is loaded, not sure why
var l = operationalLayers.get(0);
l.loadStatusChanged.connect(function() {
if (l.loadStatus === Enums.LoadStatusLoaded) {
featureTableHouses = l.layers[0].featureTable;
}
});
featureTableSchools = operationalLayers.get(1).layers[0].featureTable;
}
}
Button {
id: b1
text: "Bedrooms"
onClicked: {
featureTableHouses.queryFeatures(params);
}
}
Button {
id: b2
anchors.left: b1.right
text: "Find School"
onClicked: {
featureTableSchools.queryFeatures(schoolQuery);
}
}
Button {
id: b3
anchors.left: b2.right
text: "Find houses within radius"
onClicked: {
featureTableHouses.queryFeatures(schoolSpatialQuery);
}
}
}
QueryParameters {
id: params
whereClause: "BedRooms > 3"
}
QueryParameters {
id: schoolQuery
whereClause: "School='McKinley Elementary'"
}
QueryParameters {
id: schoolSpatialQuery
whereClause: "BedRooms > 3"
geometry: schoolGeometry ? GeometryEngine.buffer(schoolGeometry, 2000) : null
}
}