Select to view content in your preferred language

Detect Map Pan/Zoom based on User's Touch/Pinch

8588
13
Jump to solution
12-14-2012 12:15 PM
AaronConnolly
Regular Contributor
Hello,

Is it possible with the SDK to discern the difference between programmatically panning/zooming the map and one actually touching and pinching the map?

I need to be able to tell the difference with my app.

1. Listening for the 'MapDidEndPanning' and 'MapDidEndZooming' event does not tell you whether or not the user panned/zoomed the map or whether or not you did so programmatically.
2. AGSMapViewTouchDelegate only provides methods for click, tap + hold, tap + hold + release, and tap + hold + move.

Thanks,
- Aaron
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Any word from you guys (ESRI) as to whether hooking up gesture recognizers is recommended or not?


No, it is not recommended to hooking up gesture recognizers. If you do so then it'll interfere the functionality of map. In current SDK, there is no easy way to differentiate between programmatically panning/zooming the map and one actually touching and pinching the map. However, the next version of the SDK will have that functionality.

Regards,
Nimesh

View solution in original post

0 Kudos
13 Replies
AaronConnolly
Regular Contributor
I'm thinking I'm going to have to hook up my own gesture recognizer for both panning and pinching. Has anyone else faced this problem?
0 Kudos
AaronConnolly
Regular Contributor
Piece of cake:

In view did load:

// Add gesture recognizers to map view
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(mapPannedByTouch:)];
UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(mapPinchedByTouch:)];
    
[self.mapView addGestureRecognizer:panGestureRecognizer];
[self.mapView addGestureRecognizer:pinchGestureRecognizer];


Then:

- (void)mapPannedByTouch:(UIGestureRecognizer*)gestureRecognizer {
    
    NSLog(@"map panned by touch!");
}

- (void)mapPinchedByTouch:(UIGestureRecognizer*)gestureRecognizer {
    
    NSLog(@"map pinched by touch!");
}
0 Kudos
AaronConnolly
Regular Contributor
After hooking up these gesture recognizers I notice that the map doesn't pan but a little bit after each pan. It looks like it might be conflicting with some of the map's default functionality.

Any word from you guys (ESRI) as to whether hooking up gesture recognizers is recommended or not?

Thanks,
- Aaron
0 Kudos
AaronConnolly
Regular Contributor
Hey guys,

I noticed that if you add the gesture recognizer code to the MapViewDemo project the map doesn't work. You can't pan or zoom the map afterward. Why is that? Incidentally I found this post that describes how to bubble touch events up from the map. Does this work? If so, why can't we use gesture recognizers instead?

http://forums.arcgis.com/threads/38228-How-to-catch-AGSMapView-touch-gestures

Thanks,
- Aaron
0 Kudos
AaronConnolly
Regular Contributor
After further investigation it seems you have to subclass AGSMapView and implement the touchesEnded event to do this. It is not clear, why, the gesture recognizers disable the map? Can we get clarification there?
0 Kudos
NimeshJarecha
Esri Regular Contributor
Any word from you guys (ESRI) as to whether hooking up gesture recognizers is recommended or not?


No, it is not recommended to hooking up gesture recognizers. If you do so then it'll interfere the functionality of map. In current SDK, there is no easy way to differentiate between programmatically panning/zooming the map and one actually touching and pinching the map. However, the next version of the SDK will have that functionality.

Regards,
Nimesh
0 Kudos
AaronConnolly
Regular Contributor
No, it is not recommended to hooking up gesture recognizers. If you do so then it'll interfere the functionality of map. In current SDK, there is no easy way to differentiate between programmatically panning/zooming the map and one actually touching and pinching the map. However, the next version of the SDK will have that functionality.

Regards,
Nimesh


Got it. Thanks Nimesh.
0 Kudos
FrankLin1
Emerging Contributor
By the way , when can we meet next version of the SDK ?

Frank
0 Kudos
NimeshJarecha
Esri Regular Contributor
The new version of ArcGIS SDK for iOS is available now.

Regards,
Nimesh
0 Kudos