I created a geodatabase via ArcGIS Runtime Content in ArcMap.
I am trying to add it via this reference: Create an offline map—ArcGIS Runtime SDK for Qt | ArcGIS for Developers
BUT map.addLayer does not exist or its giving me an error
Any ideas?
//Declare the geodatabase
Geodatabase {
id: geodatabase
path: "/path_to_my_geodatabase/mydata.geodatabase"
}
FeatureLayer {
id: featureLayer
featureTable: geodatabase.geodatabaseFeatureTableByLayerId(0);
}
map.addLayer(featureLayer);
Solved! Go to Solution.
Jay,
Based on the sample Feature Layer (Geodatabase),
- AppStudio Sample - arcgis-appstudio-samples/MyApp.qml at v4.0 · Esri/arcgis-appstudio-samples · GitHub
- ArcGIS Runtime Qt/QML Sample - Feature layer (geodatabase) | ArcGIS for Developers
You don't need to call addLayer if you initialize the FeatureLayer inside Map, that layer is already added.
Looping in ArcGIS Runtime SDK for Qt, to see why addLayer is throwing an error.
Thank you,
Erwin
Forgot to add I am using QML for AppStudio
Jay,
Based on the sample Feature Layer (Geodatabase),
- AppStudio Sample - arcgis-appstudio-samples/MyApp.qml at v4.0 · Esri/arcgis-appstudio-samples · GitHub
- ArcGIS Runtime Qt/QML Sample - Feature layer (geodatabase) | ArcGIS for Developers
You don't need to call addLayer if you initialize the FeatureLayer inside Map, that layer is already added.
Looping in ArcGIS Runtime SDK for Qt, to see why addLayer is throwing an error.
Thank you,
Erwin
There is no addLayer method on Map. Instead, you can nest the layer inside the Map like you mentioned, or you can call map.operationalLayers.append(), and add the layer via that method LayerListModel QML Type | ArcGIS for Developers .
can I still reference the index of the gdb like this
featureTable: geodatabase.geodatabaseFeatureTableByLayerId(4); OK going to test that now. THANKS
Think I got it...THANK YOU SO MUCH.....
Seems I could not use
featureTable: gdb.geodatabaseFeatureTableByLayerId(4);
But had to use
featureTable: gdb.geodatabaseFeatureTablesByTableName["WMAs_1"];
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Esri.ArcGISRuntime 100.6
//import Esri.ArcGISExtras 1.1
Rectangle {
id: navigateOnline
width: 800
height: 600
property string errorMessage: ""
signal previous(string message)
property string lecaDataPath: app.mmpkManager.fileUrl3
// Map view UI presentation at top
MapView {
anchors.fill: parent
Rectangle{
id: stupidrectangle
width: 300
height: 50
Column{
id: searchBar22
width: 300
spacing: 0
Text {
text: lecaDataPath
width: 300
wrapMode: Text.WordWrap
}
}
}
Map {
id: map
// set an initial viewpoint
ViewpointCenter {
Point {
x: -8778929
y: 44521052
spatialReference: SpatialReference { wkid: 3857 }
}
targetScale: 35e4
}
BasemapTopographic {}
//! [FeatureLayer Geodatabase create]
// create a feature layer
FeatureLayer {
// obtain the feature table from the geodatabase by name
//featureTable: gdb.geodatabaseFeatureTableByLayerId(4);
featureTable: gdb.geodatabaseFeatureTablesByTableName["WMAs_1"]
// create the geodatabase
Geodatabase {
id: gdb
path: lecaDataPath
onErrorChanged: errorMessage = error.message;
}
onErrorChanged: errorMessage = error.message;
}
onErrorChanged: errorMessage = error.message;
}
onErrorChanged: errorMessage = error.message;
}
Dialog {
modal: true
x: Math.round(parent.width - width) / 2
y: Math.round(parent.height - height) / 2
standardButtons: Dialog.Ok
visible: text.length > 0
property alias text : textLabel.text
property alias informativeText : detailsLabel.text
ColumnLayout {
Text {
id: textLabel
text: errorMessage
}
Text {
id: detailsLabel
text: "Please consult the README.md"
}
}
}
}
Any idea how to read this geodatabase and or get a list of the features that it contains?
You could loop through the geodatabaseFeatureTables list:
Geodatabase {
id: gdb
path: dataPath + "geodatabase/LA_Trails.geodatabase"
onErrorChanged: console.log(error.message)
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusLoaded) {
console.log("number of feature tables:", geodatabaseFeatureTables.length)
for (var i = 0; i < geodatabaseFeatureTables.length; i++) {
var ft = geodatabaseFeatureTables[i];
var fl = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: ft});
map.operationalLayers.append(fl);
}
}
}
Component.onCompleted: load()
}
So your example would read the geodatabase and create multiple Feature Layer objects to display the multiple features in the geodatabase?
yes that is what this example does.