[英]rails geocoder gem query shows different nearby results
I am using the geocoder gem to show nearby results from the current IP address. 我正在使用地理编码器gem来显示当前IP地址的附近结果。 The problem is that geocoder shows nearby locations correctly only when I use wifi, otherwise I can see other locations that are not within 5 miles on 4g.
问题是地理编码器只有在我使用wifi时才能正确显示附近的位置,否则我可以看到4g以内不在5英里范围内的其他位置。
def index
location_info = request.location
@locations = Location.near([location_info.latitude, location_info.longitude], 5)
end
The results are different and when I check the database rails console
to see what the locations ip address is. 结果是不同的,当我检查数据库
rails console
,看看位置IP地址是什么。 I realised that cellular networks deal requests through their own network. 我意识到蜂窝网络通过自己的网络处理请求。 Wifi on the other hand uses my own private network which means a different ip address in the
ip_address
param. 另一方面,Wifi使用我自己的专用网络,这意味着
ip_address
参数中的不同IP地址。 Thus producing different results from the query above. 从而从上面的查询产生不同的结果。 I could be wrong but thats my assumption.
我错了,但那是我的假设。
Does anyone know if there is another way to get the same results on both wifi and through a cellular network on nearbys? 有没有人知道是否有另一种方法可以在wifi和通过近端网络上的蜂窝网络获得相同的结果?
There are different ip address used for wifi and cellular network. 有不同的IP地址用于wifi和蜂窝网络。 So this problem occurred.
所以发生了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.