【问题标题】:Disable panning while zooming缩放时禁用平移
【发布时间】:2016-04-29 03:10:24
【问题描述】:

我从 google maps api for iOS 切换到 here maps api for iOS 。我想在缩放时禁用地图的平移/滚动,以保持中心点的 gps 位置相同。有什么建议吗?提前致谢。

【问题讨论】:

    标签: ios objective-c here-api


    【解决方案1】:

    你可以使用 [MPAMapView disableMapGestures:] 用于禁用平移/滚动的 API。 详情可查@https://developer.here.com/mobile-sdks/documentation/ios/topics/map-gestures.html

    【讨论】:

      【解决方案2】:

      您可以使用NMAMapGestureDelegateNMAMapViewDelegate 的组合来完成此用例。

      例如,您可以实现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 事件可能更适合您的用例。

      更多信息:

      Map Gestures

      NMAMapGestureDelegate

      NMAMapViewDelegate

      Map Event Blocks

      【讨论】:

      • 我已经尝试在执行捏合时禁用手势。问题是,如果您捏住边缘,即不在地图中心。地图中心移开。在谷歌地图 iOS sdk 中,同样可以通过 gmsuisettings 类的 allowScrollGesturesDuringRotateOrZoom 属性来实现。
      • 听起来你应该尝试使用NMAMap transformCenterfixedMapCenterOnMapRotateZoom
      • 您好安德鲁,感谢您的快速回复。尽管在文档中定义了 fixedMapCenterOnMapRotateZoom 属性,但不幸的是,该属性似乎已在 SDK 3.1.1 版中删除
      • 您使用的是 HERE 高级版 SDK 还是入门版 SDK? fixedMapCenterOnMapRotateZoom API 似乎只在高级 SDK 中。
      • 我正在使用高级 sdk 90 天试用版。
      猜你喜欢
      • 2017-08-22
      • 1970-01-01
      • 2012-01-20
      • 2017-01-15
      • 1970-01-01
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多