I'm trying to allow the user to edit a graphic (to drag the points on a polyline) by clicking on it - I'm using GraphicsLayer. https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/td...On this post, I read that queryFeatures are not available on GraphicsLayer, and in order to query it, you have to convert the GraphicsLayer into a FeatureLayer.
I tried the solution from that past, with this code:
```
And I get the following error:
```{name: 'view:no-layerview-for-layer', details: {…}, message: 'No layerview has been found for the layer'}```
I'm not sure if using tracksLayer.graphics._items was correct. tracksLayer is my GraphicsLayer.
Also, I'm not sure of the use of objectIdField: "ObjectID" (I got that from the documentation).
Is there something I'm missing? Or is there another way to allow the user to edit the points on a polyline (in GraphicsLayer?) without being able to query it? This approach of having to change a GraphicsLayer to a FeatureLayer seems too complex, and maybe I should just redo everything and create a FeatureLayer from the start?
Thanks so much for the help!
Check out the section called "Add an array of client-side features" in the expand section called "Creating a FeatureLayer" in this help doc. Also, check out the 'dataUpdating' property of the FeatureLayerView.
Hi @JohnGrayson , thanks for your response! Are you referring to this portion?
let features = [
{
geometry: {
type: "point",
x: -100,
y: 38
},
attributes: {
ObjectID: 1,
DepArpt: "KATL",
MsgTime: Date.now(),
FltId: "UAL1"
}
},
...
];
// geometryType and spatialReference of the layer
// will be inferred from the first feature in the array
// if it has a geometry.
let layer = new FeatureLayer({
source: features, // autocast as a Collection of new Graphic()
objectIdField: "ObjectID"
});
This is what I was looking at as an example for my code. Instead of making a custom features array in the example, I just used tracksLayer.graphics._items (as that's what had my real data). Would I have to convert my data into that format? Thanks!