查找mapView中显示的标记

Jay*_*ayo 10 google-maps-sdk-ios swift

我正在尝试确定当前在mapview中显示的标记.我研究了以下方法:

self.mapView.bounds.contains(markers[0].position)

但该contains命令接受CGPoint或CGRect.在除Swift之外的其他平台中,contains可以接受标记的位置.

如何将标记的位置转换为接受contains

Juu*_*uul 8

使用mapview的当前projection.使用调用的投影方法containsCoordinate检查标记的位置是否在投影内,即当前可见.

所以类似于:

let coord = marker.position
let isVisible = self.mapview.projection.containsCoordinate(coord)
Run Code Online (Sandbox Code Playgroud)

https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_projection.html#aa6ad29e6831e40f00435c3aaeda8e08a