Add GeometryChanged event to the new GeometryEditor

433
7
Jump to solution
11-22-2023 06:54 AM
StefanKallin
New Contributor II

We have recently begun moving our apps to the new v200.x SDK.

During this process we have noticed that the old SketchEditor had a GeometryChanged event that seems to be missing in the new GeometryEditor.

Parts of our user interactions rely on being able to capture changes to the currently edited geometry to display values (like the radius of a circle) to the user during editing.

Are there any plans to add this event to the GeometryEditor or is there another way to solve this issue?

0 Kudos
1 Solution

Accepted Solutions
StefanKallin
New Contributor II

@williambohrmann3 and @ShellyGill1 

Terribly sorry for reporting something that is in fact not a problem at all.

I used search and replace to refactor the code from using the SketchEditor into using the GeometryEditor.

I completely missed the fact that the old code used an async/await pattern and that the event listener was disconnected at the end of the method. The new code is not async at all so the reason I did not get any events was because I just did not listen to them. My bad!

Thanks for your efforts and replies! I hope that my next post (if any) will be related to an actual issue... 😉

View solution in original post

0 Kudos
7 Replies
williambohrmann3
Esri Contributor

Hi @StefanKallin thanks for your post. You might try subscribing to the GeometryEditor PropertyChanged event. In the handler, you could conditionally check to see if this event was triggered by a geometry property change. For example:

 

mapView.GeometryEditor.PropertyChanged += (s, e) =>
{
    if (e.PropertyName == nameof(mapView.GeometryEditor.Geometry))
    {
        // Geometry has changed
    }
};

 

You can also modify the `nameof()` call with other GeometryEditor properties to have different logic when other property changes raise this event.

0 Kudos
StefanKallin
New Contributor II

Hi @williambohrmann3, sadly the PropertyChanged event is not fired when the geometry changes. I should have menitioned in my post that I have already tried this. It was my hope that this event should solve my problem but unfortunately it does not.

0 Kudos
williambohrmann3
Esri Contributor

I haven't been able to reproduce this myself. Would you kindly provide some code?

0 Kudos
ShellyGill1
Esri Contributor

Hi @StefanKallin - can you describe the scenario where you're not getting the event? If you're using the default VertexTool, and have clicked/tapped to add a vertex - for example - I'd expect it to fire at that point, or any other time the geometry value changes (like when you start the geometry editor with an existing geometry object).

However I wonder if your situation is that you want the event during a drag operation - for example in the middle of dragging/moving a vertex from one location to another using the VertexTool, or maybe during the initial creation of a circle or ellipse with the ShapeTool? I'd expect in both these cases that during the drag operation you dont get geometryChanged event on every mouse move increment of the drag operation, but it should happen when you release the mouse (or release the touch pointer if you're working on a touch device), as that's when the geometry property value is updated. Also same goes for the drag operation of a rotate or scale or move of a whole geometry or a part. If that is the specific case you're dealing with then we'd love to hear about your use case and perhaps you could post in ArcGIS Ideas for Native Maps SDKs about this requirement - we could consider enhancing the events in a future release.

0 Kudos
StefanKallin
New Contributor II

@williambohrmann3 and @ShellyGill1 

Terribly sorry for reporting something that is in fact not a problem at all.

I used search and replace to refactor the code from using the SketchEditor into using the GeometryEditor.

I completely missed the fact that the old code used an async/await pattern and that the event listener was disconnected at the end of the method. The new code is not async at all so the reason I did not get any events was because I just did not listen to them. My bad!

Thanks for your efforts and replies! I hope that my next post (if any) will be related to an actual issue... 😉

0 Kudos
williambohrmann3
Esri Contributor

Glad you were able to figure out your issue! 👏 In case you missed it, there's a great blog post on moving from SketchEditor -> GeometryEditor.

0 Kudos
ShellyGill1
Esri Contributor

No worries, glad it's working for you now @StefanKallin  😀..

0 Kudos