【问题标题】:android google.navigation intent return travel timeandroid google.navigation 意图返回旅行时间
【发布时间】:2014-02-02 10:32:50
【问题描述】:

导航我使用:

            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q="+url));
        mContext.startActivity(i);  

是否有可能谷歌导航返回旅行时间?

【问题讨论】:

    标签: android android-intent navigation


    【解决方案1】:

    您可以使用Google Directions API 并获得包含持续时间、距离等信息的 JSON。

    duration: {
    text: "5 hours 22 mins",
    value: 19325
    },
    

    请求(从多伦多到蒙特利尔的示例路线)

    http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false

    完整输出:

    {
        routes: [
            {
                bounds: {
                    northeast: {
                        lat: 45.5110114,
                        lng: -73.5535278
                    },
                    southwest: {
                        lat: 43.6533103,
                        lng: -79.3837332
                    }
                },
                copyrights: "Map data ©2014 Google",
                legs: [
                    {
                        distance: {
                            text: "542 km",
                            value: 542389
                        },
                        duration: {
                            text: "5 hours 22 mins",
                            value: 19325
                        },
                        end_address: "Montreal, QC, Canada",
                        end_location: {
                            lat: 45.5085712,
                            lng: -73.5537674
                        },
                        start_address: "Toronto, ON, Canada",
                        start_location: {
                            lat: 43.6533103,
                            lng: -79.3827675
                        },
                        steps: [
    
                        ],
                        via_waypoint: [
    
                        ]
                    }
                ],
                overview_polyline: {
                    points: ""
                },
                summary: "ON-401 E",
                warnings: [
    
                ],
                waypoint_order: [
    
                ]
            }
        ],
        status: "OK"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-14
      • 2021-09-01
      • 2023-02-20
      • 2010-10-28
      • 2020-11-26
      • 1970-01-01
      相关资源
      最近更新 更多