java在地图上获取路线点
我正在使用mapboxapi,希望通过List<Point>
获得从A到B的方向,我可以使用它在地图上绘制正确的路径。但问题是DirectionsResponse
返回的点数不够,请参阅
管线的一部分位于水面上。
可能在MapboxDirections
类中,或者另一个类中有step
方法和meters参数,以每10m获取Point
以下是我当前的代码:
MapboxDirections directions = MapboxDirections.builder()
.accessToken(ACCESS_TOKEN)
.profile(PROFILE_DRIVING)
// Brooklyn, NY, USA
.origin(Point.fromLngLat(-73.947803, 40.677790))
// Upper West Side, NY, USA
.destination(Point.fromLngLat(-73.971609, 40.784246))
.build();
Response<DirectionsResponse> response = directions.executeCall();
DirectionsResponse directionsResponse = response.body();
for (DirectionsRoute route : directionsResponse.routes()) {
List<Point> decode = PolylineUtils.decode(route.geometry(), PRECISION_6);
// I need here more points
for (Point point : decode) {
System.out.println(point.latitude() + ", " + point.longitude());
}
}
# 1 楼答案
尝试添加
.overview(DirectionsCriteria.OVERVIEW_FULL)
以获取所有点like in this example您的代码如下所示: