Class: Decidim::StaticMapGenerator
- Inherits:
-
Object
- Object
- Decidim::StaticMapGenerator
- Defined in:
- app/services/decidim/static_map_generator.rb
Overview
This class generates a url to create a static map image for a geocoded resource
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(resource, options = {}) ⇒ StaticMapGenerator
constructor
A new instance of StaticMapGenerator.
Constructor Details
#initialize(resource, options = {}) ⇒ StaticMapGenerator
Returns a new instance of StaticMapGenerator.
6 7 8 9 10 11 12 13 |
# File 'app/services/decidim/static_map_generator.rb', line 6 def initialize(resource, = {}) @resource = resource @options = @options[:zoom] ||= 15 @options[:width] ||= 120 @options[:height] ||= 120 end |
Instance Method Details
#data ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/decidim/static_map_generator.rb', line 15 def data return if @resource.blank? || map_utility.nil? Rails.cache.fetch(@resource.cache_key) do map_utility.image_data( latitude: @resource.latitude, longitude: @resource.longitude, options: @options ) end end |