如何在谷歌地图上计算距离原点lat长到目标lat长折线点数

时间:2016-09-15 10:27:31

标签: ios objective-c google-maps google-polyline

我想找到我使用google api绘制的Polyline的原点纬度长和目标纬度之间的距离。

1 个答案:

答案 0 :(得分:0)

表格CLLocation对象,如

 CLLocation *sourceLocation = [[CLLocation alloc]initWithLatitude:sourceCoordinate.latitude longitude:sourceCoordinate.longitude];

CLLocation *destinationLocation = [[CLLocation alloc]initWithLatitude:destinationCoordinate.latitude longitude:destinationCoordinate.longitude];

并将它们传递给此方法。

-(CLLocationDistance)getDistanceFromSource:(CLLocation*)source andDestination:(CLLocation*)destination {
    CLLocationDistance distance = [source distanceFromLocation:destination];
    return  distance;
}