Objective c 使用谷歌方向API显示驾驶方向

Objective c 使用谷歌方向API显示驾驶方向,objective-c,mapkit,google-directions-api,Objective C,Mapkit,Google Directions Api,在我的应用程序中,我正在创建一条从源到目的地的路线,并使用谷歌方向api,在文本框中显示驾驶方向。我正在解析json格式的方向响应,并显示html指令。 问题是假设我在一个位置,在B位置有一个转弯,然后当我到达B位置时,我在B位置得到了相关的html指令,而不是在此之前 我用来显示方向的逻辑是: 1. Parse the json response and store the html instructions and their relevant coordinates in a arra

在我的应用程序中,我正在创建一条从源到目的地的路线,并使用谷歌方向api,在文本框中显示驾驶方向。我正在解析json格式的方向响应,并显示html指令。 问题是假设我在一个位置,在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

我已经解决了这个问题,通过计算当前更新位置和结束位置之间的距离,如果这两个坐标之间的距离小于100米,那么我将显示该坐标的html指令

可以使用以下代码计算两个坐标之间的距离:

CLLocation *currentLoc = [[CLLocation alloc] initWithLatitude:startLat longitude:startLong]
CLLocation *endLoc = [[CLLocation alloc] initWithLatitude:endLat longitude:endLong];
CLLocationDistance meters = [endLoc distanceFromLocation:currentLoc];