require 'active_support/inflector' module Leaflet module ViewHelpers def map(options) options[:tile_layer] ||= Leaflet.tile_layer options[:attribution] ||= Leaflet.attribution options[:max_zoom] ||= Leaflet.max_zoom options[:subdomains] ||= Leaflet.subdomains options[:container_id] ||= 'map' tile_layer = options.delete(:tile_layer) || Leaflet.tile_layer attribution = options.delete(:attribution) || Leaflet.attribution max_zoom = options.delete(:max_zoom) || Leaflet.max_zoom container_id = options.delete(:container_id) || 'map' no_container = options.delete(:no_container) center = options.delete(:center) markers = options.delete(:markers) circles = options.delete(:circles) polylines = options.delete(:polylines) fitbounds = options.delete(:fitbounds) output = [] output << "
" unless no_container output << "" output.join("\n").html_safe end private def prep_icon_settings(settings) settings[:name] = 'icon' if settings[:name].nil? or settings[:name].blank? settings[:shadow_url] = '' if settings[:shadow_url].nil? settings[:icon_size] = [] if settings[:icon_size].nil? settings[:shadow_size] = [] if settings[:shadow_size].nil? settings[:icon_anchor] = [0, 0] if settings[:icon_anchor].nil? settings[:shadow_anchor] = [0, 0] if settings[:shadow_anchor].nil? settings[:popup_anchor] = [0, 0] if settings[:popup_anchor].nil? return settings end end end