I'm trying to add new features (socket) via queryFeatures:
My graphic object:
{"geometry":{"spatialReference":{"wkid":4326},"x":4.39725,"y":51.23578},"symbol":null,"attributes":{"OBJECTID":244024786,"id":244024786,"courseOverGround":"348.1","fiveMinuteMark":"false","length":"50.0","maxDraught":"8.3","oneMinuteMark":"false","poaCalculatedSpeedInMeterPerSecond":"7.987","poaStationarySinceUtcTime":null,"shipKind":"UNKNOWN","speedOverGroundInMeterPerSecond":"5.6","width":"8.0"},"popupTemplate":null}
I would like to add this graphic object to the layers source with:
layer.queryFeatures({
where: "1=1",
returnGeometry: true,
outFields: ["*"]
}).then((data: any) => {
const edits = { addFeatures: [pointGraphic] } // new graphic see above
layer.applyEdits(edits);
}).catch((e: any) => {
...
});
But when it's queried. The OBJECT ID is overwritten and it gets ID = 1.
Solution?
Solved! Go to Solution.
ObjectIds are determined by the FeatureLayer (client-side) or Feature Service. You can't override them. If it's an existing feature, you can use the updateFeatures. If you need it as a reference, from another source, I've seen people add it as a refObjectId field or similar so they can refer back to where the feature originally came from.
ObjectIds are determined by the FeatureLayer (client-side) or Feature Service. You can't override them. If it's an existing feature, you can use the updateFeatures. If you need it as a reference, from another source, I've seen people add it as a refObjectId field or similar so they can refer back to where the feature originally came from.