简体   繁体   中英

rails geocoder gem query shows different nearby results

I am using the geocoder gem to show nearby results from the current IP address. 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.

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. 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. 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?

There are different ip address used for wifi and cellular network. So this problem occurred.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM