Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@BhamJack

This comment has been minimized.

Copy link

BhamJack commented May 4, 2017

Thanks, good reminder of being swifty and having bester code.

@KennethFra

This comment has been minimized.

Copy link

KennethFra commented Jun 12, 2018

Suggestion: Making the extension off of MKMultiPoint as both MKPolyline and MKPolygon are subclasses of MKMultipoint and can benefit from this extension.

@freak4pc

This comment has been minimized.

Copy link
Owner Author

freak4pc commented Jul 8, 2018

@KennethFra - fair point! Thanks for that note.

@OhadMaor-VIA

This comment has been minimized.

Copy link

OhadMaor-VIA commented Aug 20, 2018

Awesome job! Thanks! :)

@StevenKowalzik

This comment has been minimized.

Copy link

StevenKowalzik commented Sep 21, 2018

This helped me a lot, thank you!

@rhunt222

This comment has been minimized.

Copy link

rhunt222 commented Oct 10, 2018

This is great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.