-
Notifications
You must be signed in to change notification settings - Fork 0
/
MKPolyline+Extensions.swift
33 lines (29 loc) · 1.04 KB
/
MKPolyline+Extensions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// MKPolyline+Extensions.swift
// OYExtensions
//
// Created by osmanyildirim
//
#if canImport(MapKit)
import MapKit
#endif
extension MKPolyline {
/// Initializer method of MKPolyline
/// - Parameter coordinates: polyline coordinates array
/// - Returns: MKPolyline with coordinates
public static func oy_init(coordinates: [CLLocationCoordinate2D]) -> MKPolyline {
.init(coordinates: coordinates, count: coordinates.count)
}
/// Initializer method of MKPolyline
/// - Parameter points: polyline points array
/// - Returns: MKPolyline with points
public static func oy_init(points: [MKMapPoint]) -> MKPolyline {
.init(points: points, count: points.count)
}
/// Coordinates array of MKPolyline
public var oy_coordinates: [CLLocationCoordinate2D] {
var coordinates = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid, count: pointCount)
getCoordinates(&coordinates, range: NSRange(location: 0, length: pointCount))
return coordinates
}
}