在日志中
02-19 14:41:29.151 10336-10336/com.example.app E/BONUSPACK﹕ OSRMRoadManager::getRoad: request failed.
02-19 14:41:29.151 10336-10336/com.example.app I/System.out﹕ 2
我有route.gpx
个文件,但我不知道如何使用它
GeoPoint startPoint = new GeoPoint(48.13, -1.63);
mapView = (MapView) findViewById(R.id.mapview);
mapCTRL = (MapController) mapView.getController();
mapCTRL.setZoom(13);
mapView.setBuiltInZoomControls(true);
mapCTRL.setCenter((new GeoPoint(startPoint)));
RoadManager roadManager = new OSRMRoadManager();
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(startPoint);
//waypoints.add(new GeoPoint(16.236505, 103.264646)); //end point บ้านดินดำ
waypoints.add(new GeoPoint(48.4, -1.9)); //end point
Road road = roadManager.getRoad(waypoints);
System.out.println(road.mStatus);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, this);
mapView.getOverlays().add(roadOverlay);
mapView.invalidate();
setContentView(mapView);
mapView.invalidate();
答案 0 :(得分:1)
假设您打算使用在线路由服务,此问题应与此相关联: RoadManager for osmdroid error
假设您想要一个离线路由系统,那么使用OSRMRoadManager(使用OSRM在线服务)是无关紧要的。你可以看一下离线路由软件,比如GraphHopper。
答案 1 :(得分:0)
new Thread(new Runnable()
{
public void run()
{
RoadManager roadManager = new OSRMRoadManager();
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
GeoPoint startPoint = new GeoPoint(source_lat, source_longi);
waypoints.add(startPoint);
GeoPoint endPoint = new GeoPoint(desti_lat,desti_longi);
waypoints.add(endPoint);
try
{
road = roadManager.getRoad(waypoints);
}
catch (Exception e)
{
e.printStackTrace();
}
runOnUiThread(new Runnable()
{
public void run()
{
if (road.mStatus != Road.STATUS_OK)
{
//handle error... warn the user, etc.
}
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, Color.RED, 8, context);
map.getOverlays().add(roadOverlay);
}
});
}
}).start();
And i am use two jar files 1)slf4j-android-1.5.8.jar and 2)osmdroid-android-4.2.jar and osmbonuspack library.