0

私のアプリでは、出発地から目的地までのルートを作成し、Google Directions APIを使用して、テキストボックスにも運転ルートを表示しています。方向応答をjson形式で解析し、html命令を表示しています。問題は、私がAの場所にいて、ターンがBの場所にあると仮定します。その後、Bに到達したときに、その前ではなく、Bの場所に関連するhtml命令を取得しています。

方向を表示するために使用しているロジックは次のとおりです。

1. Parse the json response and store the html instructions and their relevant coordinates   in a array
2. Checking the current updated location
3. Checking whether the current updated location value is present in the array, if present then displaying the html instruction corresponding to the coordinate
4

1 に答える 1

0

現在更新されている場所と終了場所の間の距離を計算することで問題を解決しました。これら2つの座標間の距離が100メートル未満の場合、その座標のhtml命令を表示しています。

次のコードを使用して、2つの座標間の距離を計算できます。

CLLocation *currentLoc = [[CLLocation alloc] initWithLatitude:startLat longitude:startLong]
CLLocation *endLoc = [[CLLocation alloc] initWithLatitude:endLat longitude:endLong];
CLLocationDistance meters = [endLoc distanceFromLocation:currentLoc];
于 2012-08-14T04:41:34.523 に答える