如何确定GMSMarker是否在GMSPolygon内(iOS Google Map SDK)

Nit*_*rad 4 google-maps objective-c ios ios7

我从这个链接得到了苹果地图套件的相同问题的答案,但是不知道如何检查某些位置或注释(GMSMarker)是否在Google Map SDK中的GMSPolygon内.所以,如果有人有任何想法,请帮助我.

Nit*_*rad 14

我自己得到了答案.

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

//Returns whether |point|,CLLocationCoordinate2D lies inside of path, GMSPath
    BOOL GMSGeometryContainsLocation(CLLocationCoordinate2D point, GMSPath *path,
                                 BOOL geodesic);
Run Code Online (Sandbox Code Playgroud)

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

if (GMSGeometryContainsLocation(locationPoint, polygonPath, YES)) {
    NSLog(@"locationPoint is in polygonPath.");
} else {
    NSLog(@"locationPoint is NOT in polygonPath.");
}
Run Code Online (Sandbox Code Playgroud)

来源:GMSGeometryContainsLocation