使GMSCircle响应点击? [英] Make GMSCircle respond to tap?

查看:178
本文介绍了使GMSCircle响应点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS的Google Maps API,因此我想这样做,所以当您点击GMSCircle时,它会弹出我在其他地方编写的小东西.我已将圆圈设置为可轻敲",但找不到需要设置或监听的水龙头.我该怎么用?

I am using the Google Maps API for iOS and I want to make it so when you tap on a GMSCircle it pops up a little thing I coded elsewhere. I have set the circle to "tappable" but I cannot find what I need to set or make to listen for the tap. What do I use?

    CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(10,10);
GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter
                                         radius:10];
circ.tappable = true;
[circ setFillColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:.5]];

circ.map = mapView_;

推荐答案

您需要使用委托方法此处的参数覆盖表示被点击的覆盖.因此,您需要检查它是否等于circ.

Here the parameter overlay indicates the overlay that was tapped. So you need to check if it equals circ.

编辑:添加有关如何在didTapOverlay中检查圆圈的详细信息

EDIT : Adding details on how to check for circle within didTapOverlay

GMSCircle添加到地图时,还将创建相应的GMSPolygon.如果将圆形设置为可点击,则在点击它时,传递给didTapOverlay方法的叠加层是此相关的多边形,而不是圆形.因此,无法在覆盖层和圆之间进行直接比较.因此,正如Raspu所指出的那样,您可以使用circ.title =在title中设置一个值,然后在didTapOverlay内部,可以检查overlay.title是否与circ.title相同.之所以可行,是因为圆的title属性位于相应的多边形内,因此将出现在overlay参数中.

When GMSCircle is added to the map, a corresponding GMSPolygon is also created. If the circle is set as tappable, then on tapping it, the overlay passed to the didTapOverlay method is this related polygon and not the circle . So a direct comparison between the overlay and the circle is not possible. Hence as Raspu as pointed out, you can set a value in title using circ.title = and then inside didTapOverlay, you can check if overlay.title is same as circ.title. This works because the title property of the circle is within the corresponding polygon and hence will be present in the overlay parameter.

这篇关于使GMSCircle响应点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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