Google Maps for iOS - 如何判断标记是否位于屏幕范围内? [英] Google Maps for iOS - How can you tell if a marker is within the bounds of the screen?

查看:178
本文介绍了Google Maps for iOS - 如何判断标记是否位于屏幕范围内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一种简单的方法来确定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屋!

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