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

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

Overview

The static map utility class for the HERE maps service

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 'lib/decidim/map/provider/static_map/here.rb', line 10

def url_params(latitude:, longitude:, options: {})
  params = {
    c: "#{latitude}, #{longitude}",
    z: options[:zoom] || 15,
    w: options[:width] || 120,
    h: options[:height] || 120,
    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