Raster 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 { wkid: 4326 }
                }
                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.geoPackageRasters.length > 0)
                return;

            // Get the first raster
            var gpkgRaster = gpkg.geoPackageRasters[0];
            // Create a RasterLayer with the raster
            var rasterLayer = ArcGISRuntimeEnvironment.createObject("RasterLayer", {raster: gpkgRaster});
            // Append the layer to the map
            map.operationalLayers.append(rasterLayer);
        }
    }
}


In this topic
  1. Code