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.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.md +34 -0
- data/README.md +299 -56
- data/google_maps_service.gemspec +3 -2
- data/lib/google_maps_service.rb +42 -9
- data/lib/google_maps_service/apis.rb +6 -0
- data/lib/google_maps_service/{directions.rb → apis/directions.rb} +38 -25
- data/lib/google_maps_service/{distance_matrix.rb → apis/distance_matrix.rb} +40 -21
- data/lib/google_maps_service/{elevation.rb → apis/elevation.rb} +22 -21
- data/lib/google_maps_service/apis/geocoding.rb +85 -0
- data/lib/google_maps_service/{roads.rb → apis/roads.rb} +68 -38
- data/lib/google_maps_service/{time_zone.rb → apis/time_zone.rb} +12 -7
- data/lib/google_maps_service/client.rb +175 -158
- data/lib/google_maps_service/convert.rb +19 -79
- data/lib/google_maps_service/errors.rb +13 -4
- data/lib/google_maps_service/polyline.rb +90 -0
- data/lib/google_maps_service/url.rb +64 -0
- data/lib/google_maps_service/validator.rb +16 -0
- data/lib/google_maps_service/version.rb +21 -1
- metadata +28 -25
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/lib/google_maps_service/geocoding.rb +0 -58
data/bin/console
DELETED
@@ -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,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
|