class Jekyll::Maps::GoogleMapTag
Constants
- DEFAULT_MAP_HEIGHT
- DEFAULT_MAP_WIDTH
- JS_LIB_NAME
Public Class Methods
new(_, args, _)
click to toggle source
Calls superclass method
# File lib/jekyll-maps/google_map_tag.rb, line 8 def initialize(_, args, _) @args = OptionsParser.parse(args) @finder = LocationFinder.new(@args) super end
Public Instance Methods
render(context)
click to toggle source
# File lib/jekyll-maps/google_map_tag.rb, line 14 def render(context) locations = @finder.find(context.registers[:site], context.registers[:page]) @args[:attributes][:id] ||= SecureRandom.uuid <<HTML <div #{render_attributes}></div> <script type='text/javascript'> #{JS_LIB_NAME}.register( '#{@args[:attributes][:id]}', #{locations.to_json}, #{map_options(context.registers[:site]).to_json} ); </script> HTML end
Private Instance Methods
map_options(site)
click to toggle source
# File lib/jekyll-maps/google_map_tag.rb, line 56 def map_options(site) opts = { :baseUrl => site.baseurl || "/", :useCluster => !@args[:flags][:no_cluster], :showMarker => @args[:attributes][:show_marker] != "false", :showMarkerPopup => @args[:attributes][:show_popup] != "false" } print @args if @args[:attributes][:zoom] opts[:customZoom] = @args[:attributes][:zoom].to_i print "zoom!" print opts[:customZoom] end opts end
render_attributes()
click to toggle source
# File lib/jekyll-maps/google_map_tag.rb, line 31 def render_attributes attributes = [] attributes << "id='#{@args[:attributes][:id]}'" attributes << render_dimensions attributes << render_class if @args[:attributes][:class] attributes.join(" ") end
render_class()
click to toggle source
# File lib/jekyll-maps/google_map_tag.rb, line 49 def render_class css = @args[:attributes][:class] css = css.join(" ") if css.is_a?(Array) %(class='#{css}') end
render_dimensions()
click to toggle source
# File lib/jekyll-maps/google_map_tag.rb, line 40 def render_dimensions width = @args[:attributes][:width] || DEFAULT_MAP_WIDTH height = @args[:attributes][:height] || DEFAULT_MAP_HEIGHT width_unit = width.to_s.include?("%") ? "" : "px" height_unit = height.to_s.include?("%") ? "" : "px" %(style='width:#{width}#{width_unit};height:#{height}#{height_unit};') end