class Decidim::Map::DynamicMap::Builder

A builder for the dynamic maps to be used in the views. Provides all the necessary functionality to display and initialize the maps.

Public Instance Methods

javascript_snippets() click to toggle source

@see Decidim::Map::View::Builder#javascript_snippets

# File lib/decidim/map/dynamic_map.rb, line 83
def javascript_snippets
  template.javascript_include_tag("decidim/map/provider/default")
end
map_element(html_options = {}) { || ... } click to toggle source

Displays the map element's markup for the view.

@param html_options [Hash] Extra options to pass to the map element. @return [String] The map element's markup.

# File lib/decidim/map/dynamic_map.rb, line 63
def map_element(html_options = {})
  map_html_options = {
    "data-decidim-map" => view_options.to_json,
    # The data-markers-data is kept for backwards compatibility
    "data-markers-data" => options.fetch(:markers, []).to_json
  }.merge(html_options)

  content = template.capture { yield }.html_safe if block_given?

  template.content_tag(:div, map_html_options) do
    (content || "")
  end
end
stylesheet_snippets() click to toggle source

@see Decidim::Map::View::Builder#stylesheet_snippets

# File lib/decidim/map/dynamic_map.rb, line 78
def stylesheet_snippets
  template.stylesheet_link_tag("decidim/map")
end