Sample Google Maps Direction
Sample Google Maps Direction API for Java and Kotlin
Sample api from Google Maps Direction API
https://maps.googleapis.com/maps/api/directions/json?origin=-6.3035467,106.8693513&destination=-6.1890675,106.8251718&key=[YOUR_API_KEY]
Using Google Maps Utils Library
implementation 'com.google.maps.android:android-maps-utils:0.5'
Get overview_polyline
in JSON result using Retrofit for draw shape route and decode with this line
for java:
PolylineOptions polyline = new PolylineOptions()
.addAll(PolyUtil.decode(string_shape))
.width(8f)
.color(Color.RED);
map.addPolyline(polyline);
for kotlin:
val polyline = PolylineOptions()
.addAll(PolyUtil.decode(string_shape))
.width(8f)
.color(Color.RED)
map.addPolyline(polyline)