Skip to content

Instantly share code, notes, and snippets.

@freak4pc
Last active April 25, 2024 04:38
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save freak4pc/98c813d8adb8feb8aee3a11d2da1373f to your computer and use it in GitHub Desktop.
Save freak4pc/98c813d8adb8feb8aee3a11d2da1373f to your computer and use it in GitHub Desktop.
Get a list of coordinates from a MKPolyline / MKRoute
public extension MKMultiPoint {
var coordinates: [CLLocationCoordinate2D] {
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,
count: pointCount)
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount))
return coords
}
}
// Given a MKRoute, you can just do:
// route.polyline.coordinates
@qianzhonglue
Copy link

Thanks for this code, It's just for me. Great

@TheBigSasha
Copy link

Lifesaver, thanks mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment