Class: GoogleMap::Icon
- Inherits:
-
Object
- Object
- GoogleMap::Icon
- Defined in:
- lib/google_map/icon.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#anchor_x ⇒ Object
include Reloadable include UnbackedDomId.
-
#anchor_y ⇒ Object
include Reloadable include UnbackedDomId.
-
#dom_id ⇒ Object
include Reloadable include UnbackedDomId.
-
#height ⇒ Object
include Reloadable include UnbackedDomId.
-
#image_url ⇒ Object
include Reloadable include UnbackedDomId.
-
#info_anchor_x ⇒ Object
include Reloadable include UnbackedDomId.
-
#info_anchor_y ⇒ Object
include Reloadable include UnbackedDomId.
-
#map ⇒ Object
include Reloadable include UnbackedDomId.
-
#shadow_height ⇒ Object
include Reloadable include UnbackedDomId.
-
#shadow_url ⇒ Object
include Reloadable include UnbackedDomId.
-
#shadow_width ⇒ Object
include Reloadable include UnbackedDomId.
-
#width ⇒ Object
include Reloadable include UnbackedDomId.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Icon
constructor
A new instance of Icon.
- #to_html ⇒ Object
- #to_js ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Icon
Returns a new instance of Icon.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/google_map/icon.rb', line 20 def initialize( = {}) self.image_url = 'http://www.google.com/mapfiles/marker.png' self.shadow_url = 'http://www.google.com/mapfiles/shadow50.png' self.width = 20 self.height = 34 self.shadow_width = 37 self.shadow_height = 34 self.anchor_x = 6 self.anchor_y = 20 self.info_anchor_x = 5 self.info_anchor_y = 1 .each_pair { |key, value| send("#{key}=", value) } if !map or !map.kind_of?(GoogleMap::Map) raise "Must set map for GoogleMap::Icon." end if dom_id.blank? self.dom_id = "#{map.dom_id}_icon_#{map.markers.size + 1}" end end |
Instance Attribute Details
#anchor_x ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def anchor_x @anchor_x end |
#anchor_y ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def anchor_y @anchor_y end |
#dom_id ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def dom_id @dom_id end |
#height ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def height @height end |
#image_url ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def image_url @image_url end |
#info_anchor_x ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def info_anchor_x @info_anchor_x end |
#info_anchor_y ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def info_anchor_y @info_anchor_y end |
#map ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def map @map end |
#shadow_height ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def shadow_height @shadow_height end |
#shadow_url ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def shadow_url @shadow_url end |
#shadow_width ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def shadow_width @shadow_width end |
#width ⇒ Object
include Reloadable include UnbackedDomId
7 8 9 |
# File 'lib/google_map/icon.rb', line 7 def width @width end |
Instance Method Details
#to_html ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/google_map/icon.rb', line 54 def to_html html = [] html << "<script type=\"text/javascript\">\n/* <![CDATA[ */\n" html << to_js html << "/* ]]> */</script> " return html.join("\n") end |
#to_js ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/google_map/icon.rb', line 42 def to_js js = [] js << "var #{dom_id} = new GIcon();" js << "#{dom_id}.image = \"#{image_url}\";" js << "#{dom_id}.shadow = \"#{shadow_url}\";" js << "#{dom_id}.iconSize = new GSize(#{width}, #{height});" js << "#{dom_id}.shadowSize = new GSize(#{shadow_width}, #{shadow_height});" js << "#{dom_id}.iconAnchor = new GPoint(#{anchor_x}, #{anchor_y});" js << "#{dom_id}.infoWindowAnchor = new GPoint(#{info_anchor_x}, #{info_anchor_y});" return js.join("\n") end |