bruchowski
bruchowski

Reputation: 5351

Manually drawing a circle with a radial distance from center lat/lng using google maps ios sdk

I need to send lat/lng coordinates to a 3rd party API and it doesn't look like it's possible to extract lat/lng coordinates from a GMSCircle, so I was thinking about generating an array of CGPoints and using GMSProjection to extract the location coordinates, however the radius needs to be exactly 1.5 miles; so with regard to the zoom level would I need to resort to something like this: https://gis.stackexchange.com/questions/7430/what-ratio-scales-do-google-maps-zoom-levels-correspond-to to calculate it?

Is there a better way to go about this? I feel like this would be a pretty common use case

Upvotes: 0

Views: 273

Answers (1)

bruchowski
bruchowski

Reputation: 5351

Figured it out, I ended up using the GMSGeometryUtils GMSGeometryOffset function to get the offset from my origin and make a circle.

NSMutableArray *path = [NSMutableArray array];
for (int i = 0; i < 60; i++) {
    CLLocationCoordinate2D locationCoordinate = GMSGeometryOffset(location.coordinate, 2414.02, i*6);
    [path addObject:[[CLLocation alloc] initWithLatitude:locationCoordinate.latitude longitude:locationCoordinate.longitude]];
}

Upvotes: 2

Related Questions