我正在使用HereMap
SDK在我的国家(越南)内绘制从一个地方到另一个地方的路径(可能在路径中有航点)。但是,我从API获得的路由结果是一条经过柬埔寨老挝(越南的邻国)的路径。我只希望路由结果是越南内部的路径。我已阅读HereMap
文档,但未找到解决方案或相关方法。我希望收到您的解决方案,非常感谢!
这是我计算路由的代码:
CoreRouter router = new CoreRouter();
// Create the RoutePlan and add two waypoints
RoutePlan routePlan = new RoutePlan();
for (AppContext.WDContext.WDLocation location : wdLocations) {
routePlan.addWaypoint(new RouteWaypoint(new GeoCoordinate(location.latitude, location.longitude)));
}
// Create the RouteOptions and set its transport mode & routing type
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.BALANCED); //I have also tried FASTEST and SHORTEST types
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new Router.Listener<List<RouteResult>, RoutingError>() {
@Override
public void onProgress(int i) {
}
@Override
public void onCalculateRouteFinished(List<RouteResult> routeResults, RoutingError routingError) {
// If the route was calculated successfully
if (routingError == RoutingError.NONE) {
// Render the route on the map
List<GeoCoordinate> coordinates = routeResults.get(0).getRoute().getRouteGeometry();
List<RoutingZone> zones = routeResults.get(0).getRoute().getRoutingZones();
// create GeoPolyline with list of GeoCoordinates
GeoPolyline geoPolyline = new GeoPolyline(coordinates);
MapPolyline polyline = new MapPolyline(geoPolyline);
polyline.setLineWidth(8);
// add GeoPolyline to current active map
mHereMap.addMapObject(polyline);
GeoBoundingBox boundingBox = routeResults.get(0).getRoute()
.getBoundingBox();
mHereMap.zoomTo(boundingBox, Map.Animation.NONE,40);
mHereMap.setPadding(40,40,40,40);
} else {
// Display a message indicating route calculation failure
NotificationHelper.getInstance().showBottomError("error - " + routingError.toString());
}
}
});