【问题标题】:How to draw the route in a map with three points on Google Maps API for android? [duplicate]如何在 Google Maps API for android 上用三个点在地图中绘制路线? [复制]
【发布时间】:2018-02-20 02:20:29
【问题描述】:

基本上,我只需要实现的是,首先绘制两点之间的路线,从当前位置到地图上的任何其他点。并且当放置第三个点时,路线必须从当前点变为第三点,最后从第三点变为最终点。

供参考,

Point A - 当前/起始位置

B - 结束位置

C - 第三个位置

任务

1) 从AB

画点

2) 如果放置了C点,从A画到CC画到 B.

我该如何实现?

谢谢

【问题讨论】:

    标签: android google-maps


    【解决方案1】:

    您可以使用航路点。使用 Google Maps Directions API 计算路线时,您还可以为驾车、步行或骑车路线指定航点。航点不适用于公交路线。您可以使用航路点计算通过其他位置的路线,在这种情况下,返回的路线包括在每个给定航路点的中途停留。

    更多详情请访问here

    示例网址如下所示

    https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&key=YOUR_API_KEY
    

    【讨论】:

      【解决方案2】:

      这应该可行。

      private void displayDirection(List<LatLng> poly){
              PolylineOptions polylineOptions= new PolylineOptions();
                      polylineOptions.color(Color.RED);
                  for(int i=0; i<poly.size(); i++){
                      polylineOptions.width(8);
                      polylineOptions.add(poly.get(i));
                  }
              mMap.addPolyline(polylineOptions);
              }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-02
        • 2012-12-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多