Last active
September 16, 2016 15:52
-
-
Save alvises/852daf664600982693f73c7702af48e1 to your computer and use it in GitHub Desktop.
Need a GeoIP Service? Build Your Own One with NodeJS and MongoDB
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
<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