在我的应用程序中,我正在创建从源到目的地的路线,并使用谷歌方向 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