Android - 折线编码算法?

Som*_*ddy 10 android google-maps

在我的android项目中,我有GeoPoints列表.我有一个算法来解码编码的折线字符串.任何人都可以帮助我将GeoPoints列表编码为折线字符串,以便将其保存在共享首选项中.

Chi*_*ara 15

你应该为Android添加新的googlemaps utils库,然后使用PolyUtil:

PolyUtil.encode(latLngPath)
PolyUtil.decode(encodedPath)
Run Code Online (Sandbox Code Playgroud)


Mar*_*ald 5

对于 Java,官方Google Maps Services for Java库也有一个实用程序。

PolylineEncoding.decode(String);
PolylineEncoding.encode(List<LatLng>); // Note that this is not the Android LatLng
Run Code Online (Sandbox Code Playgroud)

代码在这里。