私は2つのMKCoordinateRegion
オブジェクトを持っています。それらのオブジェクトからの値に基づいて、マップ上に2つのannotations
を作成します。 はその後、私はそれらの2つの位置の間の距離を計算します。道路に基づく2つの場所間の距離を計算する
CLLocationCoordinate2D pointACoordinate = [ann coordinate];
CLLocation *pointALocation = [[CLLocation alloc] initWithLatitude:pointACoordinate.latitude longitude:pointACoordinate.longitude];
CLLocationCoordinate2D pointBCoordinate = [ann2 coordinate];
CLLocation *pointBLocation = [[CLLocation alloc] initWithLatitude:pointBCoordinate.latitude longitude:pointBCoordinate.longitude];
float distanceMeters = [pointBLocation distanceFromLocation:pointALocation];
distanceMeters = distanceMeters/1000;
をしかし、私は私が得る値が正しいことを確認していないミリアンペア。
これらの値は空気ですか?距離?
距離を取得することは可能です道路に基づいて?
私は車で渡す必要がある距離が必要です。
しかし、私はすでにCLLocationとdistanceFromLocationをコード内で使っています。( – 1110
yup、道路から正確な距離を得ることはできません。このメソッドは、曲率に従う線の間を線でトレースすることによって2つの場所の距離を測定しますあなたはそれのためにgoogle maps direction apiを使う必要があります。 –