Google map polyline in Android

1.2k views Asked by At

We are making map based mobile application available on iOS and Android. We want to draw a route on map and for that we are using polyline in iOS. Here is the iOS code for it.

let polyline = infoArray[activeIndex].polyLine // Polyline code in string format
let path: GMSPath = GMSPath(fromEncodedPath: polyline)!
let routePolyline = GMSPolyline(path: path)
routePolyline.strokeWidth = 3
routePolyline.map = mapView

But Android developer is unable how to draw it Android. How to do it for Android?

1

There are 1 answers

2
antonio On

You can use the PolyUtil.decode method from the Google Maps Android API Utility Library to get a List<LatLng> from a String encoded polyline.