I am creating a GeoJSONLayer client-side using an example payload containing geojson data. ArcGIS auto-generates a `OBJECTID` attribute, and I'm hoping I can replace this value with an `id` feature property in my payload. My goal is to query for the feature using the id provided in my geojson data. I think GeoJSONLayer's objectIdField will do the trick, but I can't figure out how to implement it based off of the accompanying direction:
The name of an oid field containing a unique value or identifier for each feature in the layer. id property of the feature object in the GeoJSON will be used as ObjectID. If id property is not present and objectIDField is not specified, ObjectID field will be generated for each feature.
I've included a snippet of Geojson data I want to display below with the `id` property (0x1023) providing the new value for `ObjectID`.
{
"overlayId": "2d882141-0d9e-59d4-20bb-58e6d0460699.1",
"featureId": "example.geojson.1",
"format": "geojson",
"feature": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-15.9423828125,
-15.297068292853805
]
},
"properties": {
"sys_style": "default"
},
"name": "Point",
"id": "0x1023",
"description": "Feature Point Example"
}
]
}
}
However, if I create a GeoJSONLayer from the above data, ArcGIS simple autogenerates the ObjectID like usual (first feature has ObjectID = 1, and so on). I also tried setting GeoJSONLayer's `objectIdField` to `id`, but that didn't work either. I'm a bit stuck, as I couldn't find any examples online trying to accomplish what I am. Would appreciate any help.
this.layer = new GeoJSONLayer({
url: createUrl(geojson),
renderer: this.getRenderer(),
elevationInfo: {
mode: 'on-the-ground'
},
objectIdField: "id", // use the id in geojson data instead of the auto-generated OBJECTID as an attribute
});
}
private createUrl(geojson: GeoJSON.GeoJSON): string {
const blob: Blob = new Blob([JSON.stringify(geojson)], {
type: 'application/json'
});
return URL.createObjectURL(blob);
}