Class: Decidim::Map::Provider::StaticMap::Here
- 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
- #url(latitude:, longitude:, options: {}) ⇒ Object
- #url_params(latitude:, longitude:, options: {}) ⇒ Object
Methods inherited from StaticMap
Methods inherited from Utility
Constructor Details
This class inherits a constructor from Decidim::Map::Utility
Instance Method Details
#url(latitude:, longitude:, options: {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'decidim-core/lib/decidim/map/provider/static_map/here.rb', line 9 def url(latitude:, longitude:, options: {}) map_url = configuration.fetch(:url, nil) return super unless map_url return super unless map_url.include?("mia/v3") w = [:width] || Decidim::Map::StaticMap::DEFAULT_SIZE h = [:height] || Decidim::Map::StaticMap::DEFAULT_SIZE params = { apiKey: configuration[:api_key], overlay: "point:#{latitude},#{longitude};icon=cp;size=large|#{latitude},#{longitude};style=circle;width=50m;color=%231B9D2C60" } URI.parse("#{map_url}:radius=90/#{w}x#{h}/png8").tap do |uri| uri.query = URI.encode_www_form(params) end.to_s end |
#url_params(latitude:, longitude:, options: {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'decidim-core/lib/decidim/map/provider/static_map/here.rb', line 29 def url_params(latitude:, longitude:, options: {}) Decidim.deprecator.warn( " Please use a V3 version HERE maps.\n For further information, see:\n https://www.here.com/docs/bundle/map-image-migration-guide-v3/page/README.html\n Also make sure your Decidim.maps configurations are using the\n up to date format.\n You need to change:\n static_url = \"https://image.maps.ls.hereapi.com/mia/1.6/mapview\" if static_provider == \"here\" && static_url.blank?\n to:\n static_url = \"https://image.maps.hereapi.com/mia/v3/base/mc/overlay\" if static_provider == \"here\"\n in your config/initializers/decidim.rb file.\n DEPRECATION\n )\n\n params = {\n c: \"\#{latitude}, \#{longitude}\",\n z: options[:zoom] || Decidim::Map::StaticMap::DEFAULT_ZOOM,\n w: options[:width] || Decidim::Map::StaticMap::DEFAULT_SIZE,\n h: options[:height] || Decidim::Map::StaticMap::DEFAULT_SIZE,\n f: 1\n }\n\n params[:apiKey] = configuration[:api_key]\n\n params\nend\n".strip |