Skip to content

Instantly share code, notes, and snippets.

@alvises
Last active September 16, 2016 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvises/852daf664600982693f73c7702af48e1 to your computer and use it in GitHub Desktop.
Save alvises/852daf664600982693f73c7702af48e1 to your computer and use it in GitHub Desktop.
Need a GeoIP Service? Build Your Own One with NodeJS and MongoDB
<html>
<head>
<title>MaxMind GeoIP test</title>
<script type="text/javascript" src="//js.maxmind.com/js/apis/geoip2/v2.0/geoip2.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<h1>Loading...</h1>
<script type="text/javascript">
$(document).ready(function(){
//localization
geoip2.city(function(location){
console.log("location loaded");
console.log(location);
var locString = location.city.names.en +
", "+location.country.names.en;
$("h1").first().text(locString);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment