如何查找Nodejs中所有用户的地理位置位置 [英] How to find the geoip location for all users in Nodejs

查看:204
本文介绍了如何查找Nodejs中所有用户的地理位置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于如何查找Nodejs中所有用户的地理位置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆