简体   繁体   English

获取两个地理位置之间的路线

[英]Get directions between two geopoints

I have seen numerous answers on this subject but none of them have given me a correct solution. 我在这个问题上看到了许多答案,但是没有一个给我正确的解决方案。 I must make it clear that I don't want a polyline drew between the two geopoints. 我必须明确指出,我不想在两个地理位置之间画一条折线。 I want the directions to appear in a textview eg: 我希望这些指示出现在textview中,例如:

1: In 100 yards turn right 1:在100码处右转

below shows the code that I currently have but it takes me online and gives me directions but I want the directions to appear in a textview. 下面显示了我当前拥有的代码,但它使我上线并给了我指导,但我希望这些指导出现在textview中。 How can the code be manipulated to achieve this? 如何操纵代码来实现这一目标?

 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.googleapis.com/maps/api/directions/json?origin=55.006108,-7.322766&destination=55.013534,-7.318560&sensor=false"));
 startActivity(intent);

You should check out the google maps API, rather than trying to parse a HTML page. 您应该签出google maps API,而不是尝试解析HTML页面。 Take a look here: https://developers.google.com/maps/documentation/directions/ 在这里看看: https : //developers.google.com/maps/documentation/directions/

You can call it like this: http://maps.googleapis.com/maps/api/directions/json?origin=20.344,34.34&destination=20.5666,45.345&sensor=false 您可以这样称呼它: http://maps.googleapis.com/maps/api/directions/json?origin=20.344,34.34&destination=20.5666,45.345&sensor=false : http://maps.googleapis.com/maps/api/directions/json?origin=20.344,34.34&destination=20.5666,45.345&sensor=false

FYI, those co-ordinates aren't valid for directions because they aren't on roads, so you will get back an error code when pasing them into the API. 仅供参考,这些坐标对于路线无效,因为它们不在道路上,因此将其粘贴到API中时,您将获得错误代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM