How I can reload or change path property of ShapefileFeatureTable on Appstudio for Arcgis ?

806
2
06-06-2020 03:35 PM
MustaphaEL_HAOUDAR
New Contributor

Hello,

I'm trying to change the path property of a ShapefileFeatureTable by a fileUrl taked from a FileDialog.

I'm trying with this code:

Mapview{

         id:mapView

         Map{

         FeatureLayer{

                     ShapefileFeatureTable{

                                       id:shpfile

                              }

                     }

               }

            }

FileDialog {
        id: fileDialog
        title: "Ouvrir un fichier shapefile"
        folder: shortcuts.home
        nameFilters: [ "Shapefile (*.shp)"]
        onAccepted: {      
               fileDialog.close
               shpfile.path=fileUrl
               shpfile.retryLoad()
               }
        onRejected: {
        fileDialog.close()

                           }

}

The Probem is: on the first add it's work, but on the second add it look like that the path does not change it remain the first Shapfile path.

Thank you for your Help

Tags (1)
0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

Mustapha, 

After reading the documentation from ArcGIS Runtime SDK for Qt‌, on ShapefileFeatureLayer, I think you need to call close() function before resetting the path again to forcefully remove all internal references to it.

ShapefileFeatureTable QML Type | ArcGIS for Developers  

Thank you,

Erwin

0 Kudos
LucasDanzinger
Esri Frequent Contributor

on the first add it's work, but on the second add it look like that the path does not change it remain the first Shapfile path.

If it works the first time, this is expected. The ShapefileFeatureTable is a Loadable object. Once it successfully reaches the loaded state, you cannot change the path and reload it. Details on this can be found in the guide topic for

Instead of trying to re-purpose the object and change the path, you'll need to instantiate a new shapefile feature table and feature layer and add it to the map.

For example (have not executed this, so there may be slight syntax issues...):

onAccepted: {
  var ft = ArcGISRuntimeEnvironment.createObject("ShapefileFeatureTable", {path: fileUrl});
  var fl = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: ft});
  map.operationalLayers.append(fl);
}