Display a layer from a WFS service, requesting only features for the current extent.
Use case
WFS is an open standard with functionality similar to ArcGIS feature services. The ArcGIS Maps SDK for Qt support for WFS allows you to interoperate with open systems, which are often used in inter-agency efforts, like those for disaster relief.
How to use the sample
Pan and zoom to see features within the current map extent.
How it works
Create a WfsFeatureTable with a URL and table name.
Create a FeatureLayer from the feature table and add it to the map.
Listen for the MapView.navigatingChanged signal to detect when the user has stopped navigating the map.
When the user is finished navigating, use populateFromService to load the table with data for the current visible extent.
Relevant API
FeatureLayer
WfsFeatureTable
WfsFeatureTable.populateFromService
About the data
This service shows building footprints for downtown Seattle. For additional information, see the underlying service on ArcGIS Online.
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
// [WriteFile Name=DisplayWfsLayer, Category=Layers]// [Legal]// Copyright 2019 Esri.// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.// [Legal]import QtQuick
import Esri.ArcGISRuntime
Rectangle {
id: rootRectangleclip: truewidth: 800height: 600MapView {
id: mapViewanchors.fill: parentComponent.onCompleted: {
// Set the focus on MapView to initially enable keyboard navigation forceActiveFocus();
}
Map {
Basemap {
initStyle: Enums.BasemapStyleArcGISTopographic
}
FeatureLayer {
// Create WFS Feature Table from Get Capabilities URL and table nameWfsFeatureTable {
id: wfsFeatureTableurl: "https://dservices2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/services/Seattle_Downtown_Features/WFSServer?service=wfs&request=getcapabilities"tableName: "Seattle_Downtown_Features:Buildings"// Set feature request mode to manual - only manual is supported at v100.5.// In this mode, you must manually populate the table - panning and zooming// won't request features automatically.featureRequestMode: Enums.FeatureRequestModeManualCache
// Once the table is loaded, request to populate the cacheonLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded)
return;
populateWfsFeatureTable();
}
}
// Assign a renderer to the layerSimpleRenderer {
SimpleLineSymbol {
color: "red"width: 3style: Enums.SimpleLineSymbolStyleSolid
}
}
}
// Set initial viewpoint on the mapViewpointExtent {
Envelope {
id: initialExtentxMin: -122.341581yMin: 47.613758xMax: -122.332662yMax: 47.617207spatialReference: SpatialReference { wkid: 4326 }
}
}
}
// Populate with more features once done navigating to new extentonNavigatingChanged: {
if (navigating) {
return;
}
populateWfsFeatureTable();
}
}
functionpopulateWfsFeatureTable() {
// Create query parametersconst params = ArcGISRuntimeEnvironment.createObject("QueryParameters", {
geometry: mapView.visibleArea.extent,
spatialRelationship: Enums.SpatialRelationshipIntersects
});
// Populate features based on query wfsFeatureTable.populateFromService(params, false, ["*"]);
}
}