如何在Android应用程序中添加谷歌地图路径?

时间:2011-06-27 10:29:14

标签: android google-maps google-maps-api-3

我有开始和结束经纬度和经度。

除此之外,我还有其他一些点在起点和终点之间。所以我想创建一个路径/路径/路径,显示从头到尾的所有点。

我试过谷歌但没有收到任何可能有帮助的结果。

喜欢两点,代码是这样的,

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345");
startActivity(intent);

但是我想要一个覆盖多个点的完整路线。像这样

enter image description here

1 个答案:

答案 0 :(得分:2)

你应该使用MapView。

为了检索两点之间的路径,只需获取http://maps.google.com/maps?saddr=47.295601,0.010586&daddr=47.295601,1.010586&output=kml的内容(注意“& output = kml”)并解析它。在此文件中,您可以在“GeometryCollection”元素中获取完整路径。

如果文件为空,则找不到路线。