#swift #mapkit
#swift #mapkit
Вопрос:
Можно ли разделить MKGeodesicPolyline на заданное количество точек, а затем получить CLLocationCoordinate2D каждой точки? Что-то вроде этого:
let coordinate1=CLLocationCoordinate2D(latitude: abc, longitude: def)
let coordinate2=CLLocationCoordinate2D(latitude: ghi, longitude: jkl)
let points=[coordinate1, coordinate2]
let myRoute=MKGeodesicPolyline(coordinates: points, count: points.count)
let pointsEnroute=myRoute.getEquallyDisplacedPoints(numOfPoints: 10)
Платформа — iOS, язык должен быть быстрым.
чтобы я получил 10 pointsEnroute в виде массива координат, которые все были бы расположены на «MyRoute»?
Спасибо за предложения.
Ответ №1:
Я нашел это решение на: https://gist.github.com/freak4pc/98c813d8adb8feb8aee3a11d2da1373f
let route=MKGeodesicPolyline(points: [point1,point2], count: 2)
var coordinates=[CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,count: route.pointCount)
route.getCoordinates(amp;coordinates, range: NSRange(location: 0, length: route.pointCount))