2017-03-01 14 views
0

我在我的应用程序中添加标记GoogleMaps,我的标记总是在街道上。例如,我在地图上拥有超过2个标记,我需要绘制最佳他们之间的路线取决于街道。是否有任何服务可以帮助我,或者我需要创建自己的算法?到现在为止我工作了一点Google Elevation APIGoogle Direction API,但现在我需要Google Roads API,找到点之间的最佳道路?它一定是类似于我的需求的东西。Android:根据GoogleMaps中的街道查找2个或更多点之间的最快路线

回答

1

考虑使用以下库:https://github.com/akexorcist/Android-GoogleDirectionLibrary

GoogleDirection.withServerKey("YOUR_SERVER_API_KEY") 
     .from(new LatLng(37.7681994, -122.444538)) 
      .to(new LatLng(37.7749003,-122.4034934)) 
      .avoid(AvoidType.FERRIES) 
      .avoid(AvoidType.HIGHWAYS) 
      .execute(new DirectionCallback() { 
    @Override 
    public void onDirectionSuccess(Direction direction, String rawBody) { 
     if(direction.isOK()) { 
      // Do something 
     } else { 
      // Do something 
     } 
    } 

    @Override 
    public void onDirectionFailure(Throwable t) { 
     // Do something 
    } 
}); 

摇篮

compile 'com.akexorcist:googledirectionlibrary:1.0.5' 
+0

你有没有使用它,它可以用更thab 2点上班? – Darius92

相关问题