Class: Pinpoint::MapableService::GoogleMaps

Inherits:
Object
  • Object
show all
Defined in:
lib/pinpoint/mapable_services/google_maps.rb

Class Method Summary collapse

Class Method Details

.map_url(options = {}) ⇒ Object

Private: Renders a URL for a given location and location name using the Google Maps mapping service.

The location and location name will be properly escaped.

options - A Hash of options used in the method

:location      - A String representing the location to display
                 via the map URL
:location_name - A String representing the name of the
                 location to be displayed via the map URL

Example

map_url location:       'London, UK',
        location_name:  'Capital of the UK'
# => http://maps.google.com?q=London%2C+UK+%28Capital+of+the+UK%29


25
26
27
28
29
30
31
32
33
# File 'lib/pinpoint/mapable_services/google_maps.rb', line 25

def self.map_url(options = {})
  escaped_map_location  = CGI.escape options.fetch(:location).to_str
  escaped_location_name = CGI.escape "(#{options.fetch(:location_name)})"

  'http://maps.google.com?q=' +
  escaped_map_location +
  '+' +
  escaped_location_name
end