Lat, lng points to GMmaps polyline in Ruby
Monday, February 11th, 2008def encode(num) str = "" num = (num * 1e5).floor num <<= 1 num = ~num if num < 0 while num >= 0x20 str += (((num & 0x1f) | 0x20) + 63).chr num >>= 5 end str += (num+63).chr return str end def to_encoded_polyline(points) polyline = "" points.each do |point| polyline += encode(point[:lat]) polyline += encode(point[:lng]) end return polyline end
