首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在我的google上嵌入Turn by turn导航

如何在我的google上嵌入Turn by turn导航
EN

Stack Overflow用户
提问于 2012-12-13 20:08:58
回答 3查看 6K关注 0票数 0

我想在我的安卓application.please中依次嵌入导航,给我一个教程或者提前告诉我如何做this.thanks。

EN

回答 3

Stack Overflow用户

发布于 2014-02-25 15:59:44

如果你不习惯使用谷歌地图,你可以使用基于OpenStreetMap (地图的维基百科版本)的软件开发工具包。

有几个很好的SDK提供商:

  • skobbler (现在的Telenav)有一个软件开发工具包,它能够在你的安卓手机上渲染地图和显示轮流导航。它还支持离线模式。查看更多here
  • OsmSharp还可以进行地图渲染和逐个转弯导航。你可以从github
  • MapQuest下载他们的代码,它有一个很好的安卓map & routing engine。我认为你也可以通过Mapbox地图使用他们的路由服务(请看this作为一个起点)。我不认为他们可以做离线模式,
  • Cloudmade有一个适用于安卓的navigation SDK。他们的文档说明了如何实现这一点,但我找不到一种快速下载SDK & sample projects

的方法

作为参考,您可以查看OSM list of frameworks

票数 3
EN

Stack Overflow用户

发布于 2014-07-17 00:34:28

我认为没有办法将逐个转弯的指令嵌入到我的应用程序中,但我完全错了。Google Maps API V2实际上提供了逐个转弯的说明。看看谷歌的documentation吧。

我使用了this library中给出的代码来获取基本的路由信息。然后,我将以下方法添加到GoogleDirection.java中,以返回逐个转弯指令的列表:

代码语言:javascript
复制
// getInstructions returns a list of step-by-step instruction Strings with HTML formatting
public ArrayList<String> getInstructions(Document doc) {
    ArrayList<String > instructions = new ArrayList<String>();
    NodeList stepNodes = doc.getElementsByTagName("step");
    if (stepNodes.getLength() > 0) {
        for (int i = 0; i < stepNodes.getLength(); i++) {
            Node currentStepNode = stepNodes.item(i);
            NodeList currentStepNodeChildren = currentStepNode.getChildNodes();
            Node currentStepInstruction = currentStepNodeChildren.item(getNodeIndex(currentStepNodeChildren, "html_instructions"));
            instructions.add(currentStepInstruction.getTextContent());
        }
    }
    return instructions;
}

这种方法不会提供实时更新,告诉你什么时候你已经到达了一个新的转折点,但它工作得很好,满足了我的需求。我将getInstructions方法与instructionsToString帮助器方法一起使用,该方法将指令与HTML换行符连接在一起。如果你感兴趣的话,这段代码就是here

票数 3
EN

Stack Overflow用户

发布于 2012-12-13 20:23:21

您可以在您的活动中使用以下代码:

代码语言:javascript
复制
double latitudeDestination = 52.377028; // or some other location
double longitudeDestination = 4.892421; // or some other location
String requestedMode = "walking" // or bike or car
String mode = "";
if(requestedMode.equals("walking")) {
  mode = "&mode=w";
} else if(requestedMode.equals("bike")) {
  mode = "&mode=b";
} else if(requestedMode.equals("car")) {
  mode = "&mode=c";
}

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(String.format("google.navigation:ll=%s,%s%s", latitudeDestination, longitudeDestination, mode)));
startActivity(intent);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13859568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档