Google maps getdirections api - polyline
I am using Google maps getDirections api. I use JSON type webservice to get the info from Google webservice. Here is the sample JSON output from webservice. I am using Java to process the result. I don't know how to read the polyline data. I have given a snippet of polyline object below.
"polyline": {
"points": "a~l~Fjk~uOwHJy@P",
"levels": "B?B"
},
The documentation says that
Polyline contains an object holding an array of encoded points and levels that represent an approximate (smoothed) path of the resulting 开发者_JS百科directions.
How to read the encoded data in Java. I need to decode both points and levels. A sample Java code snippet could help me a lot. Thanks.
I think this is what you want: http://www.geekyblogger.com/2010/12/decoding-polylines-from-google-maps.html
Here is Google's documentation of the encoded polyline format. If you want to display the directions in a browser then that is probably sufficient. If you do need the results in Java then here is a version of the decoder. I've never used it but it looks correct and resilient.
精彩评论