【问题标题】:according to what google maps driving directions根据谷歌地图的行车路线
【发布时间】:2014-04-16 13:03:50
【问题描述】:

有人知道根据什么谷歌地图选择行车路线吗?

快速道路之类的......

我在我的应用程序中使用谷歌地图 v2 方向,我想知道它根据什么来确定方向。

【问题讨论】:

    标签: android google-maps driving-directions


    【解决方案1】:

    根据Google,您可以避开高速公路、渡轮和收费站。您也可以选择模式,但不能选择“快速道路”。
    例如:

    http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false&key=API_KEY&avoid=highways&mode=driving
    

    对于您的应用程序,您可以这样做:

    String url = "http://maps.googleapis.com/maps/api/directions/xml?origin=Toronto&destination=Montreal&sensor=false&key=API_KEY&avoid=highways&mode=driving";
    HttpGet httpGet = new HttpGet(url);
    HttpClient httpClient = new DefaultHttpClient();
    HttpResponse httpResponse;
    try {
        httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        InputStream inputStream = httpEntity.getContent();
    
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(inputStream);
        //In doc is your response
    } catch (Exception e) {
        e.printStackTrace();
    }
    

    【讨论】:

    • 谷歌地图应用程序根据什么选择路线?
    • 你不能。我刚刚检查过了。可以选择模式,避开收费站、高速公路和轮渡。
    猜你喜欢
    • 2012-05-17
    • 1970-01-01
    • 2015-04-18
    • 2015-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多