OSRMroadmanager构造函数给出错误

时间:2016-02-21 15:27:07

标签: android routing osmdroid

我开始使用OpenStreetMaps,使用Osmdroid和OSMbonuspack库,我有OSRMroadmanager构造函数的问题,它给了我错误。

“错误:(52,35)错误:类OSRMRoadManager中的构造函数OSRMRoadManager无法应用于给定类型;

必填:背景...... 发现:没有争论 原因:实际和正式的参数列表长度不同“

如果参数有问题,我应该将哪些参数传递给构造函数?

下面是代码。 提前谢谢。

公共类MainActivity扩展了AppCompatActivity {

@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MapView map = (MapView) findViewById(R.id.map);
    map.setTileSource(TileSourceFactory.MAPNIK);

    //zoom controllers
    map.setBuiltInZoomControls(true);
    map.setMultiTouchControls(true);

    //move to default view point
    IMapController mapController = map.getController();
    mapController.setZoom(9);
    GeoPoint startPoint = new GeoPoint(48.8583, 2.2944);
    mapController.setCenter(startPoint);

    //marker
    Marker startMarker = new Marker(map);
    startMarker.setPosition(startPoint);
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    map.getOverlays().add(startMarker);

    //refresh map
    map.invalidate();

    //string inside the marker box
    //startMarker.setIcon(getResources().getDrawable(R.drawable.center));
    startMarker.setTitle("default position");

    //routing
    RoadManager roadManager = new OSRMRoadManager();

    ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
    waypoints.add(startPoint);
    GeoPoint endPoint = new GeoPoint(48.4, -1.9);
    waypoints.add(endPoint);

    Road road = roadManager.getRoad(waypoints);

    Polyline roadOverlay = RoadManager.buildRoadOverlay(road, this);

    map.getOverlays().add(roadOverlay);
    map.invalidate();
}
}

1 个答案:

答案 0 :(得分:0)

RoadManager roadManager = new OSRMRoadManager(this);

我道歉,在向构造函数添加Context参数后,教程尚未更新。现在修复了。