ArcGIS Runtime SDK for Qt

Feature layer (GeoPackage)

Loading

Code

import QtQuick 2.6
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/gpkg/"

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            id: map
            BasemapLightGrayCanvas {}

            // Load the GeoPackage once the Map loads
            onLoadStatusChanged: {
                if (loadStatus === Enums.LoadStatusLoaded)
                    gpkg.load();
            }

            // set an initial viewpoint
            ViewpointCenter {
                Point {
                    y: 39.7294
                    x: -104.8319
                    spatialReference: SpatialReference.createWgs84()
                }
                targetScale: 200000
            }
        }
    }

    // Declare a GeoPackage
    GeoPackage {
        id: gpkg
        path: dataPath + "AuroraCO.gpkg"

        // Wait for the GeoPackage to load successfully
        onLoadStatusChanged: {
            if (loadStatus !== Enums.LoadStatusLoaded)
                return;

            if (!gpkg.geoPackageFeatureTables.length > 0)
                return;

            // Get the first feature table
            var gpkgFeatureTable = gpkg.geoPackageFeatureTables[0];
            // Create a FeatureLayer with the table
            var featureLayer = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: gpkgFeatureTable});
            // Append the layer to the map
            map.operationalLayers.append(featureLayer);
        }
    }
}


In this topic
  1. Code