Nature, science, photography and other things that interest me.

Ruby Polyline Decoder For Google Maps

As promised I have finished the ruby polyline decoder. This class will take an encoded polyline and decode it returning an array of latitude and longitude values. This one gave me a headache. Hope you can find use of it. Please take time to tell me the projects you are using it for, I’m just nosy.

Usage example:

require ‘polyline_decoder’

line = “{b~zEdruxPT?L|@PP”

polyline_decoder = PolylineDecoder.new
line_arr = polyline_decoder.decode(line)

line_arr.each do |ln|
puts ln[0].to_s + “, ” + ln[1].to_s
end

That’s it!

Download – polyline_docder.rb

3 Responses

  1. Stanley

    Thank you!

    October 24, 2008 at 5:20 am

  2. Thanks man! This is what I needed.

    October 13, 2009 at 11:07 am

  3. Jordan

    Hey, file link is broken… any chance we can get an updated link?

    Thanks…

    September 3, 2010 at 6:57 pm

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>