1
votes

I was just wondering as to how to draw route direction(two point) of Google Maps in order for it to work offline. We have already downloaded offline Google Maps and then want navigation but do not know how to.

I was thinking of creating a navigation system with offline Google Maps, but I don't know how to draw route direction offline Google Map to work offline then embed it within my own application.

I have already used @mapbox Sdk, but my issue was I have downloaded offline location in Google Maps, after this location search any direction used two point direction in map, so I can drawline easily.

Using this : https://www.mapbox.com/android-sdk/examples/offline-manager/

Please help me on this one..

1

1 Answers

0
votes

Could you clarify how exactly you are getting Google Directions API to work offline, to my knowledge the API only works online? Drawing the route can be done in a few different ways. The simpliest would be to convert the linestring the directions API gives you into multiple positions and then feed them into the polyline:

private void drawRouteLine(DirectionsRoute route) {
List<Position> positions = LineString.fromPolyline(route.getGeometry(), Constants.PRECISION_6).getCoordinates();
List<LatLng> latLngs = new ArrayList<>();
for (Position position : positions) {
  latLngs.add(new LatLng(position.getLatitude(), position.getLongitude()));
}

routeLine = mapboxMap.addPolyline(new PolylineOptions()
  .addAll(latLngs)
  .color(Color.parseColor("#56b881"))
  .width(5f));
}