宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
//  AMapPathExtension.swift
//  YYBase
//
//  Created by alvin_y on 2020/3/13.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
import AMapSearchKit
extension AMapPath {
 
    func coverToPilyline() -> MAPolyline? {
        let coordinateStrings = steps.map { $0.polyline.components(separatedBy: ";") }.reduce([String](), +)
        var coordinates = coordinateStrings.map { (cs) -> CLLocationCoordinate2D in
            let temp = cs.components(separatedBy: ",")
            let coordinate = CLLocationCoordinate2D(latitude: CLLocationDegrees(temp[1]) ?? 0.0, longitude: CLLocationDegrees(temp[0]) ?? 0.0)
            return coordinate
        }
        let polyLine = MAPolyline(coordinates: &coordinates, count: UInt(coordinates.count))
        return polyLine
    }
}