我正在创建一个应用程序,我正在使用谷歌地图用户可以绘制路线并获取方向一切进展顺利,但问题是我如何从 html_instruction 逐步获得方向,如下所示:
"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"
},
我在做这个
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);
但它的抛出异常
org.xml.sax.SAXParseException: Unexpected token (position:TEXT {
我如何解决它或以任何其他方式使用 google mapsv2 获取逐步指示
提前致谢