Reputation: 123
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.
Upvotes: 6
Views: 9835
Reputation: 832
Added this library work for me :
implementation 'com.google.maps:google-maps-services:2.2.0'
PolylineEncoding.decode(String);
PolylineEncoding.encode(List<LatLng>);
Upvotes: 0
Reputation: 8190
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.
Upvotes: 5
Reputation: 1887
you should include the new googlemaps utils library for Android and then use PolyUtil:
PolyUtil.encode(latLngPath)
PolyUtil.decode(encodedPath)
Upvotes: 15
Reputation: 7102
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
Upvotes: 4