Road Maneger for Osmdroid错误状态200

时间:2016-01-06 11:54:40

标签: android osmdroid

嗨我想在我的应用程序中使用osmdroid离线模式,我使用此代码

    Drawable marker = Mmarker;
    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();
    marker.setBounds(0, markerHeight/2, markerWidth/2, 0);

    ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getApplicationContext());

    myItemizedOverlay = new MyItemizedOverlay(marker, resourceProxy,mapView,getApplicationContext());
    mapView.getOverlays().add(myItemizedOverlay);

    mapView.setTileSource(new XYTileSource("MapQuest",
            ResourceProxy.string.mapquest_osm, 0, 18, 256, ".jpg", new String[] {
            "http://otile1.mqcdn.com/tiles/1.0.0/map/",
            "http://otile2.mqcdn.com/tiles/1.0.0/map/",
            "http://otile3.mqcdn.com/tiles/1.0.0/map/",
            "http://otile4.mqcdn.com/tiles/1.0.0/map/"}));
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);

    mapView.setUseDataConnection(false); //optional, but a good way to prevent loading from the network and test your zip loading.
    final IMapController mapController = mapView.getController();
    mapController.setZoom(14);     



class DrawPath extends AsyncTask<String,String,String>{
    RoadManager roadManager;
    ArrayList<GeoPoint> waypoints;
    Road road;
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        roadManager = new OSRMRoadManager();
        waypoints = new ArrayList<GeoPoint>();
        waypoints.add(myLocation);//start point
        waypoints.add(diCenter);// end point
        if (roadOverlay != null) {

            mapView.getOverlays().remove(roadOverlay);

        }
    }

    @Override
    protected String doInBackground(String... params) {

        road = roadManager.getRoad(waypoints);

        if (road.mStatus != Road.STATUS_OK){
            Log.e(tag, "drawPath road.status="+road.mStatus );
        }else{
            roadOverlay = RoadManager.buildRoadOverlay(road, getApplicationContext());
            Log.i(tag, "drawPath road.status="+road.mStatus );
        }
        return null;
    }

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);

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

但是每当我尝试绘制路径时,我都会收到状态为200的错误 我看到this link但没有帮助我 我的错误是:

D/BONUSPACK: OSRMRoadManager.getRoad:http://router.project-osrm.org/viaroute?&loc=36.339279999999995,59.551213&loc=36.311346,59.556574999999995&instructions=true&alt=false
W/System.err: [DEBUG] GbaRequest - GbaRequest: Constructor Called 222 userAgent null
W/System.err: [DEBUG] NafRequest - NafRequest: NafRequest constructor===useragent null     

我在浏览器中输入链接,我得到了这个

{"status":200,"hint_data":{"locations":["fktFBf____90qyUADQAAAB8AAAAAAAAACQAAAFGxpgInqAAANX4qAuWtjAMAAAEB","Erk6Bf____9G0yUACgAAAEUAAAAAAAAA9wAAAH3ntQInqAAAFxEqAgbDjAMAAAEB"],"checksum":2413689480},"route_name":["بولوار جانباز","بولوار خیام"],"via_indices":[0,55],"found_alternative":false,"route_summary":{"end_point":"بولوار خیام","start_point":"بولوار جانباز","total_time":291,"total_distance":4031},"via_points":[[36.339253,59.551205],[36.311319,59.556614]],"route_instructions":[["10","بولوار جانباز",2097,0,142,"2096m","E",103,1,"W",283],["11-2","بولوار جانباز",1072,35,92,"1071m","SE",135,1,"NW",315],["8","بولوار سجاد",205,48,16,"205m","SE",129,1,"NW",309],["3","بولوار خیام",520,50,31,"519m","SW",220,1,"NE",40],["7","",17,53,2,"16m","SE",129,1,"NW",309],["7","بولوار خیام",19,54,1,"18m","NE",40,1,"SW",220],["15","",0,55,0,"0m","N",0,"N",0]],"status_message":"Found route between points","route_geometry":"ib~hdAi}uqpBd@gEt@iGn@qGjC}W`@_ElL{qAnBuQbC{RpC_MzDuKdx@_vAxHmLlG}HpJmHvdBylApu@wg@jdIexFbdA}q@|O{JxJmEzI{CrIoB`Y{ClZDprAhFzDTjJpBbG|DhGdL|B|JlFrIlFpAfG[|FiD`EwIhNaRvEuAzM\\t}AfGb|@fDvKjAtGdAxG~A`NrFdCjBdnB~sBvsCd|CvGbBtaAocBnE_Ih\\|]vlCjtCnr@ju@|DgH}FkG"}

所以我认为链接是正确的。

所以有人可以帮我这个吗?

1 个答案:

答案 0 :(得分:0)

实际上,目前OSRM存在一个大问题。提升为Issue 195

等待修复,您可以切换到MapQuest或GraphHopper。

请记住,这些服务不能脱机工作,需要在线连接。