Class: GoogleMap::Polyline
- Inherits:
-
Object
- Object
- GoogleMap::Polyline
- Includes:
- UnbackedDomId
- Defined in:
- lib/google_map/polyline.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#dom_id ⇒ Object
Returns the value of attribute dom_id.
-
#map ⇒ Object
Returns the value of attribute map.
-
#opacity ⇒ Object
Returns the value of attribute opacity.
-
#vertices ⇒ Object
Returns the value of attribute vertices.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Polyline
constructor
A new instance of Polyline.
- #to_js ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Polyline
Returns a new instance of Polyline.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/google_map/polyline.rb', line 14 def initialize( = {}) self.vertices = [] self.color = "#000" self.weight = 1 self.opacity = 1 .each_pair { |key, value| send("#{key}=", value) } if !map or !map.kind_of?(GoogleMap::Map) raise "Must set map for GoogleMap::Polyline." end if dom_id.blank? # This needs self to set the attr_accessor, why? self.dom_id = "#{map.dom_id}_marker_#{map.markers.size + 1}" end end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def color @color end |
#dom_id ⇒ Object
Returns the value of attribute dom_id.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def dom_id @dom_id end |
#map ⇒ Object
Returns the value of attribute map.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def map @map end |
#opacity ⇒ Object
Returns the value of attribute opacity.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def opacity @opacity end |
#vertices ⇒ Object
Returns the value of attribute vertices.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def vertices @vertices end |
#weight ⇒ Object
Returns the value of attribute weight.
7 8 9 |
# File 'lib/google_map/polyline.rb', line 7 def weight @weight end |
Instance Method Details
#to_js ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/google_map/polyline.rb', line 29 def to_js js = [] js << "#{dom_id}_vertices = new Array();" vertices.each_with_index do |point, index| js << "#{dom_id}_vertices[#{index}] = new GLatLng(#{point.lat}, #{point.lng});" end js << "#{dom_id} = new GPolyline(#{dom_id}_vertices, '#{color}', #{weight}, #{opacity});" js.join "\n" end |