質問

2つの場所間の走行距離を見つける必要があります。マップに指示を表示する必要はありません。距離を計算するだけで、アプリケーションで使用する必要があります。

MapKitはこれを許可しますか?使用できる代替手段はありますか?

CloudMadeを使用してジオコーディングを進めることができますが、運転距離を取得するオプションはないようです。

どんな助けにも感謝します。

役に立ちましたか?

解決

CloudMadeは、運転指示も提供しています。遠くに興味がある場合は、指示を無視するだけです。

API-Callは次のようになります:

http://navigation.cloudmade.com/your-api-key-goes-here/api/0.3/47.25976,9.58423,47.26117,9.59882/car/shortest.js

JSONには含まれています

....
route_summary: {
total_distance: Distance in meters,...

ソース

他のヒント

これをGoogleグループで見つけましたが、それは役に立ちますか?

http://groups.google.com/group/google-maps-api/msg/4dc2fad4f74e3314?pli=1

私のアプリケーションでは、MKDirectionsを使用して、2つの場所間の運転(歩行)距離を取得しました。

CLLocationCoordinate2D startCoordinates = YOUR_START_COORDINATES;
CLLocationCoordinate2D endCoordinates = YOUR_END_COORDINATES;

MKPlacemark *startPoint = [[MKPlacemark alloc] initWithCoordinate:startCoordinates];
MKPlacemark *endPoint = [[MKPlacemark alloc] initWithCoordinate:endCoordinates];

MKMapItem *startItem = [[MKMapItem alloc] initWithPlacemark:startPoint];
MKMapItem *endItem = [[MKMapItem alloc] initWithPlacemark:endPoint];

MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];

request.source = startItem;
request.destination = endItem;
request.transportType = MKDirectionsTransportTypeAutomobile; //here you can choose a transport type you need

MKDirections *direction = [[MKDirections alloc] initWithRequest:request];

[direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse * _Nullable response, NSError * _Nullable error) {

          if (response) {
              for (MKRoute *route in response.routes) {
                  NSLog(@"Distance : %f", route.distance);
              }
          }

 }];

あなたが住所として場所を持っている場合、あなたはあなたの住所の緯度と経度を与えるClgeocoderの方法を使用することができます

- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;

MKDirectionを使用してGoogleマップを使用している距離を使用して走行距離の結果を比較すると、それらが異なることがわかります。私はこの問題について検索していました、そして、次のリンクに出会いました http://www.macworld.co.uk/review/reference-education/apple-maps-vs-google-maps-3464377/

Appleはマップサービスを改善していますが、少なくとも運転距離に関する質問で、Google(IMO)に対する正確性を依然として認めています。したがって、あなたの場合に精度があまり重要でない場合は、Appleに従うことができます。それ以外の場合は、Google APIをチェックすることをお勧めします。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top