如何使用Google Maps SDK for iOS检测点在Polygon内? [英] How to detect that a point is inside a Polygon using Google Maps SDK for iOS?

查看:156
本文介绍了如何使用Google Maps SDK for iOS检测点在Polygon内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用适用于iOS的Google Maps SDK,是否可以检测到多边形内的某个点?

With the Google Maps SDK for iOS, is it possible to detect that a point is inside a Polygon?

我在Google Maps JavaScript API中找到了containsLocation()函数但是,我在iOS SDK中找不到相同的那个。

I found containsLocation() function in Google Maps JavaScript API, however, I couldn't find the same one in the iOS SDK.

你知道其他任何方法吗?

Do you know any other ways?

推荐答案

谷歌地图SDK for iOS现在包含一个名为 GMSGeometryContainsLocation 的函数,它将帮助您使用一行代码。

The Google Maps SDK for iOS now contains a function called GMSGeometryContainsLocation, which will help you out with a single line of code.

if (GMSGeometryContainsLocation(yourPoint, pathOfPolygon, YES)) {
    NSLog(@"YES: you are in this polygon.");
} else {
    NSLog(@"You do not appear to be in this polygon.");
}

来源: Google Maps for iOS - 参考 - GMSGeometryUtils

这篇关于如何使用Google Maps SDK for iOS检测点在Polygon内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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