-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19b6054
commit 4f426e3
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var NodeGeocoder = require("node-geocoder"); | ||
var twitter = require("./gettweet.js"); | ||
var options = { | ||
provider: "google", | ||
httpAdapter: "https", | ||
apiKey: "Your API key here", | ||
formatter: null | ||
}; | ||
var geocoder = NodeGeocoder(options); | ||
|
||
var methods = {}; | ||
|
||
methods.locator = function(callback) { | ||
twitter.gettweet(function(response) { | ||
if (response.statusCode != 200) { | ||
console.log("No request made to google maps"); | ||
return callback(response); | ||
} else { | ||
console.log("Request made to google maps"); | ||
geocoder.geocode(response.location, function(err, data) { | ||
if (err) { | ||
console.log("Error occured........" + err); | ||
return callback({ | ||
statusCode: 400, | ||
statusMessage: JSON.stringify(err) | ||
}); | ||
} else { | ||
console.log("Location successfully returned..."); | ||
console.log(data); | ||
return callback({ | ||
statusCode: 200, | ||
latitude: data[0].latitude, | ||
longitude: data[0].longitude | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
module.exports = methods; |