我从this post
这两功能的答案是需要的折线阵列编码成ASCII字符串
private static String encodeSignedNumber(int num) {
int sgn_num = num << 1;
if (num < 0) {
sgn_num = ~(sgn_num);
}
return(encodeNumber(sgn_num));
}
private static String encodeNumber(int num) {
StringBuffer encodeString = new StringBuffer();
while (num >= 0x20) {
encodeString.append((char)((0x20 | (num & 0x1f)) + 63));
num >>= 5;
}
encodeString.append((char)(num + 63));
return encodeString.toString();
}
测试尝试的坐标从this网站和比较输出
这里是片段
StringBuffer encodeString = new StringBuffer();
String encode = Geo_Class.encodeSignedNumber(3850000)+""+Geo_Class.encodeSignedNumber(-12020000);
encodeString.append(encode);
encode = Geo_Class.encodeSignedNumber(220000)+""+Geo_Class.encodeSignedNumber(-75000);
encodeString.append(encode);
encode = Geo_Class.encodeSignedNumber(255200)+""+Geo_Class.encodeSignedNumber(-550300);
encodeString.append(encode);
Log.v("encode string", encodeString.toString());
从统筹链接,您知道这一点
Points: (38.5, -120.2), (40.7, -120.95), (43.252, -126.453)
确定,所以现在你认为统筹是为什么不同的看到,当你得到新的坐标,那么你必须从以前的一个例如减
1. 3850000,-12020000 => 3850000,-12020000
2. 4070000,-12095000 => (4070000 - 3850000),(-12095000 - -12020000) => +220000, -75000
是看重你必须传递给encodeSignedNumber()方法,你会得到的是统筹
等ASCII值....
从经纬度/长度数字到ASCII字符串的算法是什么? – Jesper
此链接用于将ascii字符串解码为latlng值的多段线数组http://www.geekyblogger.com/2010/12/decoding-polylines-from-google-maps.html – Pratik
请注意,该文章包含[link (http://code.google.com/intl/nl-NL/apis/maps/documentation/utilities/polylinealgorithm.html)解释了如何进行编码。现在你只需要实现... – Jesper