Class: Decidim::Map::DynamicMap::Builder

Inherits:
Frontend::Builder show all
Defined in:
decidim-core/lib/decidim/map/dynamic_map.rb

Overview

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

Direct Known Subclasses

Provider::DynamicMap::Here::Builder

Instance Method Summary collapse

Methods inherited from Frontend::Builder

#initialize

Constructor Details

This class inherits a constructor from Decidim::Map::Frontend::Builder

Instance Method Details

#javascript_snippetsObject

See Also:

  • View::Builder#javascript_snippets

83
84
85
# File 'decidim-core/lib/decidim/map/dynamic_map.rb', line 83

def javascript_snippets
  template.javascript_pack_tag("decidim_map_provider_default")
end

#map_element(html_options = {}) ⇒ String

Displays the map element's markup for the view.

Parameters:

  • html_options (Hash) (defaults to: {})

    Extra options to pass to the map element.

Returns:

  • (String)

    The map element's markup.


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'decidim-core/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.(:div, map_html_options) do
    (content || "")
  end
end

#stylesheet_snippetsObject

See Also:

  • View::Builder#stylesheet_snippets

78
79
80
# File 'decidim-core/lib/decidim/map/dynamic_map.rb', line 78

def stylesheet_snippets
  template.stylesheet_pack_tag("decidim_map")
end