Android 如何在谷歌地图中显示两个地理坐标之间的路线?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2643993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:44:20  来源:igfitidea点击:

How to display a route between two geocoords in google maps?

androidgoogle-mapsoverlayroutes

提问by poeschlorn

Possible Duplicate:
J2ME/Android/BlackBerry - driving directions, route between two locations

可能重复:
J2ME/Android/BlackBerry - 行车路线,两个地点之间的路线

I'm just writing an App for displaying the route between two coords (lat, long) in google maps view. Displaying an single coord (even with a marker) works fine, but how to draw route between two point with 2 markers?

我正在编写一个应用程序,用于在谷歌地图视图中显示两个坐标(纬度、经度)之间的路线。显示单个坐标(即使使用标记)工作正常,但如何使用 2 个标记在两点之间绘制路线?

I must admit that I'm quite new to Android and the maps-API...

我必须承认,我对 Android 和地图 API 还很陌生……

采纳答案by Praveen

this is working example link. check it out. it helps to create the route overlay on the map. here is the complete sourcecode for that.

这是工作示例链接。一探究竟。它有助于在地图上创建路线叠加。这是完整的源代码。

回答by Robby Pond

Your route will be a list of points so you have to create a route overlay class. And in the draw method of the overlay class you have to draw a Path between the points.

您的路线将是一个点列表,因此您必须创建一个路线覆盖类。并且在覆盖类的绘制方法中,您必须在点之间绘制一条路径。