Select to view content in your preferred language

Exporting client side features

370
2
Jump to solution
08-19-2024 08:14 PM
Aeseir
by
Frequent Contributor

Using arcgis js there is a scenario where featurelayer is created with client side features, i want to be able to extract those features for further processing, is it possible to do so?

Note the feature layer is not hosted, and ideally shape file or geojson format would be great.

0 Kudos
1 Solution

Accepted Solutions
Aeseir
by
Frequent Contributor

Hey @MatthewDriscoll , thanks for sharing.

toJSON() doesn't export it to geojson format, it only converts it to an instance of this class to its ArcGIS portal JSON representation per documentation.

 

However in saying that, I ended up building a transformer that takes toJSON and converts them to geoJSON format.

View solution in original post

0 Kudos
2 Replies
MatthewDriscoll
MVP Alum

For geojson you can query the feature you want to extract, get the graphics and use its properties to extract the geojson.

 

 

let newGraphic = new GraphicsLayer();
newGraphic.listMode = "hide";
theMap.add(newGraphic);

newGraphic.addMany(results.features);
newGraphic.listMode = "hide";

var graphJSON = []
graphJSON.push(newGraphic.graphics.toJSON())

 

Aeseir
by
Frequent Contributor

Hey @MatthewDriscoll , thanks for sharing.

toJSON() doesn't export it to geojson format, it only converts it to an instance of this class to its ArcGIS portal JSON representation per documentation.

 

However in saying that, I ended up building a transformer that takes toJSON and converts them to geoJSON format.

0 Kudos