【问题标题】:Get touch position google maps iOS获取触摸位置谷歌地图iOS
【发布时间】:2014-03-31 16:53:43
【问题描述】:

GMSMapView 创建一个处理手势识别器的 UIView,我想检测用户在 UIView 中的哪个位置进行触摸,我可以获得标记位置(相对于地图坐标),但我想要触摸在视图上的当前位置.有什么想法吗?。

【问题讨论】:

    标签: ios uiview google-maps-sdk-ios


    【解决方案1】:

    如果我答对了,你想在 Map 的 UIView 中计算触摸位置的 CGPoint 吗?

    所以,你有一个从 Delegate 的方法获得的 CLLocationCoordinate2D,你可以通过调用 GMSMapview 上的 GMSProjection 对象来获取它的位置,例如:

    - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
     CGPoint locationInView = [mapView.projection pointForCoordinate:coordinate]; // capitalize the V
    }
    

    并且 locationInView 将是所需的位置。所以,GMSProjection 的方法

    - (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate;
    

    在地图视图中为您提供触摸点。

    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-31
      • 2013-04-13
      • 1970-01-01
      • 2021-09-11
      • 2019-09-23
      • 2017-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多