Last active
September 5, 2024 06:36
-
-
Save freak4pc/98c813d8adb8feb8aee3a11d2da1373f to your computer and use it in GitHub Desktop.
Get a list of coordinates from a MKPolyline / MKRoute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Thanks for this code, It's just for me. Great
Lifesaver, thanks mate!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also wanted to add a thanks, still needed in April of 2022. Maybe WWDC22 we'll get some swiftui and mapkit improvements!