Module: Gmaps4railsHelper

Defined in:
lib/gmaps4rails/helper/gmaps4rails_helper.rb

Instance Method Summary collapse

Instance Method Details

#g_libraries(libraries_array) ⇒ Object



19
20
21
22
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 19

def g_libraries(libraries_array)
  return "" if libraries_array.nil?
  "," + libraries_array.join(",")
end

#gmaps(options, enable_css = true, enable_js = true) ⇒ Object

complete helper to pass all variables alongside their options



15
16
17
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 15

def gmaps(options, enable_css = true, enable_js = true )
  render :partial => 'gmaps4rails/gmaps4rails', :locals => { :options => options, :enable_css => enable_css, :enable_js => enable_js }
end

#gmaps4rails(builder, enable_css = true, enable_js = true) ⇒ Object

shortcut helper for basic marker display



5
6
7
8
9
10
11
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 5

def gmaps4rails(builder, enable_css = true, enable_js = true )
  options = {
    :map_options => { :auto_adjust => true},
    :markers     => { :data => builder, :options => {:do_clustering => true} }
  }
  render :partial => 'gmaps4rails/gmaps4rails', :locals => { :options => options, :enable_css => enable_css, :enable_js => enable_js }
end

#gmaps_container_class(options) ⇒ Object



28
29
30
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 28

def gmaps_container_class(options)
  options[:map_options].try(:[], :container_class) || "map_container"
end

#gmaps_map_class(options) ⇒ Object



32
33
34
35
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 32

def gmaps_map_class(options)
  default_class = options[:map_options].try(:[], :provider) == "bing" ? "bing_map" : "gmaps4rails_map"
  options[:map_options].try(:[], :class) || default_class
end

#gmaps_map_id(options) ⇒ Object



24
25
26
# File 'lib/gmaps4rails/helper/gmaps4rails_helper.rb', line 24

def gmaps_map_id(options)
  options[:map_options].try(:[], :id) || Gmaps4rails::DEFAULT_MAP_ID
end