-3

I am creating an application where I have to post to this url: Url to get KML

The url is supposed to return a KML file, according to this tutorial:

Tutorial link

But when I am hitting the url, I am getting a HTML file as a response which is very difficult to parse and is useless.

My source code is:

//Calling function to get the response KML
  getKmlFromUrl("https://maps.google.com/maps?saddr=22.583375060000,88.434077990000&daddr=22.491368100000,88.348189300000&ie=UTF8&0&om=0&output=kml");

//This is the function to get the KML file and show it in logcat void getKmlFromUrl(String urlString) { String kml = null;

            try {
                // defaultHttpClient
                DefaultHttpClient httpClient = new DefaultHttpClient();
                makeAToast("URL:"+urlString);
                HttpPost httpPost = new HttpPost(urlString);

                HttpResponse httpResponse = httpClient.execute(httpPost);
                HttpEntity httpEntity = httpResponse.getEntity();
                kml = EntityUtils.toString(httpEntity);

               System.out.println("KML: "+kml);

            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
//          // return XML
//         // return xml;


        }

After doing all these, I am not getting a KML response, instead I am getting an HTML response. The response (in logcat) is over here:

logcat output

Where am I going wrong?

kittu88
  • 2,451
  • 5
  • 40
  • 80

1 Answers1

2

KML response is not used anymore, google returns either JSON or XML, check below link : https://developers.google.com/places/documentation/

Moh Sakkijha
  • 2,705
  • 1
  • 14
  • 19
  • Can you give me the link of a tutorial or at least an example of how the url should be formed? – kittu88 Nov 10 '12 at 12:58
  • sure check this post : http://stackoverflow.com/questions/11745314/why-retrieving-google-directions-for-android-using-kml-data-is-not-working-anymo/11745316 – Moh Sakkijha Nov 10 '12 at 13:03