【发布时间】:2016-04-29 03:10:24
【问题描述】:
我从 google maps api for iOS 切换到 here maps api for iOS 。我想在缩放时禁用地图的平移/滚动,以保持中心点的 gps 位置相同。有什么建议吗?提前致谢。
【问题讨论】:
标签: ios objective-c here-api
我从 google maps api for iOS 切换到 here maps api for iOS 。我想在缩放时禁用地图的平移/滚动,以保持中心点的 gps 位置相同。有什么建议吗?提前致谢。
【问题讨论】:
标签: ios objective-c here-api
你可以使用 [MPAMapView disableMapGestures:] 用于禁用平移/滚动的 API。 详情可查@https://developer.here.com/mobile-sdks/documentation/ios/topics/map-gestures.html
【讨论】:
您可以使用NMAMapGestureDelegate 和NMAMapViewDelegate 的组合来完成此用例。
例如,您可以实现NMAMapGestureDelegate - (void)mapView:(NMAMapView *)mapView didReceivePinch:(float)pinch atLocation:(CGPoint)location; 处理程序方法来添加一些额外的代码来禁用您希望阻止的手势。然后在捏合手势结束后重新启用手势。
这样的事情应该可以解决问题,您可能需要稍微尝试一下实现才能使其按照您的意愿工作:
- (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];
}
您也可以查看NMAMapView - (NSInteger)respondToEvents:(NSInteger)events withBlock:(NMAMapEventBlock)block。使用respondToEvents 响应NMAMapEventGestureEnded 事件可能更适合您的用例。
更多信息:
【讨论】:
NMAMap transformCenter 和fixedMapCenterOnMapRotateZoom
fixedMapCenterOnMapRotateZoom API 似乎只在高级 SDK 中。