Class: Graticule::Geocoder::Yandex

Inherits:
Base
  • Object
show all
Defined in:
lib/graticule/geocoder/yandex.rb

Overview

First you need a Yandex Maps API key. You can register for one here: api.yandex.ru/maps/form.xml

gg = Graticule.service(:yandex).new(MAPS_API_KEY)
location = gg.locate 'Россия, Москва, ул. Моховая, д.18'
p location.coordinates
#=> [37.612281, 55.753342]

Defined Under Namespace

Classes: Country, Error, FeatureMember, GeocoderMetaData, Response

Constant Summary collapse

PRECISION =
{
  :country  => Precision::Country,      # Country level accuracy.
  :province => Precision::Region,       # Region (state, province, prefecture, etc.) level accuracy.
  :area     => Precision::Region,       # Sub-region (county, municipality, etc.) level accuracy.
  :locality => Precision::Locality,     # Town (city, village) level accuracy.
  :metro    => Precision::Street,       # Street level accuracy.
  :street   => Precision::Street,       # Intersection level accuracy.
  :house    => Precision::Address,      # Address level accuracy.
}.stringify_keys

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Yandex

Returns a new instance of Yandex.


27
28
29
30
# File 'lib/graticule/geocoder/yandex.rb', line 27

def initialize(key)
  @key = key
  @url = URI.parse 'http://geocode-maps.yandex.ru/1.x/'
end

Instance Method Details

#locate(address) ⇒ Object

Locates address returning a Location


33
34
35
# File 'lib/graticule/geocoder/yandex.rb', line 33

def locate(address)
  get :geocode => address.is_a?(String) ? address : location_from_params(address).to_s
end