Class: Google::Geo::Address
- Inherits:
-
Object
- Object
- Google::Geo::Address
- Includes:
- Parser
- Defined in:
- lib/google/geo/address.rb,
lib/google/geo/address/street_view.rb
Overview
Represents locations returned in response to geocoding queries.
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
An integer, Google’s rating of the accuracy of the supplied address.
-
#city ⇒ Object
(also: #locality)
readonly
Returns the value of attribute city.
-
#coordinates ⇒ Object
readonly
An array containing the standard three elements of a coordinate triple: latitude, longitude, elevation.
-
#country ⇒ Object
(also: #country_code)
readonly
Returns the value of attribute country.
-
#county ⇒ Object
(also: #subadministrative_area)
readonly
Returns the value of attribute county.
-
#elevation ⇒ Object
readonly
A float, the standard third element of a coordinate triple.
-
#full_address ⇒ Object
(also: #to_s)
readonly
All address attributes as one string, formatted by the service.
-
#latitude ⇒ Object
(also: #lat)
readonly
A float, the standard second element of a coordinate triple.
-
#longitude ⇒ Object
(also: #lng)
readonly
A float, the standard first element of a coordinate triple.
-
#query ⇒ Object
readonly
The address query sent to the service.
-
#state ⇒ Object
(also: #administrative_area)
readonly
Returns the value of attribute state.
-
#street ⇒ Object
(also: #thoroughfare)
readonly
Returns the value of attribute street.
-
#zip ⇒ Object
(also: #postal_code)
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(placemark, query, geo) ⇒ Address
constructor
:nodoc.
-
#street_view_html(options = {}) ⇒ Object
This is a shady method which relies on an unofficial Google API.
Methods included from Parser
Constructor Details
#initialize(placemark, query, geo) ⇒ Address
:nodoc
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/google/geo/address.rb', line 51 def initialize(placemark, query, geo) #:nodoc @geo = geo @xml = placemark @query = query { :@street => :ThoroughfareName, :@city => :LocalityName, :@zip => :PostalCodeNumber, :@county => :SubAdministrativeAreaName, :@state => :AdministrativeAreaName, :@country => :CountryNameCode, :@full_address => :address }.each do |attribute, element| instance_variable_set(attribute, (fetch(element) rescue nil)) end @longitude, @latitude, @elevation = @coordinates = fetch(:coordinates).split(",").map { |x| x.to_f } @accuracy = fetch_accuracy end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
An integer, Google’s rating of the accuracy of the supplied address.
42 43 44 |
# File 'lib/google/geo/address.rb', line 42 def accuracy @accuracy end |
#city ⇒ Object (readonly) Also known as: locality
Returns the value of attribute city.
12 13 14 |
# File 'lib/google/geo/address.rb', line 12 def city @city end |
#coordinates ⇒ Object (readonly)
An array containing the standard three elements of a coordinate triple: latitude, longitude, elevation.
28 29 30 |
# File 'lib/google/geo/address.rb', line 28 def coordinates @coordinates end |
#country ⇒ Object (readonly) Also known as: country_code
Returns the value of attribute country.
24 25 26 |
# File 'lib/google/geo/address.rb', line 24 def country @country end |
#county ⇒ Object (readonly) Also known as: subadministrative_area
Returns the value of attribute county.
18 19 20 |
# File 'lib/google/geo/address.rb', line 18 def county @county end |
#elevation ⇒ Object (readonly)
A float, the standard third element of a coordinate triple.
39 40 41 |
# File 'lib/google/geo/address.rb', line 39 def elevation @elevation end |
#full_address ⇒ Object (readonly) Also known as: to_s
All address attributes as one string, formatted by the service.
45 46 47 |
# File 'lib/google/geo/address.rb', line 45 def full_address @full_address end |
#latitude ⇒ Object (readonly) Also known as: lat
A float, the standard second element of a coordinate triple.
35 36 37 |
# File 'lib/google/geo/address.rb', line 35 def latitude @latitude end |
#longitude ⇒ Object (readonly) Also known as: lng
A float, the standard first element of a coordinate triple.
31 32 33 |
# File 'lib/google/geo/address.rb', line 31 def longitude @longitude end |
#query ⇒ Object (readonly)
The address query sent to the service. i.e. The user input.
49 50 51 |
# File 'lib/google/geo/address.rb', line 49 def query @query end |
#state ⇒ Object (readonly) Also known as: administrative_area
Returns the value of attribute state.
21 22 23 |
# File 'lib/google/geo/address.rb', line 21 def state @state end |
#street ⇒ Object (readonly) Also known as: thoroughfare
Returns the value of attribute street.
9 10 11 |
# File 'lib/google/geo/address.rb', line 9 def street @street end |
#zip ⇒ Object (readonly) Also known as: postal_code
Returns the value of attribute zip.
15 16 17 |
# File 'lib/google/geo/address.rb', line 15 def zip @zip end |
Instance Method Details
#street_view_html(options = {}) ⇒ Object
This is a shady method which relies on an unofficial Google API. Use at your own risk!
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/google/geo/address/street_view.rb', line 8 def street_view_html( = {}) %{<embed id="#{[:id] or 'google-geo-streetview'}" style="#{[:style]}" src="http://maps.google.com/mapfiles/cb/googlepano.066.swf" quality="high" wmode="opaque" swliveconnect="false" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" scale="noscale" salign="lt" flashvars="panoId=#{street_view_pano_id}&directionMap=N:N,W:W,S:S,E:E,NW:NW,NE:NE,SW:SW,SE:SE&yaw=0&zoom=0&browser=3&pitch=5&viewerId=1&context=api&animateOnLoad=false&useSsl=false" ></embed>}.gsub("\n", "").squeeze(" ") end |