Abdul Hamid
Abdul Hamid

Reputation: 3252

How to find the geoip location for all users in 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

Upvotes: 1

Views: 3755

Answers (1)

FGRibreau
FGRibreau

Reputation: 7239

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

Upvotes: 2

Related Questions