google_maps_service_ruby 0.6.1 → 0.6.3
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/CHANGELOG.md +10 -0
- data/README.md +43 -20
- data/lib/google_maps_service/apis/directions.rb +8 -2
- data/lib/google_maps_service/apis/geocoding.rb +16 -4
- data/lib/google_maps_service/apis/places.rb +153 -0
- data/lib/google_maps_service/client.rb +2 -0
- data/lib/google_maps_service/polyline.rb +3 -3
- data/lib/google_maps_service/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71fd1ea5543cf0c41c68763e4ffaa218573e4965105a7973613bffcb94b9dcd2
|
4
|
+
data.tar.gz: a2eb9d2b1bb9368d0914798f49b8b5d27645ad0a056e7e62fd10fc6abcca83d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77a992d6ca82095447e3fb75bcb8e194ae627cc97b0c20c8e2cb6f0cfa575a08bf63a078242e6f91ef1396592f93cfa89a8c4086220d8016826a8634383c2284
|
7
|
+
data.tar.gz: 28ad069318403640c4f7a15fd7e752dc7c6102bee54fe2432370059d620555ab78358961fb0e3dade88195391f79e28bc4e1953b4e4e0f0b1c9aa9fec4204020
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.6.3 - 2023-06-04
|
6
|
+
|
7
|
+
* Add Places API place, places, places_nearby and places_photo support
|
8
|
+
|
9
|
+
## 0.6.2 - 2023-03-18
|
10
|
+
|
11
|
+
* Add support for ruby 3.2
|
12
|
+
* Allow directions to return full response from API with response_slice option
|
13
|
+
* Allow geocode and reverse_geocode to return full response from API with response_slice option
|
14
|
+
|
5
15
|
## 0.6.1 - 2023-03-18
|
6
16
|
|
7
17
|
* Fix gem name in README file
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ The Ruby gem for Google Maps Web Service APIs is a gem for the following Google
|
|
16
16
|
- [Google Maps Distance Matrix API][Distance Matrix API]
|
17
17
|
- [Google Maps Elevation API][Elevation API]
|
18
18
|
- [Google Maps Geocoding API][Geocoding API]
|
19
|
+
- [Google Maps Places API][Places API]
|
19
20
|
- [Google Maps Time Zone API][Time Zone API]
|
20
21
|
- [Google Maps Roads API][Roads API]
|
21
22
|
|
@@ -45,6 +46,20 @@ Note: Currently, [Roads API] does not accept client ID. It requires API key to a
|
|
45
46
|
|
46
47
|
This gem return a Ruby Hash/Array object as the API result. The result format structure is same as in Google Maps API documentation.
|
47
48
|
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
If you find a bug please [log an issue][issues].
|
52
|
+
|
53
|
+
The goal of this gem is to follow the API and implementation of the [python client](https://github.com/googlemaps/google-maps-services-python) as much as possible. If you would like to add support for an API please consider porting the python implementation.
|
54
|
+
|
55
|
+
To create a new pull request:
|
56
|
+
|
57
|
+
1. Fork it (https://github.com/langsharpe/google-maps-services-ruby/fork).
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
61
|
+
5. Create a new Pull Request.
|
62
|
+
|
48
63
|
## Requirements
|
49
64
|
|
50
65
|
- Ruby 2.7 or later.
|
@@ -141,7 +156,7 @@ end
|
|
141
156
|
gmaps = GoogleMapsService::Client.new
|
142
157
|
```
|
143
158
|
|
144
|
-
For more examples and detail (setup **proxy**, **timeout**, **caching**, etc.) while initializing the client, check out [Client documentation](
|
159
|
+
For more examples and detail (setup **proxy**, **timeout**, **caching**, etc.) while initializing the client, check out [Client documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Client#initialize-instance_method).
|
145
160
|
|
146
161
|
### Latitude/longitude pairs format
|
147
162
|
|
@@ -237,7 +252,7 @@ Sample result:
|
|
237
252
|
}]
|
238
253
|
```
|
239
254
|
|
240
|
-
For more usage examples and result format, check out [gem documentation](
|
255
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Directions), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/directions_spec.rb), and [Google Maps Directions API documentation][Directions API].
|
241
256
|
|
242
257
|
### Distance Matrix API
|
243
258
|
|
@@ -252,7 +267,7 @@ matrix = gmaps.distance_matrix(origins, destinations,
|
|
252
267
|
units: 'imperial')
|
253
268
|
```
|
254
269
|
|
255
|
-
For more usage examples and result format, check out [gem documentation](
|
270
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/DistanceMatrix), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/distance_matrix_spec.rb), and [Google Maps Distance Matrix API documentation][Distance Matrix API].
|
256
271
|
|
257
272
|
### Elevation API
|
258
273
|
|
@@ -266,7 +281,7 @@ locations = [[40.714728, -73.998672], [-34.397, 150.644]]
|
|
266
281
|
results = gmaps.elevation_along_path(locations, 5)
|
267
282
|
```
|
268
283
|
|
269
|
-
For more usage examples and result format, check out [gem documentation](
|
284
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Elevation), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/elevation_spec.rb), and [Google Maps Elevation API documentation][Elevation API].
|
270
285
|
|
271
286
|
### Geocoding API
|
272
287
|
|
@@ -278,7 +293,27 @@ results = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
|
|
278
293
|
results = gmaps.reverse_geocode([40.714224, -73.961452])
|
279
294
|
```
|
280
295
|
|
281
|
-
For more usage examples and result format, check out [gem documentation](
|
296
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Geocoding), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/geocoding_spec.rb), and [Google Maps Geocoding API documentation][Geocoding API].
|
297
|
+
|
298
|
+
### Places API
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
# Search for places
|
302
|
+
results = gmaps.places(
|
303
|
+
'Pizza Restaurant',
|
304
|
+
location: {:lat=>37.4221114, :lng=>-122.0867443},
|
305
|
+
)
|
306
|
+
|
307
|
+
# Search for places nearby
|
308
|
+
results = gmaps.places_nearby(
|
309
|
+
location: {:lat=>37.4221114, :lng=>-122.0867443},
|
310
|
+
radius: 5000,
|
311
|
+
)
|
312
|
+
|
313
|
+
# Get the url for a photo returned by the places api
|
314
|
+
url = gmaps.places_photo(photo_reference, max_width: 400, max_height: 400)
|
315
|
+
```
|
316
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Places), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/places_spec.rb), and [Google Maps Places API documentation][Places API].
|
282
317
|
|
283
318
|
### Roads API
|
284
319
|
|
@@ -309,7 +344,7 @@ place_ids = [
|
|
309
344
|
results = gmaps.speed_limits(place_ids)
|
310
345
|
```
|
311
346
|
|
312
|
-
For more usage examples and result format, check out [gem documentation](
|
347
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/Roads), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/roads_spec.rb), and [Google Maps Roads API documentation][Roads API].
|
313
348
|
|
314
349
|
### Time Zone API
|
315
350
|
|
@@ -321,7 +356,7 @@ timezone = gmaps.timezone([39.603481, -119.682251])
|
|
321
356
|
timezone = gmaps.timezone([39.603481, -119.682251], timestamp: Time.at(1608))
|
322
357
|
```
|
323
358
|
|
324
|
-
For more usage examples and result format, check out [gem documentation](
|
359
|
+
For more usage examples and result format, check out [gem documentation](https://www.rubydoc.info/gems/google_maps_service_ruby/GoogleMapsService/Apis/TimeZone), [test script](https://github.com/langsharpe/google-maps-services-ruby/tree/master/spec/google_maps_service/apis/time_zone_spec.rb), and [Google Maps Time Zone API documentation][Time Zone API].
|
325
360
|
|
326
361
|
### Polyline encoder/decoder
|
327
362
|
|
@@ -346,19 +381,6 @@ encoded_path = GoogleMapsService::Polyline.encode(path)
|
|
346
381
|
#=> "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
|
347
382
|
```
|
348
383
|
|
349
|
-
## Issues and feature suggestions
|
350
|
-
|
351
|
-
If you find a bug, or have a feature suggestion, please [log an issue][issues]. If you'd like to
|
352
|
-
contribute, please read [How to Contribute](#contributing).
|
353
|
-
|
354
|
-
## Contributing
|
355
|
-
|
356
|
-
1. Fork it (https://github.com/langsharpe/google-maps-services-ruby/fork).
|
357
|
-
2. Create your feature branch (`git checkout -b my-new-feature`).
|
358
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
359
|
-
4. Push to the branch (`git push origin my-new-feature`).
|
360
|
-
5. Create a new Pull Request.
|
361
|
-
|
362
384
|
[apikey]: https://developers.google.com/maps/faq#keysystem
|
363
385
|
[clientid]: https://developers.google.com/maps/documentation/business/webservices/auth
|
364
386
|
|
@@ -367,6 +389,7 @@ contribute, please read [How to Contribute](#contributing).
|
|
367
389
|
[Distance Matrix API]: https://developers.google.com/maps/documentation/distancematrix/
|
368
390
|
[Elevation API]: https://developers.google.com/maps/documentation/elevation/
|
369
391
|
[Geocoding API]: https://developers.google.com/maps/documentation/geocoding/
|
392
|
+
[Places API]: https://developers.google.com/maps/documentation/places/
|
370
393
|
[Time Zone API]: https://developers.google.com/maps/documentation/timezone/
|
371
394
|
[Roads API]: https://developers.google.com/maps/documentation/roads/
|
372
395
|
|
@@ -55,13 +55,15 @@ module GoogleMapsService::Apis
|
|
55
55
|
# `rail` is equivalent to `["train", "tram", "subway"]`.
|
56
56
|
# @param [String] transit_routing_preference Specifies preferences for transit
|
57
57
|
# requests. Valid values are `less_walking` or `fewer_transfers`.
|
58
|
+
# @param [Symbol] response_slice Specify subset of response to return. Defaults to :routes for
|
59
|
+
# backwards compatibility. Use :all to get complete response.
|
58
60
|
#
|
59
61
|
# @return [Array] Array of routes.
|
60
62
|
def directions(origin, destination,
|
61
63
|
mode: nil, waypoints: nil, alternatives: false, avoid: nil,
|
62
64
|
language: nil, units: nil, region: nil, departure_time: nil,
|
63
65
|
arrival_time: nil, optimize_waypoints: false, transit_mode: nil,
|
64
|
-
transit_routing_preference: nil)
|
66
|
+
transit_routing_preference: nil, response_slice: :routes)
|
65
67
|
|
66
68
|
params = {
|
67
69
|
origin: GoogleMapsService::Convert.waypoint(origin),
|
@@ -93,7 +95,11 @@ module GoogleMapsService::Apis
|
|
93
95
|
params[:transit_mode] = GoogleMapsService::Convert.join_list("|", transit_mode) if transit_mode
|
94
96
|
params[:transit_routing_preference] = transit_routing_preference if transit_routing_preference
|
95
97
|
|
96
|
-
|
98
|
+
if response_slice == :all
|
99
|
+
get("/maps/api/directions/json", params)
|
100
|
+
else
|
101
|
+
get("/maps/api/directions/json", params)[response_slice]
|
102
|
+
end
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
@@ -34,9 +34,11 @@ module GoogleMapsService::Apis
|
|
34
34
|
# @param [String] region The region code, specified as a ccTLD (_top-level domain_)
|
35
35
|
# two-character value.
|
36
36
|
# @param [String] language The language in which to return results.
|
37
|
+
# @param [Symbol] response_slice Specify subset of response to return. Defaults to :results for
|
38
|
+
# backwards compatibility. Use :all to get complete response.
|
37
39
|
#
|
38
40
|
# @return [Array] Array of geocoding results.
|
39
|
-
def geocode(address, components: nil, bounds: nil, region: nil, language: nil)
|
41
|
+
def geocode(address, components: nil, bounds: nil, region: nil, language: nil, response_slice: :results)
|
40
42
|
params = {}
|
41
43
|
|
42
44
|
params[:address] = address if address
|
@@ -45,7 +47,11 @@ module GoogleMapsService::Apis
|
|
45
47
|
params[:region] = region if region
|
46
48
|
params[:language] = language if language
|
47
49
|
|
48
|
-
|
50
|
+
if response_slice == :all
|
51
|
+
get("/maps/api/geocode/json", params)
|
52
|
+
else
|
53
|
+
get("/maps/api/geocode/json", params)[response_slice]
|
54
|
+
end
|
49
55
|
end
|
50
56
|
|
51
57
|
# Reverse geocoding is the process of converting geographic coordinates into a
|
@@ -65,9 +71,11 @@ module GoogleMapsService::Apis
|
|
65
71
|
# @param [String, Array<String>] location_type One or more location types to restrict results to.
|
66
72
|
# @param [String, Array<String>] result_type One or more address types to restrict results to.
|
67
73
|
# @param [String] language The language in which to return results.
|
74
|
+
# @param [Symbol] response_slice Specify subset of response to return. Defaults to :results for
|
75
|
+
# backwards compatibility. Use :all to get complete response.
|
68
76
|
#
|
69
77
|
# @return [Array] Array of reverse geocoding results.
|
70
|
-
def reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil)
|
78
|
+
def reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil, response_slice: :results)
|
71
79
|
params = {
|
72
80
|
latlng: GoogleMapsService::Convert.latlng(latlng)
|
73
81
|
}
|
@@ -76,7 +84,11 @@ module GoogleMapsService::Apis
|
|
76
84
|
params[:location_type] = GoogleMapsService::Convert.join_list("|", location_type) if location_type
|
77
85
|
params[:language] = language if language
|
78
86
|
|
79
|
-
|
87
|
+
if response_slice == :all
|
88
|
+
get("/maps/api/geocode/json", params)
|
89
|
+
else
|
90
|
+
get("/maps/api/geocode/json", params)[response_slice]
|
91
|
+
end
|
80
92
|
end
|
81
93
|
end
|
82
94
|
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require_relative "../validator"
|
2
|
+
|
3
|
+
module GoogleMapsService::Apis
|
4
|
+
# Performs requests to the Google Maps Places API.
|
5
|
+
module Places
|
6
|
+
# Places search.
|
7
|
+
#
|
8
|
+
# @param [String] query The text string on which to search, for example: "restaurant".
|
9
|
+
# @param [String, Hash, Array] location The latitude/longitude value for which you wish to obtain the
|
10
|
+
# closest, human-readable address.
|
11
|
+
# @param [Integer] radius Distance in meters within which to bias results.
|
12
|
+
# @param [String] language The language in which to return results.
|
13
|
+
# @param [Integer] min_price Restricts results to only those places with no less than
|
14
|
+
# this price level. Valid values are in the range from 0 (most affordable)
|
15
|
+
# to 4 (most expensive).
|
16
|
+
# @param [Integer] max_price Restricts results to only those places with no greater
|
17
|
+
# than this price level. Valid values are in the range from 0 (most
|
18
|
+
# affordable) to 4 (most expensive).
|
19
|
+
# @param [Boolean] open_now Return only those places that are open for business at
|
20
|
+
# the time the query is sent.
|
21
|
+
# @param [String] type Restricts the results to places matching the specified type.
|
22
|
+
# The full list of supported types is available here:
|
23
|
+
# https://developers.google.com/places/supported_types
|
24
|
+
# @param [String] page_token Token from a previous search that when provided will
|
25
|
+
# returns the next page of results for the same search.
|
26
|
+
# @return [Hash] Hash with the following keys:
|
27
|
+
# results: list of places
|
28
|
+
# html_attributions: set of attributions which must be displayed
|
29
|
+
# next_page_token: token for retrieving the next page of results
|
30
|
+
def places(query, location: nil, radius: nil, language: nil, min_price: nil,
|
31
|
+
max_price: nil, open_now: false, type: nil, page_token: nil)
|
32
|
+
|
33
|
+
_places("text", query: query, location: location, radius: radius,
|
34
|
+
language: language, min_price: min_price, max_price: max_price,
|
35
|
+
open_now: open_now, type: type, page_token: page_token)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Performs nearby search for places.
|
39
|
+
#
|
40
|
+
# @param [String, Hash, Array] location The latitude/longitude value for
|
41
|
+
# which you wish to obtain the closest, human-readable address.
|
42
|
+
# @param [Integer] radius Distance in meters within which to bias results.
|
43
|
+
# @param [String] keyword A term to be matched against all content that
|
44
|
+
# Google has indexed for this place.
|
45
|
+
# @param [String] language The language in which to return results.
|
46
|
+
# @param [Integer] min_price Restricts results to only those places with no
|
47
|
+
# less than this price level. Valid values are in the range from 0
|
48
|
+
# (most affordable) to 4 (most expensive).
|
49
|
+
# @param [Integer] max_price Restricts results to only those places with no
|
50
|
+
# greater than this price level. Valid values are in the range
|
51
|
+
# from 0 (most affordable) to 4 (most expensive).
|
52
|
+
# @param [String, Array] name One or more terms to be matched against the
|
53
|
+
# names of places.
|
54
|
+
# @param [Boolean] open_now Return only those places that are open for
|
55
|
+
# business at the time the query is sent.
|
56
|
+
# @param [String] rank_by Specifies the order in which results are listed.
|
57
|
+
# Possible values are: prominence (default), distance
|
58
|
+
# @param [String] type Restricts the results to places matching the
|
59
|
+
# specified type. The full list of supported types is available
|
60
|
+
# here: https://developers.google.com/places/supported_types
|
61
|
+
# @param [String] page_token Token from a previous search that when provided
|
62
|
+
# will returns the next page of results for the same search.
|
63
|
+
# @return [Hash] Hash with the following keys:
|
64
|
+
# status: status code
|
65
|
+
# results: list of places
|
66
|
+
# html_attributions: set of attributions which must be displayed
|
67
|
+
# next_page_token: token for retrieving the next page of results
|
68
|
+
def places_nearby(location: nil, radius: nil, keyword: nil, language: nil,
|
69
|
+
min_price: nil, max_price: nil, name: nil, open_now: false,
|
70
|
+
rank_by: nil, type: nil, page_token: nil)
|
71
|
+
if rank_by == "distance"
|
72
|
+
if !(keyword || name || type)
|
73
|
+
raise ArgumentError, "either a keyword, name, or type arg is " \
|
74
|
+
"required when rank_by is set to distance"
|
75
|
+
elsif radius
|
76
|
+
raise ArgumentError, "radius cannot be specified when rank_by " \
|
77
|
+
"is set to distance"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
_places("nearby", location: location, radius: radius,
|
82
|
+
keyword: keyword, language: language, min_price: min_price,
|
83
|
+
max_price: max_price, name: name, open_now: open_now,
|
84
|
+
rank_by: rank_by, type: type, page_token: page_token)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Comprehensive details for an individual place.
|
88
|
+
#
|
89
|
+
# @param[String] place_id A textual identifier that uniquely identifies a
|
90
|
+
# place, returned from a Places search.
|
91
|
+
# @param[String] language The language in which to return results.
|
92
|
+
# @return[Hash] Hash with the following keys:
|
93
|
+
# result: dict containing place details
|
94
|
+
# html_attributions: set of attributions which must be displayed
|
95
|
+
def place(place_id, language: nil)
|
96
|
+
params = {placeid: place_id}
|
97
|
+
params[:language] = language if language
|
98
|
+
get("/maps/api/place/details/json", params)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Photo URL from the Places API.
|
102
|
+
#
|
103
|
+
# @param[String] photo_reference A string identifier that uniquely
|
104
|
+
# identifies a photo, as provided by either a Places search or Places
|
105
|
+
# detail request.
|
106
|
+
# @param[Integer] max_width Specifies the maximum desired width, in pixels.
|
107
|
+
# @param[Integer] max_height Specifies the maximum desired height, in pixels.
|
108
|
+
# @return[String] String URL of the photo or nil upon error.
|
109
|
+
def places_photo(photo_reference, max_width: nil, max_height: nil)
|
110
|
+
unless max_width || max_height
|
111
|
+
raise ArgumentError, "a max_width or max_height arg is required"
|
112
|
+
end
|
113
|
+
|
114
|
+
params = {photoreference: photo_reference}
|
115
|
+
|
116
|
+
params[:maxwidth] = max_width if max_width
|
117
|
+
params[:maxheight] = max_height if max_height
|
118
|
+
|
119
|
+
image_response_decoder = ->(response) {
|
120
|
+
response["location"]
|
121
|
+
}
|
122
|
+
|
123
|
+
get("/maps/api/place/photo", params,
|
124
|
+
custom_response_decoder: image_response_decoder)
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
# Internal handler for ``places``, ``places_nearby``, and ``places_radar``.
|
130
|
+
# See each method's docs for arg details.
|
131
|
+
def _places(url_part,
|
132
|
+
query: nil, location: nil, radius: nil, keyword: nil, language: nil,
|
133
|
+
min_price: 0, max_price: 4, name: nil, open_now: nil,
|
134
|
+
rank_by: nil, type: nil, page_token: nil)
|
135
|
+
|
136
|
+
params = {}
|
137
|
+
params[:query] = query if query
|
138
|
+
params[:minprice] = min_price if min_price
|
139
|
+
params[:maxprice] = max_price if max_price
|
140
|
+
params[:location] = GoogleMapsService::Convert.latlng(location) if location
|
141
|
+
params[:radius] = radius if radius
|
142
|
+
params[:keyword] = keyword if keyword
|
143
|
+
params[:language] = language if language
|
144
|
+
params[:name] = GoogleMapsService::Convert.join_list(" ", name) if name
|
145
|
+
params[:opennow] = "true" if open_now
|
146
|
+
params[:rankby] = rank_by if rank_by
|
147
|
+
params[:type] = type if type
|
148
|
+
params[:pagetoken] = page_token if page_token
|
149
|
+
|
150
|
+
get("/maps/api/place/%ssearch/json" % url_part, params)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -8,6 +8,7 @@ require "google_maps_service/apis/directions"
|
|
8
8
|
require "google_maps_service/apis/distance_matrix"
|
9
9
|
require "google_maps_service/apis/elevation"
|
10
10
|
require "google_maps_service/apis/geocoding"
|
11
|
+
require "google_maps_service/apis/places"
|
11
12
|
require "google_maps_service/apis/roads"
|
12
13
|
require "google_maps_service/apis/time_zone"
|
13
14
|
|
@@ -25,6 +26,7 @@ module GoogleMapsService
|
|
25
26
|
include GoogleMapsService::Apis::DistanceMatrix
|
26
27
|
include GoogleMapsService::Apis::Elevation
|
27
28
|
include GoogleMapsService::Apis::Geocoding
|
29
|
+
include GoogleMapsService::Apis::Places
|
28
30
|
include GoogleMapsService::Apis::Roads
|
29
31
|
include GoogleMapsService::Apis::TimeZone
|
30
32
|
|
@@ -32,7 +32,7 @@ module GoogleMapsService
|
|
32
32
|
shift += 5
|
33
33
|
break if b < 0x1f
|
34
34
|
end
|
35
|
-
lat += (result & 1) != 0 ? (~result >> 1) : (result >> 1)
|
35
|
+
lat += ((result & 1) != 0) ? (~result >> 1) : (result >> 1)
|
36
36
|
|
37
37
|
result = 1
|
38
38
|
shift = 0
|
@@ -43,7 +43,7 @@ module GoogleMapsService
|
|
43
43
|
shift += 5
|
44
44
|
break if b < 0x1f
|
45
45
|
end
|
46
|
-
lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1)
|
46
|
+
lng += ((result & 1) != 0) ? ~(result >> 1) : (result >> 1)
|
47
47
|
|
48
48
|
points << {lat: lat * 1e-5, lng: lng * 1e-5}
|
49
49
|
end
|
@@ -71,7 +71,7 @@ module GoogleMapsService
|
|
71
71
|
d_lng = lng - last_lng
|
72
72
|
|
73
73
|
[d_lat, d_lng].each do |v|
|
74
|
-
v = v < 0 ? ~(v << 1) : (v << 1)
|
74
|
+
v = (v < 0) ? ~(v << 1) : (v << 1)
|
75
75
|
while v >= 0x20
|
76
76
|
result += ((0x20 | (v & 0x1f)) + 63).chr
|
77
77
|
v >>= 5
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_maps_service_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lang Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.28
|
153
153
|
description: Google Maps API Client, including the Directions API, Distance Matrix
|
154
|
-
API and
|
154
|
+
API, Geocoding API and Places API. google_maps_service_ruby is a fork of google_maps_service,
|
155
155
|
which is a fork of google-maps-services-python.
|
156
156
|
email:
|
157
157
|
- langer8191@gmail.com
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/google_maps_service/apis/distance_matrix.rb
|
170
170
|
- lib/google_maps_service/apis/elevation.rb
|
171
171
|
- lib/google_maps_service/apis/geocoding.rb
|
172
|
+
- lib/google_maps_service/apis/places.rb
|
172
173
|
- lib/google_maps_service/apis/roads.rb
|
173
174
|
- lib/google_maps_service/apis/time_zone.rb
|
174
175
|
- lib/google_maps_service/client.rb
|
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
204
|
- !ruby/object:Gem::Version
|
204
205
|
version: '0'
|
205
206
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
+
rubygems_version: 3.4.6
|
207
208
|
signing_key:
|
208
209
|
specification_version: 4
|
209
210
|
summary: Google Maps API Client
|