如何在 Nodejs 中查找所有用户的 geoip 位置

我有一个要求,我必须找到用户的 geoip 位置.我已经使用了将用户地址存储在数据库中的代码,然后显示该用户的 geoip 位置.现在假设用户将他的位置更改为其他地方.如果用户现在从该地区或国家登录,如何我应该显示该用户的 geoip.我使用的代码是:

I have a requirement where i have to find the geoip location of the users. I have used the code where i store the address of the user in database and then display the geoip location of that user.Now suppose the users changed his location to some other place.If the user now logs in from that region or country, how should i display the geoip of that user. The code that i use is:

geo.geocoder(geo.google, address, sensor,function(formattedAddress, latitude, longitude) {
             console.log("Formatted Address: " + formattedAddress);
             console.log("Latitude: " + latitude);
             console.log("Longitude: " + longitude);
             user.latitude = latitude;
             user.longitude = longitude;
             user.save(function(err) {
               if(err)
                 return userUpdateFailed();
               req.flash('info', 'Succesfully Upadated Changes');
               res.redirect('/userinfo');
             });
          });

有没有其他方法可以找到用户的确切位置.请帮助

Is there any alternative wherby i can be able to find the exact location of user.Please help

推荐答案

Node-GeoIP 可以是一种解决方案,但请记住,基于 ip 的地理定位并不总是真实的.

Node-GeoIP could be a solution but keep in mind that ip-based geolocalization isn't always truthful.

相关文章