Touch Delegate - Cancelling Gesture Immediately After Starting

1286
5
05-25-2017 09:06 AM
IsmaelZavala
New Contributor

I want to override the touch methods (touchesBegan, touchesEnded) because AGSGeoViewTouchDelegate doesn't provide methods to pick up when touches end in general. Only long press and taps. 

In the previous version (10.2) I was able to override the touchesEnded without an issue, but after upgrading to version 100, as I'm dragging the map, immediately after I start dragging, the method touchesCancelled gets called before I lift my finger. 

It is an issue because I am creating a custom animation when the user starts changing the view of the map and another animation when the user stops moving the map. 

Any assistance on how I could go around this issue would be greatly appreciated. 

Tags (1)
0 Kudos
5 Replies
GagandeepSingh
Occasional Contributor II

Can the use case or animation be achieved using `viewpointChangedHandler` on `AGSMapView`? So, say if you want to keep a UIView/NSView constant with respect to a location on map view. In each invocation of `viewpointChangedHandler` you will convert the map view location to screen point and move the UIView to that point.

0 Kudos
IsmaelZavala
New Contributor

Thank you for your response, unfortunately this wouldn't be a solution for my issue. This could solve me performing the first animation when a user starts moving the map. But I would need another method when the user stops moving the map to perform the second animation. 

I also noticed in the notes for this method it says, 

"This handler may get invoked up to 60 times per second, for example, when a pan or zoom animation is in progress. Do not perform any heavy-lifting in this handler as it may adversely impact the rendering performance."

Thank you very much for the suggestion

0 Kudos
GagandeepSingh
Occasional Contributor II

Can you explain what kind of animation you are doing on interaction with map. May be there is another way to achieve that.

0 Kudos
IsmaelZavala
New Contributor

The animation isn't technically on the map. Its two views that are above the mapview layer that I want to imitate how other mapping apps have where when you move the map, the pin animates up and separates itself from the center dot. 


When the user stops interacting with the map, I am animating the pin down to be over the center dot. 

0 Kudos
MarkDostal
Esri Contributor

If you need to know when the user is starts or stops navigating on the map with interaction then KVO on this property on AGSMapView (via AGSGeoView):

@property (nonatomic, assign, readonly, getter=isNavigating) BOOL navigating;

private var myContext = 0 // outside class definition

...

mapView.addObserver(self, forKeyPath: "navigating", options: .new, context: &myContext)

...

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {

        if context == &myContext {

            if keyPath == "navigating" {

                print("navigation: \(mapView.isNavigating ? "Started" : "Stopped")")

            }

        } else {

            super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)

        }

    }

0 Kudos