-1

I am creating an app in which i am using google map user can draw route and get directions all is going well but problem is that how i can get step by step direction from html_instruction like below :

"legs" : [
        {
           "distance" : {
              "text" : "6.0 km",
              "value" : 6020
           },
           "duration" : {
              "text" : "1 hour 15 mins",
              "value" : 4514
           },
           "end_address" : "MH Road, Rawalpindi, Pakistan",
           "end_location" : {
              "lat" : 33.5955202,
              "lng" : 73.044865
           },
           "start_address" : "4th Road, Rawalpindi, Pakistan",
           "start_location" : {
              "lat" : 33.6377411,
              "lng" : 73.0647159
           },
           "steps" : [
              {
                 "distance" : {
                    "text" : "23 m",
                    "value" : 23
                 },
                 "duration" : {
                    "text" : "1 min",
                    "value" : 15
                 },
                 "end_location" : {
                    "lat" : 33.6375325,
                    "lng" : 73.06468649999999
                 },
                 "html_instructions" : "Head \u003cb\u003esouth\u003c/b\u003e toward \u003cb\u003e4th Rd\u003c/b\u003e",
                 "polyline" : {
                    "points" : "{zhlEom}|Lf@D@?"
                 },
                 "start_location" : {
                    "lat" : 33.6377411,
                    "lng" : 73.0647159
                 },
                 "travel_mode" : "WALKING"
              },

i am doing this

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

but its throwing exception of

org.xml.sax.SAXParseException: Unexpected token (position:TEXT {

how i can resolve it or any other way to get step by step directions using google mapsv2

Thanks in advance

hena12
  • 63
  • 3
  • 6

1 Answers1

0

If the JSON has the Unexpected token, it probably has a non printable character that is not showing up. Try copying and pasting your original text into hex dump website here, and compare to what you get.

bjiang
  • 6,068
  • 2
  • 22
  • 35