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.
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
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.