Question

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 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.

Was it helpful?

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top