Google Maps for iOS - 如何判断标记是否位于屏幕范围内? [英] Google Maps for iOS - How can you tell if a marker is within the bounds of the screen?
问题描述
我试图找出一种简单的方法来确定Google Maps for iOS,如果给定的GMSMarker位于可见地图的范围内。在Javascript API中似乎有这样的解决方案,但除了基于这篇文章似乎没有办法。
方案使用 GMSVisibleRegion 检索视口的边界并创建一个<一个href =https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_coordinate_bounds> GMSCoordinateBounds 。致电 containsCoordinate
,传入标记的位置。如果标记在视口内,它应该返回true,否则返回false。
I'm trying to figure out a straightforward way to determine in Google Maps for iOS if a given GMSMarker is within the bounds of the visible map. There seems to be solutions for this in the Javascript API but other than perhaps doing some complex reasoning based on this post there doesn't seem to be a way.
Retrieve the bounds of your viewport with GMSVisibleRegion and create a GMSCoordinateBounds with it. Call containsCoordinate
, passing in the marker's position. It should return true if the marker is within the viewport and false if not.
这篇关于Google Maps for iOS - 如何判断标记是否位于屏幕范围内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!