获取触摸位置谷歌地图iOS

Fel*_*lix 4 uiview ios google-maps-sdk-ios

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

Vla*_*bas 6

如果我的问题是正确的,你想在Map的UIView中计算触摸位置的CGPoint吗?

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

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

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

- (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate;
Run Code Online (Sandbox Code Playgroud)

在Map的视图中为您提供触摸点.

希望能帮助到你 :)