如何在我的OSM应用程序中显示路线 [英] How to display Route on my OSM application

查看:893
本文介绍了如何在我的OSM应用程序中显示路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在日志

  02-19 14:41:29.151 10336-10336 / com.example.app E / BONUSPACK:OSRMRoadManager :: getRoad:请求失败。02-19 14:41:29.151 10336-10336 / com.example.app I / System.out的:2

和我有 route.gpx 文件,但我不知道如何使用它

 的GeoPoint的startPoint =新的GeoPoint(48.13,-1.63);    图形页面=(图形页面)findViewById(R.id.mapview);
    mapCTRL =(MapController)mapView.getController();    mapCTRL.setZoom(13);
    mapView.setBuiltInZoomControls(真);
    mapCTRL.setCenter((新的GeoPoint(的startPoint)));    RoadManager roadManager =新OSRMRoadManager();
    ArrayList的<&GeoPoint的GT;航点=新的ArrayList<&GeoPoint的GT;();
    waypoints.add(的startPoint);
    //waypoints.add(new的GeoPoint(16.236505,103.264646)); //终点บ้านดินดำ
    waypoints.add(新的GeoPoint(48.4,-1.9)); //终点    路路= roadManager.getRoad(航点);
    的System.out.println(road.mStatus);    折线roadOverlay = RoadManager.buildRoadOverlay(公路,这一点);
    调用MapView.getOverlays()加(roadOverlay)。
    mapView.invalidate();    的setContentView(图形页面);    mapView.invalidate();


解决方案

假设你打算使用在线路由服务,这个问题应该链接到这一个:
<一href=\"http://stackoverflow.com/questions/21213224/roadmanager-for-osmdroid-error-help-please\">RoadManager对于osmdroid错误,请帮助?

假设你想有一个离线路由系统,然后使用OSRMRoadManager(使用OSRM在线服务)是不相关的。你可以看看离线路由软件,如GraphHopper。

In log

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

and I have route.gpx file but i don't know how to use it

    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();

解决方案

Assuming you plan to use an online routing service, this question should be linked to this one: RoadManager for osmdroid error, help please?

Assuming you want to have an offline routing system, then using OSRMRoadManager (which uses OSRM online service) is irrelevant. You could have a look at offline routing software, like GraphHopper.

这篇关于如何在我的OSM应用程序中显示路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆