Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Feature layer (shapefile)

Sample Viewer View Sample on GitHub

Open a shapefile stored on the device and display it as a feature layer with default symbology.

Use case

Shapefiles store location, shape and attributes of geospatial vector data. Shapefiles can be loaded directly into ArcGIS Runtime.

How to use the sample

Pan and zoom around the map. View the data loaded from the shapefile.

How it works

  1. Create a ShapefileFeatureTable passing in the URL of a shapefile.
  2. Create a FeatureLayer using the shapefile feature table.
  3. Add the layer to the map's operation layers.

Relevant API

  • FeatureLayer
  • ShapefileFeatureTable

Offline data

Read more about how to set up the sample's offline data here.

Link Local Location
Public Art Shapefile <sdcard>/ArcGIS/Samples/ShapeFile/Aurora_CO_shp/Public_Art.shp

Tags

Layers, shapefile, shp, vector

Sample Code

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

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600
    
    readonly property url dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/shp/"

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            id: map
            BasemapStreetsVector {}

            FeatureLayer {

                ShapefileFeatureTable {
                    path: dataPath + "Public_Art.shp"
                }

                onLoadStatusChanged: {
                     if (loadStatus !== Enums.LoadStatusLoaded)
                         return;

                     mapView.setViewpointCenterAndScale(fullExtent.center, 80000);
                 }

            }
        }
    }
}