Disable panning while zooming

跟風遠走 提交于 2019-12-24 13:59:38

问题


I switched from google maps api for iOS to here maps api for iOS . I would like to disable panning/scrolling of map while zooming in order to keep gps location of centre point same. Any suggestion? Thanks in advance.


回答1:


You could use [MPAMapView disableMapGestures:] apis to disable panning/scrolling. Details could be found @ https://developer.here.com/mobile-sdks/documentation/ios/topics/map-gestures.html




回答2:


You can accomplish this use case using a combination of NMAMapGestureDelegate and NMAMapViewDelegate.

For example, you can implement the NMAMapGestureDelegate - (void)mapView:(NMAMapView *)mapView didReceivePinch:(float)pinch atLocation:(CGPoint)location; handler method to add some extra code to disable the gestures you wish to block. And then re-enable the gestures once the pinch gesture has ended.

Something like this should do the trick, you may have to play with the implementation a bit to get it working how you would like:

- (void)mapView:(NMAMapView *)mapView didReceivePinch:(float)pinch atLocation:(CGPoint)location
{
    [mapView disableMapGestures:(NMAMapGestureTypePan | NMAMapGestureTypeTwoFingerPan)];

    // execute default pinch behaviour
    [mapView.defaultGestureHandler mapView:mapView didReceivePinch:pinch atLocation:location];
}

...

- (void)mapViewDidEndMovement:(NMAMapView *)mapView
{
    [mapView enableMapGestures:NMAMapGestureTypeAll];
}

You can look at NMAMapView - (NSInteger)respondToEvents:(NSInteger)events withBlock:(NMAMapEventBlock)block as well. It's possible responding to the NMAMapEventGestureEnded event using respondToEvents may work better for your use case.

More Information:

Map Gestures

NMAMapGestureDelegate

NMAMapViewDelegate

Map Event Blocks



来源:https://stackoverflow.com/questions/36915704/disable-panning-while-zooming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!