Class: Decidim::Map::DynamicMap

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

Overview

A base class for dynamic mapping functionality, common to all dynamic map services.

Defined Under Namespace

Classes: Builder

Instance Attribute Summary

Attributes inherited from Utility

#configuration, #locale, #organization

Instance Method Summary collapse

Methods inherited from Utility

#initialize

Constructor Details

This class inherits a constructor from Decidim::Map::Utility

Instance Method Details

#builder_classClass

Returns the builder class for the map. Allows fetching the class name dynamically also in the utility classes that extend this class.

Returns:

  • (Class)

    The class for the builder object.



23
24
25
# File 'lib/decidim/map/dynamic_map.rb', line 23

def builder_class
  self.class.const_get(:Builder)
end

#builder_optionsHash

Returns the options for the default builder object.

Returns:

  • (Hash)

    The default options for the map builder.



30
31
32
33
34
35
# File 'lib/decidim/map/dynamic_map.rb', line 30

def builder_options
  {
    marker_color: organization.colors.fetch("primary", "#ef604d"),
    tile_layer: tile_layer_configuration
  }
end

#create_builder(template, options = {}) ⇒ Decidim::Map::DynamicMap::Builder

Creates a builder class for the front-end that is used to build the map HTML markup.

Returns:



15
16
17
# File 'lib/decidim/map/dynamic_map.rb', line 15

def create_builder(template, options = {})
  builder_class.new(template, builder_options.merge(options))
end