class Geocoder::Result::Amap
def self.response_attributes
:cityCode
:business
Baidu's Geocoding API documentation and include (among others):
Get address components of a given type. Valid types are defined in
#
def self.response_attributes %w[roads pois roadinters] end
def address
def address formatted_address end
def address_components
def address_components @data['addressComponent'] || @data end
def city
def city address_components['city'] == [] ? province : address_components["city"] end
def coordinates
def coordinates location = @data['location'] || @data['roadinters'].try(:first).try(:[], 'location') \ || address_components.try(:[], 'streetNumber').try(:[], 'location') location.to_s.split(",").reverse.map(&:to_f) end
def country
def country "China" end
def country_code
def country_code "CN" end
def district
def district address_components['district'] end
def formatted_address
def formatted_address @data['formatted_address'] end
def postal_code
def postal_code "" end
def province
def province address_components['province'] end
def state
def state province end
def state_code
def state_code "" end
def street
def street if address_components["neighborhood"]["name"] != [] return address_components["neighborhood"]["name"] elsif address_components['township'] != [] return address_components["township"] else return @data['street'] || address_components['streetNumber'].try(:[], 'street') end end
def street_number
def street_number @data['number'] || address_components['streetNumber'].try(:[], 'number') end