谷歌驾驶方向在地图上的方式点

时间:2015-02-25 06:48:56

标签: android google-maps google-maps-android-api-2 google-direction

我想使用api v2在谷歌地图上显示行车路径。我有一个来源,目的地和这两点之间的某种方式。  为此我使用下面的代码,它工作正常,但问题是当我有少于10分然后它的工作找到但当我添加超过10分然后api返回错误。

下面是我生成网址的代码 -

api -
https://maps.googleapis.com/maps/api/directions/json?

代码 -

public static String getDirectionsUrl(LatLng origin,LatLng dest,ArrayList<LatLng> mLatLongAL,String url){
    try{
        String str_origin = "origin="+origin.latitude+","+origin.longitude;
        String str_dest = "destination="+dest.latitude+","+dest.longitude;
        String sensor = "sensor=false";
        String waypoints = "";
        for(int i=0;i<mLatLongAL.size();i++){
            LatLng point  = (LatLng) mLatLongAL.get(i);
            if(i==0)
                waypoints = "waypoints=";
            waypoints += point.latitude + "," + point.longitude + "|";
        }
        String parameters = str_origin+"&"+str_dest+"&"+sensor+"&"+waypoints;
        String mUrl = url+parameters;
        return mUrl;
    }
    catch(Exception e){
        e.printStackTrace();
    }
    return null;
}

如何获得超过10个航点的路径。

先谢谢。

1 个答案:

答案 0 :(得分:0)

使用Google的Direction API,您最多只能使用免费版本的8个航路点。如果您使用的是免费版本,请不要确定如何获得10分。要获得更多请求的航点,您需要获得Google Maps API for Work,这将允许您最多23个航点。您可以参考文档here