谷歌地图iOS sdk获取挖掘重叠坐标 [英] Google maps iOS sdk get tapped overlay coordinates

查看:84
本文介绍了谷歌地图iOS sdk获取挖掘重叠坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google地图iOS sdk。
i当用户点击一个叠加层时想获得触摸点的坐标。

有这个委托方法:

   - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate 

但是当你点击一个覆盖层或一个标记时它不会被调用。

我可以通过程序调用它(但是坐标参数缺失 - 这就是我想要的..)?
或者从这个位置获取位置:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ map $ )overlay

任何建议都很珍贵!

谢谢!

解决方案

UPDATE 6/2/15



将UITapGestureRecognizer拖放到地图上,然后从触摸点提取坐标。您的didTapAtCoordinate和didTapAtOverlay将继续如前所述。

  UITapGestureRecognizer * touchTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@选择器(tapTouchTap :)]; 
[self.view addGestureRecognizer:touchTap];

- (void)tapTouchTap:(UITapGestureRecognizer *)touchGesture
{
CGPoint point = [touchGesture locationInView:self.view];
CLLocationCoordinate2D coord = [self.mapView.projection coordinateForPoint:point];
NSLog(@%f%f,coord.latitude,coord.longitude);
}

ORIGINAL POST



您可能会丢失两段代码。
在头文件中采用GMSMapViewDelegate:

$ $ p $ @interface Map:UIViewController< GMSMapViewDelegate>

您还需要在您的viewDidLoad中设置委托:

  self.mapView.delegate = self; 

现在这个应该会为您启动:

<$ p

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate: coordinate.latitude,coordinate.longitude);
}


i'm working with Google maps iOS sdk. i want to get the coordinates of the touched point when user taps an overlay.

there is this delegate method:

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate

but it's not called when you tap an overlay or a marker.

can i call it programmatically (but coordinate parameter is missing-that's what i want..)? or get location from this:

- (void) mapView: (GMSMapView *) mapView  didTapOverlay: (GMSOverlay *) overlay

any suggestion's precious!

thanks!

解决方案

UPDATE 6/2/15

Just staple a UITapGestureRecognizer onto the map and then extract the coordinate from the touch point. Your didTapAtCoordinate and didTapAtOverlay will continue to fire as before.

  UITapGestureRecognizer *touchTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouchTap:)];
  [self.view addGestureRecognizer:touchTap];

-(void)tapTouchTap:(UITapGestureRecognizer*)touchGesture
{
  CGPoint point = [touchGesture locationInView:self.view];
  CLLocationCoordinate2D coord = [self.mapView.projection coordinateForPoint:point];
  NSLog(@"%f %f", coord.latitude, coord.longitude);
}

ORIGINAL POST

You are likely missing two snippets of code. Adopt the GMSMapViewDelegate in your header file:

@interface Map : UIViewController <GMSMapViewDelegate>

You also need to set the delegate in your viewDidLoad:

self.mapView.delegate = self;

Now this should fire for you:

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
    NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);
}

这篇关于谷歌地图iOS sdk获取挖掘重叠坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆