In my android project I have List of GeoPoints. I have a algorithm to decode the encoded polyline string. Can anyone help me for encoding the List of GeoPoints to polyline string in-order to save this in Shared Preferences.
For Java generally, the official Google Maps Services for Java library has a utility, too.
PolylineEncoding.decode(String);
PolylineEncoding.encode(List<LatLng>); // Note that this is not the Android LatLng
Code is here.
you should include the new googlemaps utils library for Android and then use PolyUtil:
PolyUtil.encode(latLngPath)
PolyUtil.decode(encodedPath)
From Google:
http://groups.google.com/group/google-maps-api/browse_thread/thread/c85319eb7fd930dc
Seems like an Java Polyline impl. in progress.
From Github:
https://github.com/markrambow/JavaPolylineEncoder
https://github.com/petpen/JavaPolylineEncoder2
And the spec is here:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With