0

currently im developing an OSMDroid map mainly in offline mode. everything is ok except im trying to cache the route in offline using RoadManager. the route can be displayed in online but for offline it appeared as a straight line, not the lines of route just like during online. Below is the code for the road manager, the route cn be seen except in offline. It would be a great honor for me if any of u cn help

RoadManager code

RoadManager roadManager = new MapQuestRoadManager("bOqEG6oonVKVMJGQj9GOVPBEvgcfUofu");
        roadManager.addRequestOption("routeType=shortest");

    Road road = roadManager.getRoad(geopoints);
    Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
    map.getOverlays().add(roadOverlay);
    List<GeoPoint> roadPoints = roadOverlay.getPoints();
    Log.d(TAG, "onCreate: road Points -> length:" + roadPoints.size());

codes that i want to be implemented in cache manager

 List<GeoPoint> roadPoints = roadOverlay.getPoints();
    Log.d(TAG, "onCreate: road Points -> length:" + roadPoints.size());

CacheManager but only for geopoints, unable to set roadpoint as parameter

 CacheManager cacheManager = new CacheManager(map);

 cacheManager.downloadAreaAsyncNoUI(getApplicationContext(),geopoints, 10, 15, new CacheManager.CacheManagerCallback() {
 public static final String TAG = "CacheManagerCallback";
        @Override
        public void onTaskComplete() {
            Log.d(TAG, "onTaskComplete: ");

        }

        @Override
        public void updateProgress(int progress, int currentZoomLevel, int zoomMin, int zoomMax) {
            Log.d(TAG, "updateProgress: " + progress);

        }

        @Override
        public void downloadStarted() {
            Log.d(TAG, "downloadStarted: ");
        }

        @Override
        public void setPossibleTilesInArea(int total) {
            Log.d(TAG, "setPossibleTilesInArea: " + total);
        }

        @Override
        public void onTaskFailed(int errors) {
            Log.d(TAG, "onTaskFailed: " + errors);
        }

    });
warabino
  • 21
  • 5

1 Answers1

1

CacheManager is about caching of tiles. It doesn't handle overlays.

You will have to implement this yourself. For markers and polylines (and polygons), using the KML API and storing the result in a KML file may be a simple solution. Look at OSMBonusPack tutorial pages.

MKer
  • 3,430
  • 1
  • 13
  • 18
  • does it means that I need to use KML so that the route cn be displayed during offline? – warabino Nov 08 '17 at 02:13
  • hi, now im able to store the kml file but how am I going to import the KML file so that when offiline the file is used bcause it already save the route. here's my code: – warabino Nov 08 '17 at 08:50
  • `KmlDocument kmlDocument = new KmlDocument(); kmlDocument.mKmlRoot.addOverlay(roadOverlay, kmlDocument); File localFile = kmlDocument.getDefaultPathForAndroid("my_route.kml"); kmlDocument.saveAsKML(localFile); kmlDocument.parseKMLFile(localFile); FolderOverlay kmlOverlay = (FolderOverlay)kmlDocument.mKmlRoot.buildOverlay(map, null, null, kmlDocument); map.getOverlays().add(kmlOverlay); BoundingBox bb = kmlDocument.mKmlRoot.getBoundingBox(); map.getController().setCenter(bb.getCenter());` – warabino Nov 08 '17 at 09:07