I'm trying to understand whether the following GeoJSON is invalid, needs to be reconfigured, or if I'm fighting a losing battle. I have a service that returns a FeatureCollection with 3 Features, each with a different geometry type. When I load this into the MapViewer, only the Features matching the first type are displayed. In this case, it's just one Polygon, but if there were other Polygons in the payload, they would show up, but LineStrings and Points would not. Based on another post, I'm thinking this is just how the ArcGIS tools are designed to work, though I'm gonna have a heck of a time convincing my colleagues of this based on one post in a forum. Am I trying to achieve something (putting multiple geometry types in a single GeoJSON payload) that's bound to fail? If so, is there any documentation around this? Any insight would be most appreciated.
Here's an example of what the service returns:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"_status": "grey",
"_title": "mid",
"_server_updated_at": "2024-03-14T16:49:08.565Z",
"updated_by_name": "Fred Flintstone",
"a_text_field": "mid",
"marker-color": "#B3B3B3"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ -81.66371706436922, 40.71829817504227 ],
[ -81.06224242161565, 39.31625234224697 ],
[ -80.26034775685123, 40.93560245921894 ],
[ -81.66371706436922, 40.71829817504227 ]
]
]
}
},
{
"type": "Feature",
"properties": {
"_status": "grey",
"_title": "long mid",
"_server_updated_at": "2023-12-06T18:50:26.849Z",
"updated_by_name": "Wilma Flintstone",
"a_text_field": "long mid",
"marker-color": "#B3B3B3"
},
"geometry": {
"type": "Point",
"coordinates": [ -80.25972907881545, 43.42321525687475 ]
}
},
{
"type": "Feature",
"properties": {
"_status": "grey",
"_title": "abc",
"_server_updated_at": "2023-11-15T17:49:59.679Z",
"updated_by_name": "Fred Flintstone",
"a_text_field": "abc",
"marker-color": "#B3B3B3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[ -77.57057954205416, 40.614879553515614 ],
[ -76.89765822721861, 39.74043573381558 ],
[ -77.36075502468489, 39.58287875921611 ]
]
}
}
]
}
Solved! Go to Solution.
Hi @ToddRunstein -
The information you found on the ArcGIS Pro documentation page is also documented in our ArcGIS Maps SDK for JavaScript GeoJSONLayer class: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html#limits
Each GeoJSONLayer will only accept one geometry type. If there are multiple types of geometries, only the type specified in geometryType will be loaded. If geometryType is not specified, it will default to the geometry type of the first geometry.
This limitation will be the same for Map Viewer since it uses this GeoJSONLayer class to create GeoJSON layers. If you want to have multiple geometry types using GeoJSON, you would have to create separate layers for each geometry type.
Well, I'm not sure whether the Map Viewer is using ArcGIS Pro tools, but if it is, I think I found the documentation I was looking for:
https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/json-to-features.htm
This tool "Converts feature collections in an Esri JSON formatted file (.json) or a GeoJSON formatted file (.geojson) to a feature class" and "specifies that a feature class must be composed of features of the same feature type". Finally, it says "When the input is a .geojson file, the attributes of the first record are used to define the schema of the output feature class".
That definitely describes the behavior I'm seeing. Unfortunately, I think that means returning GeoJSON is never going to work, at least, not with more than one geometry type. 😢
Hi @ToddRunstein -
The information you found on the ArcGIS Pro documentation page is also documented in our ArcGIS Maps SDK for JavaScript GeoJSONLayer class: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html#limits
Each GeoJSONLayer will only accept one geometry type. If there are multiple types of geometries, only the type specified in geometryType will be loaded. If geometryType is not specified, it will default to the geometry type of the first geometry.
This limitation will be the same for Map Viewer since it uses this GeoJSONLayer class to create GeoJSON layers. If you want to have multiple geometry types using GeoJSON, you would have to create separate layers for each geometry type.