Class: MapWKT::Overlay::Polyline

Inherits:
MapWKT::Overlay show all
Defined in:
lib/mapwkt/gmap/polyline.rb

Instance Method Summary collapse

Methods inherited from MapWKT::Overlay

#center, #geometry, #initialize, #source

Constructor Details

This class inherits a constructor from MapWKT::Overlay

Instance Method Details

#js_output(map_name = nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/mapwkt/gmap/polyline.rb', line 4

def js_output (map_name = nil)
  points = self.geometry.open? ? self.geometry.points : [*self.geometry.points, self.geometry.points.first]
  path = "[#{points.map {|p| "new google.maps.LatLng(#{p.latitude_f},#{p.longitude_f})" }.join(?,)}]"
  
  "new google.maps.Polyline({#{" map: #{map_name}," if map_name} path: #{path} })"
end