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.
Wondering how I replicate the button turning the layer off with your example....I like your example much more as it streamlines the process considerably....
Can I do this on the Geodatabase in your example? Set to false and then hit up the ID to set the visibility to true as in my example?
visible: false
Right now I am doing it individually with in a Feature Layer.
FeatureLayer {
id: wmas_1
visible: false
featureTable: gdb4.geodatabaseFeatureTablesByTableName["WMA_features"]
// create the geodatabase
Geodatabase {
id: gdb4
path: DataPathWMAs
onErrorChanged: errorMessage = error.message;
}
onErrorChanged: errorMessage = error.message;
}
On a button I turn it on and off as such
onClicked:{
if (checked == true){
wmas_1.visible = true
}else if (checked == false){
wmas_1.visible = false
}else{
console.log("something");
}
}
You could do something like:
onClicked:{
if (checked == true){
map.operationalLayers.get(0).visible = true
}else if (checked == false){
map.operationalLayers.get(0).visible = false
}else{
console.log("something");
}
}
I will have a couple geodatabases on the phone.
There will be a couple buttons/sliders in the app to turn on specific layers from specific geodatabases
How do I distinguish between the geodatabases and features in the geodatabase with the onclick of the button or slider.
I dont see you referencing the specific geodatabase and I assume the get(0) is getting the first reference index in the geodatabase?
I am doing this right now...
I am trying to set the Feature layer visible to FALSE
and when I move the switch it turns it one...
Although when I start the app it draws the features and is visible...the visible setting does not seem to be working....
Am I going about this correctly? Should I be using the Feature Layer Shell????
This gets even ore confusing when I add in another geodatabase with other feature tables...how do i specifically target those?
FeatureLayer {
id: wmas_1
visible: false
Geodatabase {
id: gdb
path: lecaDataPathWMAs
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);
}
}
}
}
}
T.Switch {
// SNIP
onClicked:{
if (checked == true){
wmas_1.visible = true
}else if (checked == false){
wmas_1.visible = false
}else{
console.log("xxxxx");
}
}
}
I think some of the concepts here are tripping you up a bit.
Geodatabase:
This is the container, similar to a File Geodatabase in desktop, which holds N number of feature tables (called "feature class" in the desktop).
GeodatabaseFeatureTable:
These live inside of the Geodatabase. This is the backing data, schema information, rendering info, and everything required to define each table of features. This is synonymous to a Feature Class in desktop
FeatureLayer:
This is the layer that does the display of a feature table. The feature table is the backing data (i.e. the model) and the feature layer is what displays on the map (i.e. the view)
So at a high level, what I would do is:
- Create a Geodatabase for each .geodatabase file you have.
- Load each Geodatabase and loop through each to obtain each feature table
- Create a feature layer from each feature table
- Add each feature layer to the map
- Somehow, store a reference to the specific layers you want to mention. The first idea that comes to mind is to store a json or some data structure that keeps track of the index position of the layer added to the map. In my snippet above where I call get and pass in 0, that is just getting the first item in the map. If you store the index for the specific layers you want to have visibility toggled for, you could hard code those in your button. If you instead wanted to be more dynamic and display a toggle checkbox for each layer in the map, you could create a ListView in QML code, and bind the model property directly to the map's operationalLayers list model, and each layer would display in the ListView.