相关疑难解决方法(0)

使用Google Maps API v2获取行车路线

我想在两个位置之间找到行车方向:

LatLng(12.917745600000000000,77.623788300000000000)
LatLng(12.842056800000000000,7.663096499999940000)
Run Code Online (Sandbox Code Playgroud)

我试过的代码:

Polyline line = mMap.addPolyline(new PolylineOptions().
    add(new LatLng(12.917745600000000000,77.623788300000000000),
    new LatLng(12.842056800000000000,7.663096499999940000))
       .width(5).color(Color.RED));
Run Code Online (Sandbox Code Playgroud)

但这在两点之间划了一条直线.

有没有其他方法/方法来获得这两点之间的行车路线.

java android google-maps directions google-maps-android-api-2

52
推荐指数
2
解决办法
11万
查看次数

在Android中使用Directions API显示多条路线

我正在使用这个类在地图上显示路线.问题是它只显示一条路线.我想要做的是在地图上显示多个备用路线.即使服务器响应有多条路由,它也只解析第一条路由并显示它.我应该做些什么更改才能显示google服务器返回的所有路由.这是我的课程.

public class GMapV2Direction {
    public final static String MODE_DRIVING = "driving";
    public final static String MODE = "walking";
    public final static String MODE_WALKING = "walking";

    public GMapV2Direction() { }

    public Document getDocument(LatLng start, LatLng end, String mode) {
        String url = "http://maps.googleapis.com/maps/api/directions/xml?" 
                + "origin=" + start.latitude + "," + start.longitude  
                + "&destination=" + end.latitude + "," + end.longitude 
                + "&sensor=false&units=metric&mode="+MODE+"alternatives=true";

        try {
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost(url);
            HttpResponse response …
Run Code Online (Sandbox Code Playgroud)

android google-maps directions google-maps-android-api-2

8
推荐指数
1
解决办法
1万
查看次数