我正在尝试在我的fragmentMap上绘制一条路线;当我“给”谷歌时,只有原点和目的地点才能正常运行;但是当我尝试添加几个航点时,它失败了!
这是代码,我希望你能给我一个解决方案,我会发疯的!非常感谢
String waypoints = "";
String wayp= "&waypoints=";
if(lp.size()>2){
for(int i=1;i<lp.size()-1;i++){
LatLng point = lp.get(i).getLoc();
waypoints += point.latitude + "," + point.longitude+ "|";
}
}else{
waypoints = "";
}
wayp +=waypoints;
Log.v("MAPPA", wayp);
String url = "http://maps.googleapis.com/maps/api/directions/xml?"
+ "origin=" + start.latitude + "," + start.longitude
+wayp+ "&destination=" + end.latitude + "," + end.longitude
+ "&sensor=false&units=metric&mode=driving";
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(url);
HttpResponse response = httpClient.execute(httpPost, localContext);
InputStream in = response.getEntity().getContent();
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(in);
return doc;
} catch (Exception e) {
Log.v("MAPPA", "CATCH");
e.printStackTrace();
}
总是抓住!