Nitesh Borad Nitesh Borad - 1 year ago 132
Objective-C Question

How to determine if an GMSMarker is inside of GMSPolygon (iOS Google Map SDK)

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.

Answer Source

Now, I've got an 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