Select to view content in your preferred language

How to use SketchEditor Freehand v100.1

1589
11
07-10-2017 08:26 AM
FrancisGagne
Emerging Contributor

I tried to use the new SketchEditor. There's not much info on it beside the API doc, so here's my code:

if (viewerModel.getMapView().getSketchEditor() == null) {
SketchEditor sketch = new SketchEditor();
viewerModel.getMapView().setSketchEditor(sketch);
sketch.start(SketchCreationMode.FREEHAND_LINE);
} else {
viewerModel.getMapView().getSketchEditor().stop();
viewerModel.getMapView().setSketchEditor(null);
}

When I start the freehand sketch, the map pan with my movement so the line created is barely moving. I tried to overide the map onTouchListener onScroll , but it seems the SketchEditor is already doing that. There's probably another step I need to make I guess?

Can you help?

0 Kudos
11 Replies
AlexanderNohe1
Honored Contributor

Have you tried overriding

public boolean onTouch (View view, MotionEvent event)

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/mapping/..., android.view.MotionEvent)

I have not had to get a chance to test this out as I was out the last two weeks or so.  Additionally, this week may be tough as it is UC week (hopefully I will have a chance to review it soon)

0 Kudos
FrancisGagne
Emerging Contributor

Yes, I already tried that.

mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(viewerModel.getContext(), mapView) {
@Override
public boolean onScroll(MotionEvent from, MotionEvent to, float distanceX, float distanceY) {
    System.out.println("test");
    return true;
}
});

When I set it before the .start(), I have the same behavior and there's no log. The drawing is showing but it's just a mess of line below my finger since the map is paning.
When I set it after, no drawing is showing, the test log is shown and the pan is desactivated.

0 Kudos
AlexanderNohe1
Honored Contributor

I was referring to the onTouch, not the onScroll.  When you override that, do you see the behavior you wish?

0 Kudos
FrancisGagne
Emerging Contributor

If I override the onTouch listener with nothing, the map won't do much...

The problem is, when I draw freehand on the map, the paning  should be desactivated.

The SketchEditor.start() overwrites the touch listeners since it needs to know where the user draw. The problem in the SDK is probably just because super.onScroll() is called in the overriding.

0 Kudos
AlexanderNohe1
Honored Contributor

Hi Francis Gagne‌,

I had a chance to test it out myself.  I am at UC this week so when I get a chance, I will try to walk over to the Android SDK guys tomorrow and show them what I am seeing as well and see what we can do about it.  I am really only seeing the map pan when I drag my finger quickly across the map.  If I draw anything else, the map does not pan as it regularly would.  Are you seeing the map pan like it regularly would or seeing it pan only if you draw quickly?  Just want to confirm we are seeing the same behavior...

Thanks,

Alexander

0 Kudos
FrancisGagne
Emerging Contributor

Hello Alexander,

I did some testing with the other creation mode yesterday and I just reverted to the freehand and it seems to works fine now, beside the bug that you mentioned: if I draw a shape quickly, the map moves at the end of the movement. 

We already had that problem when we created our own drawing tool, so you only have to override some more listener during the FREEHAND_POLYGON and FREEHAND_LINE. 

mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) {
   @Override
   public boolean onFling(MotionEvent from, MotionEvent to, float velocityX, float velocityY) {
     boolean handled = false;
      if (mapView.getSketchEditor().getSketchCreationMode().equals(SketchCreationMode.FREEHAND_LINE) 
             || mapView.getSketchEditor().getSketchCreationMode().equals(SketchCreationMode.FREEHAND_POLYGON) {
         handled = true;
      }
    return handled;
   }
});


0 Kudos
AlexanderNohe1
Honored Contributor

Yeah, I am working with my resources regarding the quick movement. Do you see that quick movement being part of your regular workflow?  Is this something you believe your users will run into often?

0 Kudos
FrancisGagne
Emerging Contributor

Oh yes asolutely, it needs to be resolved.

0 Kudos
AlexanderNohe1
Honored Contributor

Do you have an idea of how many people this is affecting in regards to your application?  This helps build a case regarding this issue.

0 Kudos