我想使用 api v2 在谷歌地图上显示行车路线。我在这两点之间有一个源头、目的地和某个路径点。 为此,我使用下面的代码并且它工作正常,但问题是当我有少于 10 个点时它可以找到但是当我添加超过 10 个点时 api 返回错误。
下面是我生成 url 的代码 -
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 个路径点的路径。
提前致谢。
最佳答案
使用 Google 的 Direction API,您最多只能使用免费版本的 8 个航路点。如果您使用的是免费版本,则不确定如何获得 10。要获得请求的更多航路点,您需要获得 Google Maps API for Work ,这将允许您最多使用 23 个航路点。可以引用文档here .
关于android - 谷歌在 map 上的行车方向与航路点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28712886/