module OpenJpGeocoder
Constants
- VERSION
Public Class Methods
search(address)
click to toggle source
Your code goes hereā¦
# File lib/open_jp_geocoder.rb, line 8 def self.search(address) api_uri = URI.parse(URI.encode("https://msearch.gsi.go.jp/address-search/AddressSearch?q=#{address}")) geo_json = Net::HTTP.get(api_uri) geo_hash = JSON.parse(geo_json) if geo_hash.empty? 'not found' else {'latitude': geo_hash[0]['geometry']['coordinates'][1], 'longitude': geo_hash[0]['geometry']['coordinates'][0]} end end