【发布时间】:2013-07-31 14:09:38
【问题描述】:
我想点击并按住map 以添加带有google maps api 的pin。
是IOS的教程吗?
GMSMarker *marker;
【问题讨论】:
标签: ios google-maps map
我想点击并按住map 以添加带有google maps api 的pin。
是IOS的教程吗?
GMSMarker *marker;
【问题讨论】:
标签: ios google-maps map
您能否像使用 MKMapView 一样将 UILongPressGestureRecognizer 添加到您的 GMSMapView 中?我现在不在 Mac 上,所以我无法测试这个理论。
如果是,则使用 locationInView 检测屏幕上的触摸位置:
- (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gesture
{
CGPoint pointInView = [gesture locationInView:mapView];
}
然后找到相对于屏幕上点的位置坐标:
CLLocationCoordinate2D coordinate =
[mapView.projection coordinateForPoint: point];
然后按照谷歌地图SDK文档Add a marker
GMSMarker *marker = [GMSMarker markerWithPosition:coordinate];
marker.title = @"Hello World";
marker.map = mapView;
希望对您有所帮助,或让您走上正轨。抱歉,我现在无法测试它是否有效!
【讨论】: