How to find the geoip location for all users in Nodejs(如何在 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.
这篇关于如何在 Nodejs 中查找所有用户的 geoip 位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Nodejs 中查找所有用户的 geoip 位置


基础教程推荐
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 直接将值设置为滑块 2022-01-01