Module: GPolyline

Included in:
PointList
Defined in:
lib/kmlbo/g_polyline.rb

Overview

GPolyline is a module that implements the Google Polyline Algorithm Format. developers.google.com/maps/documentation/utilities/polylinealgorithm

Author

Josh Cronemeyer

Copyright

Copyright © 2008-2011

License

MIT License (www.opensource.org/licenses/mit-license.php)

Include this module into a class that has an instance variable called @tuple_array, where @tuple_array contains a list of geocoordinates of the form [[lng, lat, elev], …, [lng, lat, elev]]. It will override to_s and output an encoded path suitable for use in Google Maps v3 API

require "kmlbo/g_polyline"
class Polyline
  include GPolyline
  ...
end

path = Polyline.new
path.to_s
# => "svzmFdgi_QdA?nCA"

Ideas for this implementation of the google polyline algorithm format come from the following sources:

This implementation is tested against results from the Google API to ensure compatability. See unit tests for more information.

Instance Method Summary collapse

Instance Method Details

#to_sObject

Output an encoded path String suitable for use in Google Maps v3 API



33
34
35
# File 'lib/kmlbo/g_polyline.rb', line 33

def to_s
  encode_polyline_algorithm
end