Converting coordinates into map addresses

試著忘記壹切 提交于 2019-12-01 14:33:15
rubo77

Here you find How to convert GPS coordinates to a full address with php?

And in Ruby:

require 'curb'

require 'json'

class GpsUtils

GOOGLE_MAP_URL = "http://maps.googleapis.com/maps/api/geocode/json?latlng="

class << self

  # Return the address
  def convert_from_gps_coordinates_to_address(lat, long)
    response = Curl.get(GOOGLE_MAP_URL + lat + "," + long)
    json_response = JSON.parse(response.body_str)
    # Read the full address (formatted_address) from json_response
    json_response["results"].first["formatted_address"] 
  end 

end 

end

GpsUtils.convert_from_gps_coordinates_to_address("19.43250", "-99.1330"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!