问题描述
我写一个应用程序,帮助人们找到合适的位置,并显示方向与目标。之前,此功能工作做好,但现在平局路由功能不起作用。我得到的例外是,应用程序无法下载,然后分析相应的路由KML(的code:xmlreader.parse(是); ),尽管产生的URL,以获取KML是正确的(我测试它在浏览器中) - 例如:<一href=\"https://maps.google.com/maps?f=d&hl=en&saddr=21.04664,105.852203&daddr=21.040527,105.849783&ie=UTF8&om=0&output=kml\" rel=\"nofollow\">https://maps.google.com/maps?f=d&hl=en&saddr=21.04664,105.852203&daddr=21.040527,105.849783&ie=UTF8&om=0&output=kml
我问我自己是否谷歌为MapView的方向API不能正常工作或我错过了一些东西。
下面是我的code得到的路线,然后生成URL - 获得KML然后绘制路线。
公共无效drawPath(从GeoPoint的,要的GeoPoint,诠释色彩,图形页面mMapView01){ NavigationDataSet navSet =新NavigationDataSet();
StringBuilder的urlString =新的StringBuilder();
urlString.append(http://maps.google.com/maps?f=d&hl=en);
urlString.append(放&; SADDR =); //从
urlString.append(Double.toString((双)from.getLatitudeE6()/ 1.0E6));
urlString.append(,);
urlString.append(Double.toString((双)from.getLongitudeE6()/ 1.0E6));
urlString.append(与&amp; DADDR =); //以
urlString.append(Double.toString((双)to.getLatitudeE6()/ 1.0E6));
urlString.append(,);
urlString.append(Double.toString((双)to.getLongitudeE6()/ 1.0E6));
urlString.append(与&amp; IE = UTF8&放大器; 0安培; OM = 0&放大器;输出= KML);
Log.v(TEST,urlString.toString());
尝试{
//设置的网址
网址URL =新的URL(urlString.toString());
//通过URL类让我们的数据
InputSource的是=新的InputSource(url.openConnection()的getInputStream());
//的DocumentBuilderFactory dbfAdd = DocumentBuilderFactory.newInstance();
//的DocumentBuilder dbAdd = dbfAdd.newDocumentBuilder();
// dbAdd.parse(url.toString());
//创建工厂
工厂SAXParserFactory的= SAXParserFactory.newInstance();
//创建一个解析器
的SAXParser解析器= factory.newSAXParser();
//创建读取器(扫描仪)
的XMLReader的XMLReader = parser.getXMLReader();
//实例我们的处理
NavigationSaxHandler navSaxHandler =新NavigationSaxHandler();
//指定我们的处理
xmlreader.setContentHandler(navSaxHandler);
//执行同步解析
xmlreader.parse(是);
//得到的结果 - 应该是一个完全填充的RSSFeed实例,或null上的错误
navSet = navSaxHandler.getParsedData();
Log.v(图,输入源:+(是== NULL));
}赶上(例外五){
// Log.d(DirectionMap,异常解析KML。);
Log.v(画,死在这里);
e.printStackTrace();
}
尝试{
字符串的距离= navSet.getRoutePlacemark()getDistance的()。
placeLabelTextView.setText(placeLabel +距离);
}赶上(例外五){
// TODO:处理异常
}
// HIEN THI平阳迪 Log.v(地图,(navSet.getCurrentPlacemark()= NULL)+ - 脱!);
字符串路径= navSet.getRoutePlacemark()getCoordinates()。
。的String [] =对path.trim()分裂();
串[] lngLat =成对[0] .split(,); // lngLat [0] =经度lngLat [1] =纬度lngLat [2] =高度
尝试{
的GeoPoint startGP =新的GeoPoint((int)的(Double.parseDouble(lngLat [1])* 1E6),(INT)(Double.parseDouble(lngLat [0])* 1E6));
。mMapView01.getOverlays()增加(新MyOverLay(startGP,startGP,1));
GP1的GeoPoint;
GP2的GeoPoint = startGP;
INT W =(int)的(5 * ShowPlaceOnMapsActivity.this.getResources()getDisplayMetrics()密度。);
的for(int i = 1; I&LT; pairs.length;我++)//最后一个会崩溃
{
lngLat =对[I] .split(,);
GP1 = GP2;
GP2 =新的GeoPoint((int)的(Double.parseDouble(lngLat [1])* 1E6),(INT)(Double.parseDouble(lngLat [0])* 1E6));
。mMapView01.getOverlays()增加(新MyOverLay(GP1,GP2,2,颜色,W));
}
。mMapView01.getOverlays()增加(新MyOverLay(GP2,GP2,3)); // HIEN THI CAC绮丹
清单&LT;&叠加GT; mapOverlays;
mapOverlays = mMapView01.getOverlays();
字符串s =新的String();
字符串description =新的String();
字符串名称=新的String();
标P =新地标();
可绘制drawable1 = mMapView01.getResources()getDrawable(R.drawable.way_turn_mark)。
MyItemizedOverlay itemizedOverlay1 =新MyItemizedOverlay(drawable1,mMapView01); 为(迭代&所述;标点方式&gt; ITER = navSet.getPlacemarks()迭代(); iter.hasNext()){
P =(标)iter.next();
如果(!p.getTitle()。等于(路径)){
S = p.getCoordinates();
说明= p.getDescription();
// Log.v(TEST,URL:+以p.getAddress());
名称= p.getTitle();
lngLat = s.split(,);
GP2 =新的GeoPoint((int)的(Double.parseDouble(lngLat [1])* 1E6),(INT)(Double.parseDouble(lngLat [0])* 1E6));
如果(描述!= NULL)
itemizedOverlay1.addOverlay(新OverlayItem(GP2,名+\\ n+的描述,));
其他
itemizedOverlay1.addOverlay(新OverlayItem(GP2,名称,));
}
}
mapOverlays.add(itemizedOverlay1); mapController.animateTo(新的GeoPoint((startGP.getLatitudeE6()+ gp2.getLatitudeE6())/ 2,(startGP.getLongitudeE6()+ gp2.getLongitudeE6())/ 2));
}赶上(NumberFormatException的E){
} }
我得到了code中的例外是:
xmlreader.parse(是);
org.apache.harmony.xml.ExpatParser $ ParseException的:.......不是结构良好的
你有没有遇到这个问题?任何帮助和注释是高度AP preciated。
这里是异常堆栈跟踪
07-30 22:06:03.510:VERBOSE / TEST(234): http://maps.google.com/maps?f=d&hl=en&saddr=21.059457,105.843963&daddr=21.052597,105.840636&ie=UTF8&0&om=0&output=kml
07-30 22:06:04.190:VERBOSE / DRAW(234):死在这里
07-30 22:06:04.190:WARN / System.err的(234):$ org.apache.harmony.xml.ExpatParser ParseException的:第1行,列805:格式不正确(标记无效)
07-30 22:06:04.210:WARN / System.err的(234):在org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:508)
07-30 22:06:04.210:WARN / System.err的(234):在org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
07-30 22:06:04.210:WARN / System.err的(234):在org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
07-30 22:06:04.210:WARN / System.err的(234):在org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:302)
07-30 22:06:04.210:WARN / System.err的(234):在hust.se.vtio.icompanion.ShowPlaceOnMapsActivity.drawPath(ShowPlaceOnMapsActivity.java:301)
07-30 22:06:04.210:WARN / System.err的(234):在hust.se.vtio.icompanion.ShowPlaceOnMapsActivity.onOptionsItemSelected(ShowPlaceOnMapsActivity.java:245)
07-30 22:06:04.210:WARN / System.err的(234):在android.app.Activity.onMenuItemSelected(Activity.java:2170)
07-30 22:06:04.210:WARN / System.err的(234):在com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
07-30 22:06:04.210:WARN / System.err的(234):在com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
07-30 22:06:04.210:WARN / System.err的(234):在com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
07-30 22:06:04.210:WARN / System.err的(234):在com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)
07-30 22:06:04.220:WARN / System.err的(234):在com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
07-30 22:06:04.220:WARN / System.err的(234):在android.view.View.onTouchEvent(View.java:4179)
07-30 22:06:04.220:WARN / System.err的(234):在android.widget.TextView.onTouchEvent(TextView.java:6540)
07-30 22:06:04.220:WARN / System.err的(234):在android.view.View.dispatchTouchEvent(View.java:3709)
07-30 22:06:04.220:WARN / System.err的(234):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-30 22:06:04.220:WARN / System.err的(234):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-30 22:06:04.220:WARN / System.err的(234):在com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-30 22:06:04.220:WARN / System.err的(234):在android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-30 22:06:04.220:WARN / System.err的(234):在android.os.Handler.dispatchMessage(Handler.java:99)
07-30 22:06:04.220:WARN / System.err的(234):在android.os.Looper.loop(Looper.java:123)
07-30 22:06:04.220:WARN / System.err的(234):在android.app.ActivityThread.main(ActivityThread.java:4363)
07-30 22:06:04.220:WARN / System.err的(234):在java.lang.reflect.Method.invokeNative(本机方法)
07-30 22:06:04.220:WARN / System.err的(234):在java.lang.reflect.Method.invoke(Method.java:521)
07-30 22:06:04.220:WARN / System.err的(234):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860)
07-30 22:06:04.220:WARN / System.err的(234):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-30 22:06:04.220:WARN / System.err的(234):在dalvik.system.NativeStart.main(本机方法)
这里是KML的我得到了内容时打开URL在浏览器
下面是KML文件的内容,我从浏览器得到了:
&LT; KML的xmlns =http://earth.google.com/kml/2.2&GT;
&lt;文件&GT;
&LT;名称&gt;驾驶方向21.052597,105.840636&LT; /名称&gt;
&LT;描述&GT;&LT;![CDATA []]&GT;&LT; /描述&GT;
&LT;风格ID =节日礼物&GT;
&LT; IconStyle&GT;
&LT;图标和GT;
&LT; HREF&GT;&LT; / HREF&GT;
&LT; /图标&GT;
&LT; / IconStyle&GT;
&LT; /样式和GT;
&LT;风格ID =蓝紫魅力&GT;
&LT;&的LineStyle GT;
&LT;彩色&GT; 73FF0000&LT; /彩色&GT;
&所述;宽度大于5&下; /宽度GT;
&LT; /&的LineStyle GT;
&LT; /样式和GT;
&LT;风格ID =STYLE1&GT;
&LT; IconStyle&GT;
&LT;图标和GT;
&LT; HREF&GT;&LT; / HREF&GT;
&LT; /图标&GT;
&LT; / IconStyle&GT;
&LT; /样式和GT;
&LT;标&GT;
&LT;名称&gt;来源:21.059457,105.843963&LT; /名称&gt;
&LT; styleUrl&GT;#节日礼物&LT; / styleUrl&GT;
&LT;点和GT;
&LT;&坐标GT; 105.842567,21.058840,0.000000&LT; /坐标&GT;
&LT; /点和GT;
&LT; /标&GT;
&LT;标&GT;
&LT;名称&gt;驾驶方向21.052597,105.840636&LT; /名称&gt;
&LT; styleUrl&GT;#蓝紫魅力&LT; / styleUrl&GT;
&LT; ExtendedData&GT;
&lt;数据NAME =_ SnapToRoads&GT;
&LT; VALUE&GT;真&LT; /值&GT;
&LT; /数据&GT;
&LT; / ExtendedData&GT;
&LT;&LineString的GT;
&所述;细分→1&下; /细分&GT;
&LT;&坐标GT;
105.842567,21.058840,0.000000
105.842346,21.059200,0.000000
105.841080,21.060551,0.000000
105.840530,21.061300,0.000000
105.840393,21.061399,0.000000
105.839653,21.061701,0.000000
105.839653,21.061701,0.000000
105.838860,21.061159,0.000000
105.838860,21.061159,0.000000
105.838852,21.061050,0.000000
105.838409,21.060699,0.000000
105.838409,21.060699,0.000000
105.838692,21.059879,0.000000
105.840950,21.055691,0.000000
105.840950,21.055691,0.000000
105.840477,21.055571,0.000000
105.839493,21.054930,0.000000
105.839493,21.054930,0.000000
105.839981,21.054060,0.000000
105.840553,21.052561,0.000000
&LT; /坐标&GT;
&LT; / LineString的&GT;
&LT; /标&GT;
&LT;标&GT;
&LT;名称&gt;收件人:21.052597,105.840636&LT; /名称&gt;
&LT; styleUrl&GT;#STYLE1&LT; / styleUrl&GT;
&LT;点和GT;
&LT;&坐标GT; 105.840546,21.052563,0.000000&LT; /坐标&GT;
&LT; /点和GT;
&LT; /标&GT;
&LT; /文件&GT;
&LT; / KML&GT;
通过解析KML文件提取谷歌的谷歌地图的这种方法不再可用自2012年7月27日(因为谷歌已经改变检索谷歌地图的结构,现在你只能通过JSON或XML得到它),现在是时候你code迁移到JSON,而不是KML。
查看答案我自己的问题here.
I write an application that help people find appropriate places and show the direction to the target. Before, this functionality work well but now the draw route function does not work. The exception I got is that application can not download and then parse the kml corresponding to the route (the code: xmlreader.parse(is);), although the URL generated to get KML is correct (I test it in Browser) - for example: https://maps.google.com/maps?f=d&hl=en&saddr=21.04664,105.852203&daddr=21.040527,105.849783&ie=UTF8&om=0&output=kml
I ask my self whether the direction API of Google for MapView does not work properly or I missed some thing.
Here is my code to get the route and then generate URL - get KML and then draw the route.
public void drawPath(GeoPoint from,GeoPoint to, int color, MapView mMapView01) {
NavigationDataSet navSet= new NavigationDataSet();
StringBuilder urlString = new StringBuilder();
urlString.append("http://maps.google.com/maps?f=d&hl=en");
urlString.append("&saddr=");//from
urlString.append( Double.toString((double)from.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)from.getLongitudeE6()/1.0E6 ));
urlString.append("&daddr=");//to
urlString.append( Double.toString((double)to.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)to.getLongitudeE6()/1.0E6 ));
urlString.append("&ie=UTF8&0&om=0&output=kml");
Log.v("TEST", urlString.toString());
try{
// setup the url
URL url = new URL(urlString.toString());
// get our data via the url class
InputSource is = new InputSource(url.openConnection().getInputStream());
// DocumentBuilderFactory dbfAdd = DocumentBuilderFactory.newInstance();
// DocumentBuilder dbAdd = dbfAdd.newDocumentBuilder();
// dbAdd.parse(url.toString());
// create the factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// create a parser
SAXParser parser = factory.newSAXParser();
// create the reader (scanner)
XMLReader xmlreader = parser.getXMLReader();
// instantiate our handler
NavigationSaxHandler navSaxHandler = new NavigationSaxHandler();
// assign our handler
xmlreader.setContentHandler(navSaxHandler);
// perform the synchronous parse
xmlreader.parse(is);
// get the results - should be a fully populated RSSFeed instance, or null on error
navSet= navSaxHandler.getParsedData();
Log.v("MAP", "input source: " + (is == null));
} catch(Exception e) {
// Log.d("DirectionMap","Exception parsing kml.");
Log.v("DRAW", "Die here");
e.printStackTrace();
}
try {
String distance = navSet.getRoutePlacemark().getDistance();
placeLabelTextView.setText(placeLabel + distance);
} catch (Exception e) {
// TODO: handle exception
}
//hien thi duong di
Log.v("MAP",(navSet.getCurrentPlacemark() != null) + "-des: ");
String path = navSet.getRoutePlacemark().getCoordinates();
String[] pairs = path.trim().split(" ");
String[] lngLat = pairs[0].split(","); // lngLat[0]=longitude lngLat[1]=latitude lngLat[2]=height
try {
GeoPoint startGP = new GeoPoint((int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6));
mMapView01.getOverlays().add(new MyOverLay(startGP, startGP, 1));
GeoPoint gp1;
GeoPoint gp2 = startGP;
int w = (int) (5 * ShowPlaceOnMapsActivity.this.getResources().getDisplayMetrics().density);
for (int i = 1; i < pairs.length; i++) // the last one would be crash
{
lngLat = pairs[i].split(",");
gp1 = gp2;
gp2 = new GeoPoint((int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6));
mMapView01.getOverlays().add(new MyOverLay(gp1, gp2, 2, color,w));
}
mMapView01.getOverlays().add(new MyOverLay(gp2, gp2, 3));
//hien thi cac chi dan
List<Overlay> mapOverlays;
mapOverlays=mMapView01.getOverlays();
String s=new String();
String description=new String();
String name=new String();
Placemark p=new Placemark();
Drawable drawable1=mMapView01.getResources().getDrawable(R.drawable.way_turn_mark);
MyItemizedOverlay itemizedOverlay1 = new MyItemizedOverlay(drawable1, mMapView01);
for (Iterator<Placemark> iter=navSet.getPlacemarks().iterator();iter.hasNext();) {
p = (Placemark)iter.next();
if(!p.getTitle().equals("Route")){
s=p.getCoordinates();
description=p.getDescription();
// Log.v("TEST", "URL: " + p.getAddress());
name=p.getTitle();
lngLat =s.split(",");
gp2= new GeoPoint((int) (Double.parseDouble(lngLat[1])* 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6));
if(description != null)
itemizedOverlay1.addOverlay(new OverlayItem(gp2,name+"\n"+description,""));
else
itemizedOverlay1.addOverlay(new OverlayItem(gp2, name, ""));
}
}
mapOverlays.add(itemizedOverlay1);
mapController.animateTo(new GeoPoint( (startGP.getLatitudeE6() + gp2.getLatitudeE6())/2, (startGP.getLongitudeE6() + gp2.getLongitudeE6())/2 ));
} catch (NumberFormatException e) {
}
}
The exception I got for the code is at:
xmlreader.parse(is);
org.apache.harmony.xml.ExpatParser$ParseException:....... not well-formed
Have you met this problem? Any help and comment is highly appreciated.
Here is exception stack trace
07-30 22:06:03.510: VERBOSE/TEST(234): http://maps.google.com/maps?f=d&hl=en&saddr=21.059457,105.843963&daddr=21.052597,105.840636&ie=UTF8&0&om=0&output=kml
07-30 22:06:04.190: VERBOSE/DRAW(234): Die here
07-30 22:06:04.190: WARN/System.err(234): org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 805: not well-formed (invalid token)
07-30 22:06:04.210: WARN/System.err(234): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:508)
07-30 22:06:04.210: WARN/System.err(234): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
07-30 22:06:04.210: WARN/System.err(234): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
07-30 22:06:04.210: WARN/System.err(234): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:302)
07-30 22:06:04.210: WARN/System.err(234): at hust.se.vtio.icompanion.ShowPlaceOnMapsActivity.drawPath(ShowPlaceOnMapsActivity.java:301)
07-30 22:06:04.210: WARN/System.err(234): at hust.se.vtio.icompanion.ShowPlaceOnMapsActivity.onOptionsItemSelected(ShowPlaceOnMapsActivity.java:245)
07-30 22:06:04.210: WARN/System.err(234): at android.app.Activity.onMenuItemSelected(Activity.java:2170)
07-30 22:06:04.210: WARN/System.err(234): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
07-30 22:06:04.210: WARN/System.err(234): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
07-30 22:06:04.210: WARN/System.err(234): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
07-30 22:06:04.210: WARN/System.err(234): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)
07-30 22:06:04.220: WARN/System.err(234): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
07-30 22:06:04.220: WARN/System.err(234): at android.view.View.onTouchEvent(View.java:4179)
07-30 22:06:04.220: WARN/System.err(234): at android.widget.TextView.onTouchEvent(TextView.java:6540)
07-30 22:06:04.220: WARN/System.err(234): at android.view.View.dispatchTouchEvent(View.java:3709)
07-30 22:06:04.220: WARN/System.err(234): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-30 22:06:04.220: WARN/System.err(234): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-30 22:06:04.220: WARN/System.err(234): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-30 22:06:04.220: WARN/System.err(234): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-30 22:06:04.220: WARN/System.err(234): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 22:06:04.220: WARN/System.err(234): at android.os.Looper.loop(Looper.java:123)
07-30 22:06:04.220: WARN/System.err(234): at android.app.ActivityThread.main(ActivityThread.java:4363)
07-30 22:06:04.220: WARN/System.err(234): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 22:06:04.220: WARN/System.err(234): at java.lang.reflect.Method.invoke(Method.java:521)
07-30 22:06:04.220: WARN/System.err(234): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-30 22:06:04.220: WARN/System.err(234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-30 22:06:04.220: WARN/System.err(234): at dalvik.system.NativeStart.main(Native Method)
And here is the content of KML I got when open URL in Browser
Here is the content of KML file I got from Browser:
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Driving directions to 21.052597,105.840636</name>
<description><![CDATA[]]></description>
<Style id="style3">
<IconStyle>
<Icon>
<href></href>
</Icon>
</IconStyle>
</Style>
<Style id="style2">
<LineStyle>
<color>73FF0000</color>
<width>5</width>
</LineStyle>
</Style>
<Style id="style1">
<IconStyle>
<Icon>
<href></href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>From: 21.059457,105.843963</name>
<styleUrl>#style3</styleUrl>
<Point>
<coordinates>105.842567,21.058840,0.000000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Driving directions to 21.052597,105.840636</name>
<styleUrl>#style2</styleUrl>
<ExtendedData>
<Data name="_SnapToRoads">
<value>true</value>
</Data>
</ExtendedData>
<LineString>
<tessellate>1</tessellate>
<coordinates>
105.842567,21.058840,0.000000
105.842346,21.059200,0.000000
105.841080,21.060551,0.000000
105.840530,21.061300,0.000000
105.840393,21.061399,0.000000
105.839653,21.061701,0.000000
105.839653,21.061701,0.000000
105.838860,21.061159,0.000000
105.838860,21.061159,0.000000
105.838852,21.061050,0.000000
105.838409,21.060699,0.000000
105.838409,21.060699,0.000000
105.838692,21.059879,0.000000
105.840950,21.055691,0.000000
105.840950,21.055691,0.000000
105.840477,21.055571,0.000000
105.839493,21.054930,0.000000
105.839493,21.054930,0.000000
105.839981,21.054060,0.000000
105.840553,21.052561,0.000000
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>To: 21.052597,105.840636</name>
<styleUrl>#style1</styleUrl>
<Point>
<coordinates>105.840546,21.052563,0.000000</coordinates>
</Point>
</Placemark>
</Document>
</kml>
This way of extracting the Google Directions from Google by parsing the KML file is no longer available since 27 July 2012 (because Google has changed the structure of retrieving Google Directions, now you can only get it by JSON or XML), it is time to migrate your code to JSON instead of KML.
See the answer in my own question here.
这篇关于Android的:不能让KML文件来分析,然后绘制在地图上的路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!