Detect tap on GMSPolyline in Swift?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm struggling with detecting a tap on a GMSPolyline drawn on my Google map, it works just fine with GMSpolygones, but the same approach doesn't seem to work with polyline. My current approach, which works for polygones, is: if (GMSGeometryContainsLocation(coordinate, polygon.path!, false)) { ... } Any suggestions how to detect taps on a polyline? Or just close to it? 回答1: According to their API documentation , GMSPolyline inherits from GMSOverlay which means a GMSPolyline has the property tappable . So you'd want something like this let