Class: GoogleMaps::Services::StreetViewImage
- Inherits:
-
Object
- Object
- GoogleMaps::Services::StreetViewImage
- Defined in:
- lib/googlemaps/services/streetview.rb
Overview
Performs requests to the Google Street View Map API.
Instance Attribute Summary collapse
-
#client ⇒ Symbol
The HTTP client.
Instance Method Summary collapse
-
#initialize(client) ⇒ StreetViewImage
constructor
A new instance of StreetViewImage.
-
#query(size:, location: nil, pano: nil, heading: nil, fov: nil, pitch: nil) ⇒ Hash
Get the street view map image.
Constructor Details
#initialize(client) ⇒ StreetViewImage
Returns a new instance of StreetViewImage.
21 22 23 |
# File 'lib/googlemaps/services/streetview.rb', line 21 def initialize(client) self.client = client end |
Instance Attribute Details
#client ⇒ Symbol
Returns The HTTP client.
19 20 21 |
# File 'lib/googlemaps/services/streetview.rb', line 19 def client @client end |
Instance Method Details
#query(size:, location: nil, pano: nil, heading: nil, fov: nil, pitch: nil) ⇒ Hash
Get the street view map image.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/googlemaps/services/streetview.rb', line 37 def query(size:, location: nil, pano: nil, heading: nil, fov: nil, pitch: nil) params = { 'size' => Convert.rectangular_dimensions(size) } if location params['location'] = Convert.to_latlng(location) end if pano params['pano'] = pano end if location && pano raise StandardError, 'should not specify both location and panorama ID.' end if heading raise StandardError, 'invalid compass heading value.' unless (0..360).include? heading params['heading'] = heading end if fov raise StandardError, 'invalid field of view (fov) value.' unless (0..120).include? fov params['fov'] = fov end if pitch raise StandardError, 'invalid pitch value.' unless (-90..90).include? pitch params['pitch'] = pitch end self.client.request(url: "/maps/api/streetview", params: params) end |