Symbolize a shapefile

Loading

Code

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3
import Esri.ArcGISExtras 1.1

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    property string dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/shp/"
    property real scaleFactor: System.displayScaleFactor

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            BasemapStreetsVector {}

            // Declare a FeatureLayer for displaying the shapefile
            FeatureLayer {
                id: featureLayer
                // Create a ShapefileFeatureTable pointing to the data location
                ShapefileFeatureTable {
                    path: dataPath + "Subdivisions.shp"
                }
            }

            // set an initial viewpoint
            ViewpointCenter {
                Point {
                    y: 4818336
                    x: -11662054
                    spatialReference: SpatialReference { wkid: 3857 }
                }
                targetScale: 200000
            }
        }
    }

    // Update the renderer on click
    Button {
        anchors {
            left: parent.left
            top: parent.top
            margins: 10 * scaleFactor
        }
        text: "Change Renderer"
        onClicked: {
            // apply the new renderer
            featureLayer.renderer = simpleRenderer;
            visible = false;
        }
    }

    // Create a SimpleRenderer
    SimpleRenderer {
        id: simpleRenderer

        SimpleFillSymbol {
            color: "yellow"
            style: Enums.SimpleFillSymbolStyleSolid

            SimpleLineSymbol {
                color: "red"
                style: Enums.SimpleLineSymbolStyleSolid
                width: 1
            }
        }
    }
}


In this topic
  1. Code