Select to view content in your preferred language

Xamarin Forms - MapView.SketchEditor.StartAsync right after pinch to zoom

1589
5
06-13-2018 02:12 PM
PaulFarrow1
Emerging Contributor

Ok so we have the mapview.sketcheditor.startasync with a freehandpolygon in a loop and we can draw the polygon and geometry is returned, we can then keep drawing polygons one after the other with no problem.  We then pinch to zoom the map and the first mapview.sketcheditor.startasync after that doesn't draw a freehand polygon but instead pans the map and returns a null geometry,  after the pan we can then draw a polygon.

This feels like an Esri bug.

1. Has anyone else experienced this?

2. What did you do to get around it?

Thanks


Paul

0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor

Thank you for your feedback. We ignore multi-touch gestures for sketch editor. Which version of the api are you using? To better assist, can you share which platform and code?

You may also try to disable sketch editor in code this way...

var pinchGestureRecognizer = new PinchGestureRecognizer();
pinchGestureRecognizer.PinchUpdated += (s, e) =>
  {
      if (MyMapView.SketchEditor.IsEnabled)
              MyMapView.SketchEditor.IsEnabled = e.Status == GestureStatus.Canceled || e.Status == GestureStatus.Completed;                  
  };
MyMapView.GestureRecognizers.Add(pinchGestureRecognizer);‍‍‍‍‍‍‍

To cancel or complete sketch in v100.x, use Cancel/CompleteCommand.

if (MyMapView.SketchEditor.CancelCommand.CanExecute(null))
     MyMapView.SketchEditor.CancelCommand.Execute(null);

You may check SketchEditor.Geometry property and MyMapView.GeometryChanged events. For Freehand, you should get this event on mouse/touch up.

0 Kudos
PaulFarrow1
Emerging Contributor

Thank you for replying.  This is on Xamarin forms and exhibits the same behavor on iOS and Android.  We are using 100.2.1 runtime.

I am not sure how that helps me.  Setting the IsEnabled to false does not help the issue.

Basically I have to pan the map before something internally allows the sketcheditor to resume giving back geometry otherwise geometry is null after a zoom of the map.

I will try to create a basic example of it and call the support line or can I call you somehow?

0 Kudos
PaulFarrow1
Emerging Contributor

UPDATE: Just in case any one else is facing this issue - I logged a support call and ESRI agreed its a bug in the 100.2.1 runtime and has been marked as a bug with the tracking id of BUG-000114899.

0 Kudos
RichZwaap
Frequent Contributor

I believe I've found a workaround for this issue.  Essentially, it involves listening for the MapView's NavigationCompleted event, then, when fired, forcing completion of the current freehand polygon sketch, replacing the MapView's SketchEditor instance with a new one, and starting a new freehand polygon sketch with the completed sketch's Geometry.  I've attached a sample that encapsulates this workaround in an extension method to the MapView called SketchFreehandPolygonAsync.  That method can be called in place of MapView.SketchEditor.StartAsync.  Although stopping and starting the sketch session and replacing the SketchEditor on navigation completion seems a bit heavy-handed, it seemed to work without any notable side effects in the bit of testing I did on an Android and iOS device.

Hope this helps.

0 Kudos
PaulFarrow1
Emerging Contributor

So I tried this before in our application and had issues.  I tried it in my little example I gave you guys and it appears to work but within our application I hit what I hit before which is I  seem to have a cascading cancel exception which doesn't allow the sketch to continually loop.  I have put a couple of days effort into this over the week since you posted and I still cant get it to succeed successfully in our application.  Is this something I could screen share with you or are we closer to getting a proper fix for this?

0 Kudos