Native (and better) way to get latitude&longitude (thanks +missfleur, also see in comments)
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
console.log(position) // object that contains latitude and longitude, among other things
});
});
this can be used in place of ipinfo.io, just do the rest as is in the getCurrentPosition callback function