{"id":361,"date":"2008-08-02T15:32:39","date_gmt":"2008-08-02T20:32:39","guid":{"rendered":"http:\/\/unitstep.net\/?p=361"},"modified":"2009-02-28T20:57:00","modified_gmt":"2009-03-01T01:57:00","slug":"decoding-google-maps-encoded-polylines-using-php","status":"publish","type":"post","link":"https:\/\/unitstep.net\/blog\/2008\/08\/02\/decoding-google-maps-encoded-polylines-using-php\/","title":{"rendered":"Decoding Google Maps Encoded Polylines using PHP"},"content":{"rendered":"
I’ve talked about the Google Maps encoded polyline format<\/a> before<\/a>. While there’s some nice utilities for encoding polylines<\/a> that take the work out of implementing it yourself, I couldn’t find many polyline decoders<\/em>. <\/p>\n This made it somewhat tedious to decode them, as the only way to get the original list of points was to create a To solve this, I quickly ported the algorithm over to PHP<\/acronym> from the JavaScript source. Please feel free to download\/modify\/use this script.<\/p>\n <\/p>\n Since the encoded polyline format offers numerous benefits (and because I had data already stored in this format) I did not want to move away from it. At the same time, I needed access to the points for working with things like Google Static Maps<\/a>, which curiously does not accept the encoded polyline format for displaying paths. (Probably to reduce resource usage on their end, since decoding takes CPU time)<\/p>\nGPolyline<\/code><\/a> and then pull out the points from that object. This is not ideal since the work must always be done on the client side with JavaScript and using Google Maps.<\/p>\n