Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Feature layer change renderer

Sample Viewer View Sample on GitHub

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 an ArcGIS Runtime application 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.

How it works

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

  1. Create a ServiceFeatureTable from a URL.
  2. Create a FeatureLayer from the service feature table.
  3. Create a new renderer (in this case, a SimpleRenderer).
  4. 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

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.9

Rectangle {
    width: 800
    height: 600

    

    // Map view UI presentation at top
    MapView {
        id: mapView

        anchors.fill: parent
        wrapAroundMode: Enums.WrapAroundModeDisabled

        Map {
            BasemapTopographic {}

            // create the feature layer
            FeatureLayer {
                id: featureLayer

                // feature table
                ServiceFeatureTable {
                    id: featureTable
                    url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0"
                }
            }

            onLoadStatusChanged: {
                if (loadStatus === Enums.LoadStatusLoaded) {
                    mapView.setViewpoint(viewPoint);
                }
            }
        }

        SimpleRenderer {
            id: renderer

            SimpleLineSymbol {
                style: Enums.SimpleLineSymbolStyleSolid
                color: "blue"
                antiAlias: true
                width: 2
            }
        }

        ViewpointExtent {
            id: viewPoint
            extent: Envelope {
                xMin: -13075816.4047166
                yMin: 4014771.46954516
                xMax: -13073005.6797177
                yMax: 4016869.78617381
                spatialReference: SpatialReference {
                    wkid: 102100
                }
            }
        }
    }

    Row {
        anchors {
            bottom: parent.bottom
            left: parent.left
            right: parent.right
            margins: 5
            bottomMargin: 25
        }
        spacing: 5

        // button to change renderer
        Button {
            text: "Change Renderer"
            enabled: featureTable.loadStatus === Enums.LoadStatusLoaded
            onClicked: {
                featureLayer.renderer = renderer;
            }
        }
    }
}