Hi,
I'm building a very custom application with 4.x and I'm struggling with duplicating functionality that I have in my current 3.x application.
Here's what I want to be able to do:
Watch this short screencast to see what I mean.
In 3.x that was super easy to do using the edit toolbar, like this:
editToolbar = new Edit(map);
//Once the feature is selected
editToolbar.activate(Edit.MOVE | Edit.SCALE | Edit.EDIT_VERTICES, feature);
How can I do the same thing in 4.x?
Thanks!
Matt
Moving a single feature seems pretty straightforward with 4.x. Have you seen this demo of the Editor Widget? It got some major updates in the 4.23 release.
Hi @BlakeTerhune ,
Thanks for the response, and thanks for pointing me back to the Editor widget demo! I saw it before, but I couldn't see how to move features. Now I see... you have to click Select under Edit Features. Once I do that, and select a feature, then it does exactly what I want.
If I go with that solution, I'm still stuck with using the Editor widget, which doesn't really fit into my flow. Is there a way I can use that tool, but hide the widget and pass in the feature before I start it?
Thanks,
Matt
@MattStayner wrote:If I go with that solution, I'm still stuck with using the Editor widget, which doesn't really fit into my flow. Is there a way I can use that tool, but hide the widget and pass in the feature before I start it?
Possibly, but I haven't worked with editing in 4.x yet so I really can't advise how to go about customizing that functionality. Hopefully someone else with more experience can contribute to this conversation.
The key here is using the SketchViewModel module. This is admittedly brief, but here's the basic flow:
@JoelBennett This looks like just what I need. It is a bit convoluted (coping graphics to other layer and back again), but if it works, that's OK. I will give it a go and report back here on my results. Thanks!
Convoluted it is, but it's the nature of the way things work in 4.x now that FeatureLayer no longer exposes a graphics property. This workflow is largely how the 4.x Editor widget works behind the scenes too.
I can't seem to get sketchViewModel working. I do something like this:
const updateOptions = { tool: "move" };
const newGraphic = graphic.clone();
graphic.visible = false;
await sketchViewModel.update([newGraphic], updateOptions);
graphic.geometry = this.view.toMap(e);
But I keep getting this error:
SketchViewModel.js:51 Uncaught (in promise) TypeError: h.remove is not a function
at f.n._setupUpdateOperation (SketchViewModel.js:51:462)
at f.n.update (SketchViewModel.js:18:246)
Any thoughts/help on what I'm doing wrong?
This would suggest that the layer property of the SketchViewModel has not been set. Please see step 3 of the process given previously.