Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to find the geoip location for all users in Nodejs

How to find the geoip location for all users in Nodejs

Problem

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

Problem courtesy of: Inventillect

Solution

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

Solution courtesy of: FGRibreau

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How to find the geoip location for all users in Nodejs

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×