如何确定GMSMarker是否位于GMSPolygon(iOS Google Map SDK)内部 [英] How to determine if an GMSMarker is inside of GMSPolygon (iOS Google Map SDK)

查看:172
本文介绍了如何确定GMSMarker是否位于GMSPolygon(iOS Google Map SDK)内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从此链接,但不知道如何检查某个位置或注释(GMSMarker)是否位于Google Map SDK中的GMSPolygon内部。
所以请,如果有人有任何想法,请帮助我。

解决方案

我自己得到了答案。

在Google SDK中的GMSGeometryUtils.h文件中定义了一个内联函数:

  //返回| point |,CLLocationCoordinate2D位于路径内,GMSPath 
BOOL GMSGeometryContainsLocation(CLLocationCoordinate2D point,GMSPath * path,
BOOL geodesic);

它包含一个名为GMSGeometryContainsLocation的函数,它确定位置点是否位于多边形路径内。

  if(GMSGeometryContainsLocation(locationPoint,polygonPath,YES)){
NSLog(@locationPoint is in polygonPath。);
} else {
NSLog(@locationPoint不在polygonPath中。);
}

资料来源:GMSGeometryContainsLocation


I have gotten answer of the same question for apple map kit from this link, but don't have idea about how to check if some location or annotation (GMSMarker) is inside the GMSPolygon in Google Map SDK. So please, if anyone has any idea, help me.

解决方案

I got the answer by my own.

There is an inline function defined in GMSGeometryUtils.h file in Google SDK:

//Returns whether |point|,CLLocationCoordinate2D lies inside of path, GMSPath
    BOOL GMSGeometryContainsLocation(CLLocationCoordinate2D point, GMSPath *path,
                                 BOOL geodesic);

It contains a function called GMSGeometryContainsLocation, which determines whether location point lies inside of polygon path.

if (GMSGeometryContainsLocation(locationPoint, polygonPath, YES)) {
    NSLog(@"locationPoint is in polygonPath.");
} else {
    NSLog(@"locationPoint is NOT in polygonPath.");
}

Source: GMSGeometryContainsLocation

这篇关于如何确定GMSMarker是否位于GMSPolygon(iOS Google Map SDK)内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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