简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM