I have the latitude and longitude values. I want to display the name of the places that corresponds to those values.
I found that it can be done this way with curl.
http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY&format=json
How can I use this in my nodejs server running express and ejs? Right now the server passes the longitude and latitude coordinates to the client, so they are available in both the client and server.
First install request:
npm install request
Then:
var request = require('request'),
geoUrl = 'http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY&format=json';
request(geoUrl, function(err, response, body) {
console.log(body);
});
Handling the response is up to you -- it's not really JSON, it looks more like JSONP.