//
|
// 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
|
}
|
}
|