1
我想使用地理編碼器獲取當前座標。通過地理編碼器獲取當前位置。 Rails
但
request.location.latitude
request.location.longitude
總是返回0.0和我0.0。 是否可以使用地理編碼器查找地理座標?
在此先感謝!
我想使用地理編碼器獲取當前座標。通過地理編碼器獲取當前位置。 Rails
但
request.location.latitude
request.location.longitude
總是返回0.0和我0.0。 是否可以使用地理編碼器查找地理座標?
在此先感謝!
這是因爲在開發環境中您的IP地址是127.0.0.1,這不是真正的Internet IP地址。這將工作返回一個互聯網IP的經緯度。
可以在開發環境中配置IP地址,這樣做增加下面的應用程序/配置/環境/ development.rb
class ActionDispatch::Request
def ip
"216.52.207.74"
end
end
重新啓動服務器產品線,現在它應該返回有效的緯度和經度