0

I'm trying to draw a route on my fragmentMap; when i "give" to google only origin and destination points averythings goes fine; but when I try to add few waypoints, it fails!

This is the code, I hope you'll give me a solution, i'm going crazy!Thanks very much

    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();
    }

Always in catch!

gauss
  • 63
  • 1
  • 11

0 Answers0