谷歌的方向和语音导航 [英] Google direction and voice navigation

查看:118
本文介绍了谷歌的方向和语音导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在一个Android项目。 然后,我想出了2提问。

I have been working on a android project. Then I came up with 2 question.

Q1。如何实现导航的驱动? 我的逻辑和一些工作 - 我能够利用2个地址之间的路径。而我的想法是,使用onLocationChanged(电流)方法,然后调用 https://开头maps.googleapis.com/maps/api/directions/output?parameters 的与所述当前位置和目的地其中通过一些方法来绘制地图上的路径。 当每一个onLocationChanged()方法调用,我又重新绘制地图上的路径。 它是我们如何做到这一点对导航?

Q1. how to implement navigation drive ? My logic and some work - I am be able to draw path between 2 address. And my thought is that, use the onLocationChanged(current) method then call https://maps.googleapis.com/maps/api/directions/output?parameters with the current location and destination which through some method to draw the path on the map. Upon every onLocationChanged() method call, I redraw the path on the map again. " Is it how we would do it for navigation ? "

Q2。如何实现语音导航Q1一起工作呢? - 做了一些研究,无法找到任何东西,这似乎明显有帮助的。所有我知道的是,在从/ API /方向返回的JSON,也有它的方向指示。 难道我用它的声音从返回JSON?或者有更好的办法吗?

Q2. how to implement voice navigation to work with Q1 ? - Did some research, can't find anything that seems clearly helpful. All I know its that, in the return JSON from the /api/directions, there are direction instruction in it. " Do I use it for voice from the return JSON ? Or there is a better way ? "

将在一些细节上的链接或例子非常有帮助。 谢谢adavnce

Would be very helpful with some link or example in details. Thanks in adavnce

推荐答案

在这里我所知道的,希望它可以帮助你。

here what I know, hope it helps you out.

关于第一个问题:

检索方向和必要的数据后,你要画的方向一次,只有一次!是的,你必须使用 onLocationChanged(),但不要再重绘整个事情..如果你在大多数导航应用的通知,他们仍然保留的主要途径,他们不要删除通过部分...但你必须使用 onLocationChanged()来检查用户是否超出绘制的路径(可能由100米),所以你有重新计算,并再次重绘......每次重绘路径的用户举动是一个代价高昂的操作,最好是避免...

After retrieving the directions and the necessary data, you have to draw the direction once and only once! yes, you have to use the onLocationChanged() but not to redraw the whole thing again.. if you notice in most of the navigation application they still keep the main route, they don't remove the passed parts... but you have to use onLocationChanged() to check if the user is out of the drawn path (by maybe 100m) so you have to re-calculate and redraw it again... redraw the path every time the user move is a costly operation it is better to be avoided...

第二个问题:

正如你所说的,已经获取的数据具有导航命令..所以你要做的就是创建一个类来映射指令的声音..如果你在腿通知 - >步骤标签,有一个开始和结束坐标为每个子路径,这样你就可以使用这些数据来计算每个200米它们之间的距离说,用户是多远,打开命令离开为例。

As you said, the data retrieved already has the navigation commands.. so what you have to do is create a class to map the command with the voice.. and if you notice within the legs -> steps tags, there is a start and ending coordinates for each sub-path, so you can use these data to calculate the distance between them on each 200m say the command that "how far the user is to turn left" for example.

希望这给你它是如何工作的总体思路。祝你好运,快乐的节目。

hope this gives you a general idea of how it works. Good luck and happy programming.

这篇关于谷歌的方向和语音导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆