google_maps_service 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "google_maps_service"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,58 +0,0 @@
1
- require 'google_maps_service/convert'
2
-
3
- module GoogleMapsService
4
-
5
- # Performs requests to the Google Maps Geocoding API.
6
- module Geocoding
7
-
8
- # Geocoding is the process of converting addresses
9
- # (like +"1600 Amphitheatre Parkway, Mountain View, CA"+) into geographic
10
- # coordinates (like latitude 37.423021 and longitude -122.083739), which you
11
- # can use to place markers or position the map.
12
- #
13
- # @param [String] address The address to geocode.
14
- # @param [Hash] components A component filter for which you wish to obtain a geocode,
15
- # for example: `{ 'administrative_area': 'TX','country': 'US' }`
16
- # @param [String, Hash] bounds The bounding box of the viewport within which to bias geocode
17
- # results more prominently. Accept string or hash with northeast and southwest keys.
18
- # @param [String] region The region code, specified as a ccTLD ("top-level domain")
19
- # two-character value.
20
- # @param [String] language The language in which to return results.
21
- #
22
- # @return Array of geocoding results.
23
- def geocode(address: nil, components: nil, bounds: nil, region: nil, language: nil)
24
- params = {}
25
-
26
- params[:address] = address if address
27
- params[:components] = GoogleMapsService::Convert.components(components) if components
28
- params[:bounds] = GoogleMapsService::Convert.bounds(bounds) if bounds
29
- params[:region] = region if region
30
- params[:language] = language if language
31
-
32
- return get('/maps/api/geocode/json', params)[:results]
33
- end
34
-
35
- # Reverse geocoding is the process of converting geographic coordinates into a
36
- # human-readable address.
37
- #
38
- # @param [Hash, Array] latlng The latitude/longitude value for which you wish to obtain the
39
- # closest, human-readable address#
40
- # @param [String, Array<String>] result_type One or more address types to restrict results to.
41
- # @param [Array<String>] location_type One or more location types to restrict results to.
42
- # @param [String] language The language in which to return results.
43
- #
44
- # @return Array of reverse geocoding results.
45
- def reverse_geocode(latlng: nil, result_type: nil, location_type: nil, language: nil)
46
- params = {
47
- latlng: GoogleMapsService::Convert.latlng(latlng)
48
- }
49
-
50
- params[:result_type] = GoogleMapsService::Convert.join_list("|", result_type) if result_type
51
- params[:location_type] = GoogleMapsService::Convert.join_list("|", location_type) if location_type
52
- params[:language] = language if language
53
-
54
- return get('/maps/api/geocode/json', params)[:results]
55
- end
56
-
57
- end
58
- end