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.
8 9 10 11 12 13 14 15 |
# File 'app/services/decidim/static_map_generator.rb', line 8 def initialize(resource, = {}) @resource = resource @options = @options[:zoom] ||= 15 @options[:width] ||= 120 @options[:height] ||= 120 end |
Instance Method Details
#data ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/services/decidim/static_map_generator.rb', line 17 def data return if Decidim.geocoder.nil? || @resource.blank? Rails.cache.fetch(@resource.cache_key) do request = HTTParty.get(uri, headers: { "Referer" => organization.host }) request.body end end |