Class: StaticGmaps::Marker
- Inherits:
-
Object
- Object
- StaticGmaps::Marker
- Defined in:
- lib/static_gmaps2.rb
Overview
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#label ⇒ Object
Returns the value of attribute label.
-
#shadow ⇒ Object
readonly
Returns the value of attribute shadow.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #alpha_character ⇒ Object
-
#alpha_character=(value) ⇒ Object
for compatibility with original ruby api.
- #attributes ⇒ Object
- #available_parameters ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Marker
constructor
A new instance of Marker.
- #latitude ⇒ Object
- #latitude=(f) ⇒ Object
- #location ⇒ Object
- #location=(array_or_string) ⇒ Object
- #longitude ⇒ Object
- #longitude=(f) ⇒ Object
- #url_fragment ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Marker
Returns a new instance of Marker.
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/static_gmaps2.rb', line 145 def initialize( = {}, &block) self.location = [:location] || [StaticGmaps::default_latitude, StaticGmaps::default_longitude] self.label = [:label] || StaticGmaps::default_alpha_character self.color = [:color] || StaticGmaps::default_color # original api compatibility self.label = [:alpha_character] if [:alpha_character] self.latitude = [:latitude] if [:latitude] self.longitude = [:longitude] if [:longitude] yield self if block_given? end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
139 140 141 |
# File 'lib/static_gmaps2.rb', line 139 def color @color end |
#icon ⇒ Object
Returns the value of attribute icon.
139 140 141 |
# File 'lib/static_gmaps2.rb', line 139 def icon @icon end |
#label ⇒ Object
Returns the value of attribute label.
139 140 141 |
# File 'lib/static_gmaps2.rb', line 139 def label @label end |
#shadow ⇒ Object (readonly)
Returns the value of attribute shadow.
139 140 141 |
# File 'lib/static_gmaps2.rb', line 139 def shadow @shadow end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
139 140 141 |
# File 'lib/static_gmaps2.rb', line 139 def size @size end |
Instance Method Details
#alpha_character ⇒ Object
221 222 223 |
# File 'lib/static_gmaps2.rb', line 221 def alpha_character self.label end |
#alpha_character=(value) ⇒ Object
for compatibility with original ruby api
217 218 219 |
# File 'lib/static_gmaps2.rb', line 217 def alpha_character=(value) self.label = value end |
#attributes ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/static_gmaps2.rb', line 160 def attributes self.available_parameters.inject({}) do |store, parameter_name| value = self.send(parameter_name) store[parameter_name] = value if value store end end |
#available_parameters ⇒ Object
156 157 158 |
# File 'lib/static_gmaps2.rb', line 156 def available_parameters [:location, :color, :label, :size, :icon, :shadow] end |
#latitude ⇒ Object
198 199 200 |
# File 'lib/static_gmaps2.rb', line 198 def latitude @location.value[0] if @location.value.is_a?(Array) end |
#latitude=(f) ⇒ Object
190 191 192 |
# File 'lib/static_gmaps2.rb', line 190 def latitude=(f) @location.value[0] = f end |
#location ⇒ Object
186 187 188 |
# File 'lib/static_gmaps2.rb', line 186 def location @location ? @location.value : nil end |
#location=(array_or_string) ⇒ Object
182 183 184 |
# File 'lib/static_gmaps2.rb', line 182 def location=(array_or_string) @location = Location.new(array_or_string) end |
#longitude ⇒ Object
202 203 204 |
# File 'lib/static_gmaps2.rb', line 202 def longitude @location.value[1] if @location.value.is_a?(Array) end |
#longitude=(f) ⇒ Object
194 195 196 |
# File 'lib/static_gmaps2.rb', line 194 def longitude=(f) @location.value[1] = f end |
#url_fragment ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/static_gmaps2.rb', line 225 def url_fragment # markers=color:blue|label:S|62.107733,-145.541936&markers=size:tiny|color:green|Delta+Junction,AK raise ArgumentError.new("Location must be set before a url_fragment can be generated for Marker.") if !location marker_parameter_separator = "|" marker_value_separator = ":" location = @location.to_s str = "" attrs = self.attributes attrs.delete(:location) if !attrs.empty? str << attrs.map {|parameter, value| "#{parameter}#{marker_value_separator}#{value}"}.join(marker_parameter_separator) str << marker_parameter_separator end str << location str end |