我正在创建一个应用程序,我必须在其中发布到此 url:Url to get KML
根据本教程,该 url 应该返回一个 KML 文件:
但是当我点击 url 时,我会得到一个HTML文件作为响应,这很难解析并且没用。
我的源代码是:
//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");
//这是获取KML文件并显示在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;
}
完成所有这些操作后,我没有收到KML响应,而是收到了HTML响应。响应(在 logcat 中)在这里:
我哪里错了?