Change the appearance of a feature layer with a renderer.
Use case
A feature layer hosted on ArcGIS Online has a preset renderer and will display in your app with that renderer. However, for example, the color associated with the original renderer may be unsuitable for a company with staff or clients who are color blind, or for presentation with a different set of basemap and operational layers. In these cases, the renderer on the feature layer's data can be set to a more suitable color.
How to use the sample
Use the button in the control panel to change the renderer on the feature layer. The original renderer displays red polygons around parcels that do not have a pool permit. When the blue renderer in this sample is applied, all parcels are indicated by blue polygons.
A SimpleRenderer is created with a SimpleLineSymbol. When the button is clicked, the renderer property on the FeatureLayer is set to the new SimpleRenderer.
How it works
Create a ServiceFeatureTable from a URL.
Create a FeatureLayer from the service feature table.
Create a new renderer (in this case, a SimpleRenderer).
Change the feature layer's renderer using featureLayer.renderer.
Relevant API
FeatureLayer.renderer
ServiceFeatureTable
SimpleRenderer
About the data
This sample displays a feature layer showing areas that do or do not have pool permits.
Tags
feature layer, renderer, visualization
Sample Code
FeatureLayer_ChangeRenderer.qml
Use dark colors for code blocksCopy
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
// [WriteFile Name=FeatureLayer_ChangeRenderer, Category=Features]// [Legal]// Copyright 2016 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 QtQuick.Controls
import Esri.ArcGISRuntime
Rectangle {
width: 800height: 600// Map view UI presentation at topMapView {
id: mapViewanchors.fill: parentwrapAroundMode: Enums.WrapAroundModeDisabled
Component.onCompleted: {
// Set the focus on MapView to initially enable keyboard navigation forceActiveFocus();
}
Map {
Basemap {
initStyle: Enums.BasemapStyleArcGISTopographic
}
// create the feature layerFeatureLayer {
id: featureLayer// feature tableServiceFeatureTable {
id: featureTableurl: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0" }
}
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusLoaded) {
mapView.setViewpoint(viewPoint);
}
}
}
SimpleRenderer {
id: rendererSimpleLineSymbol {
style: Enums.SimpleLineSymbolStyleSolid
color: "blue"antiAlias: truewidth: 2 }
}
ViewpointExtent {
id: viewPointextent: Envelope {
xMin: -13075816.4047166yMin: 4014771.46954516xMax: -13073005.6797177yMax: 4016869.78617381spatialReference: SpatialReference {
wkid: 102100 }
}
}
}
Row {
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
margins: 5bottomMargin: 25 }
spacing: 5// button to change rendererButton {
text: "Change Renderer"enabled: featureTable.loadStatus === Enums.LoadStatusLoaded
onClicked: {
featureLayer.renderer = renderer;
}
}
}
}