-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMapKitPathRenderer.swift
43 lines (37 loc) · 1.49 KB
/
MapKitPathRenderer.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
34
35
36
37
38
39
40
41
42
43
//
// MapKitPathRenderer.swift
// MapKitPathRenderer
//
// Created by Hem Dutt on 27/04/18.
//
import UIKit
import MapKit
struct MapSourceDestinationStruct
{
var sourceCoordinate : CLLocationCoordinate2D? = nil
var destinationCoordinate : CLLocationCoordinate2D? = nil
}
//defaultStepCount is the count of points needed between source and destiation coordinates
//let defaultStepCount = 20
public class MapKitPathRenderer: NSObject
{
public func getRoutePathBetween(source : CLLocationCoordinate2D , destination : CLLocationCoordinate2D , straightLinePath : Bool = true ,steps : Int = 20) -> (MKPolyline?, [CLLocationCoordinate2D]?)
{
if straightLinePath == true
{
//Return straight line route between source, destination points
return MKPRStraightLineRoute.init().getRoutePathBetween(source: source, destination: destination, steps: steps)
}
return (nil , nil)
}
func getRoutesForSourceDestinatonStructArray(_ sdArray : [MapSourceDestinationStruct] ,straightLinePath : Bool = true, steps : Int = 20) -> [(MKPolyline?, [CLLocationCoordinate2D]?)]
{
var routes : [(MKPolyline?, [CLLocationCoordinate2D]?)] = []
if straightLinePath == true
{
//Return multiple straight line routes for multiple source, destination points in sdArray
routes = MKPRStraightLineRoute.init().getRoutesForSourceDestinatonStructArray(sdArray, steps: steps)
}
return routes
}
}