How to show simple GeoJson on the map?

616
2
07-11-2023 12:35 AM
JulianBissekkou
New Contributor III

Hello everybody,

I have a simple Geojson that I want to display on my map. I parsing the json using 

`AGSFeatureCollection.fromJSON()` and then adding a `AGSFeatureCollectionLayer(featureCollection: collection)` to the map using `mapView.map!.operationalLayers.add(layer)`

 

This shows nothing and I think it fails at the first step where I parse it into a FeatureCollection because `unknownJSON` contains all the data.

Am I using an unsupported format or is something missing?

Thanks in advance.

 

 

Example json:
```

{
"features": [
{
"geometry": {
"type": "LineString",
"coordinates": [
[
6.123123123,
52.8912817381
],
[
6.123141241,
52.12313122
]
]
},
"type": "Feature",
"properties": {
"oid": 9
}
},
{
"geometry": {
"type": "LineString",
"coordinates": [
[
13.11,
50.15
],
[
12.214123,
48.12312
]
]
},
"type": "Feature",
"properties": {
"oid": 5
}
},
{
"geometry": {
"type": "LineString",
"coordinates": [
[
9.231231,
52.1231312
],
[
9.123123,
52.123131
]
]
},
"type": "Feature",
"properties": {
"oid": 4
}
}
],
"type": "FeatureCollection"
}


```

0 Kudos
2 Replies
Ting
by Esri Contributor
Esri Contributor

Hi Julian, unfortunately Runtime iOS SDK doesn't fully support GeoJSON, unlike the GeoJSONLayer API in Javascript. 🙁 Runtime does support very simple GeoJSON such as creating a geometry, but not much else. There are a few options:

1. Publish the GeoJSON file to ArcGIS Online and consume it as a feature layer. See the doc here.

2. Break the feature collection into separate geometries manually.

3. Use tools to convert it to other formats that Runtime supports. 

0 Kudos
Ting
by Esri Contributor
Esri Contributor

p.s., here is an answer from my colleague Nick that may help you: https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/polygons-as-feature-layer/m-p/127...

0 Kudos