Question: I have seen few examples of using geoip in node.js such as <https://github.com/kuno/GeoIP.git> and <https://github.com/wadey/node-geoip>. However what i want is to display the map showing geoip for the particular loged in user.How can it be implemented.

Answer: 
I've just published an NPM module for the [IPLocate.io API](https://www.iplocate.io) which I created, which lets you find the location (city, country and coordinates) based on an IP address.

Super easy, no databases to download, and 1,500 free requests per day.

Install
-------

`npm install node-iplocate`

Usage
-----

```
const iplocate = require("node-iplocate");

iplocate("8.8.8.8").then(function(results) {
  console.log("IP Address: " + results.ip);
  // IP Address: 8.8.8.8
  console.log("Country: " + results.country + " (" + results.country_code + ")"); 
  // Country: United States (US)
  console.log("Continent: " + results.continent); 
  // Continent: North America
  console.log("Organisation: " + results.org + " (" + results.asn + ")"); 
  // Organisation: Google LLC (AS15169)

  console.log(JSON.stringify(results, null, 2));
  /*
    {
      "ip": "8.8.8.8",
      "country": "United States",
      "country_code": "US",
      "city": null,
      "continent": "North America",
      "latitude": 37.751,
      "longitude": -97.822,
      "time_zone": null,
      "postal_code": null,
      "org": "Google LLC",
      "asn": "AS15169"
    }
  */
});

// Or with callbacks
iplocate("8.8.8.8", null, function(err, results) {
  // ...
  console.log(JSON.stringify(results, null, 2));
});

// Provide an API key from IPLocate.io
iplocate("8.8.8.8", { api_key: "abcdef" }).then(function(results) {
  // ...
});

```
extending mpobrien's answer-

I found this to be easier and faster approach.
----------------------------------------------

Download the binary db at maxmind

<http://dev.maxmind.com/geoip/geoip2/geolite2/>
<http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz>

Use node-maxmind-db

<https://github.com/PaddeK/node-maxmind-db>

```
var mmdbreader = require('maxmind-db-reader');

// open database
var countries = mmdbreader.openSync('./countries.mmdb');

// get geodata
app.get('/api/v1/ip/', function(req, res) {
    var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

    countries.getGeoData(ip, function(err, geodata) {
        if(!err && geodata.location) return res.json({success: true, location: geodata.location});
        return res.json({success: false, location: null, error: err});
    });
});

```

Then you will have user location based on his ip address which you can display on map.

Benefits-

The bindary data file is small and easy to update. No db import export.
Just swap the file and reload the data. ie- `mmdbreader.openSync()`