Select to view content in your preferred language

Add Geodatabase layer to Map

653
3
03-05-2019 01:38 PM
LaurynasGedminas2
Regular Contributor

How to add local Geodatabase feature class grammatically to the Map object created thru: ArcGISRuntimeEnvironment.createObject("Map",{});  ?

Thank you

0 Kudos
3 Replies
LucasDanzinger
Esri Frequent Contributor

Here is some code to do this - arcgis-runtime-samples-qt/FeatureLayer_Geodatabase.qml at master · Esri/arcgis-runtime-samples-qt · ... 

Essentially you need to:

- Create a Geodatabase object via the path to the local file - Geodatabase QML Type | ArcGIS for Developers 

- Iterate through the list of GeodatabaseFeatureTable objects - Geodatabase QML Type | ArcGIS for Developers 

- For each feature table, create a Feature Layer by setting the featureTable property - FeatureLayer QML Type | ArcGIS for Developers 

- Add the FeatureLayers to the Map's operational layer list model

0 Kudos
LaurynasGedminas2
Regular Contributor

I am trying to create the Map object from Geodatabase layer:

var geodb = ArcGISRuntimeEnvironment.createObject("Geodatabase", {path: outputGdb});
var t1 = geodb.geodatabaseFeatureTablesByTableName["offline_test"];
var fc = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: t1
           });
var map2 = ArcGISRuntimeEnvironment.createObject("Map",{});
map2.operationalLayers.append(fc);
mapView.map = map2;

Map loads with no data, is this wrong way to load GB data programmatically?

Thank you,
0 Kudos
LaurynasGedminas2
Regular Contributor
Proper way:

var geodb = ArcGISRuntimeEnvironment.createObject("Geodatabase", {
                                                                    path: outputGdb});
geodb.loadStatusChanged.connect(function () {
     if (Enums.LoadStatusLoaded === geodb.loadStatus) {
                        var tables = geodb.geodatabaseFeatureTables;
                        var t1 = geodb.geodatabaseFeatureTablesByTableName["offline_test"];
                        var fc = ArcGISRuntimeEnvironment.createObject("FeatureLayer", 
                           {featureTable: t1});
                        var map = ArcGISRuntimeEnvironment.createObject("Map",{});
                        map.operationalLayers.append(fc);
                        mapView.map = map;
       }

})

Thank you,

0 Kudos