Class: Decidim::Map::Provider::StaticMap::Here

Inherits:
StaticMap show all
Defined in:
decidim-core/lib/decidim/map/provider/static_map/here.rb

Overview

The static map utility class for the HERE maps service

Constant Summary

Constants inherited from StaticMap

StaticMap::DEFAULT_SIZE, StaticMap::DEFAULT_ZOOM

Instance Attribute Summary

Attributes inherited from Utility

#configuration, #locale, #organization

Instance Method Summary collapse

Methods inherited from StaticMap

#image_data, #link, #url

Methods inherited from Utility

#initialize

Constructor Details

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

Instance Method Details

#url_params(latitude:, longitude:, options: {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'decidim-core/lib/decidim/map/provider/static_map/here.rb', line 10

def url_params(latitude:, longitude:, options: {})
  params = {
    c: "#{latitude}, #{longitude}",
    z: options[:zoom] || Decidim::Map::StaticMap::DEFAULT_ZOOM,
    w: options[:width] || Decidim::Map::StaticMap::DEFAULT_SIZE,
    h: options[:height] || Decidim::Map::StaticMap::DEFAULT_SIZE,
    f: 1
  }

  api_key = configuration[:api_key]
  if api_key.is_a?(Array)
    # Legacy way of configuring the API credentials
    params[:app_id] = api_key[0]
    params[:app_code] = api_key[1]
  else
    # The new way of configuring the API key
    params[:apiKey] = api_key
  end

  params
end