I'm using Codehelper.io
Their PHP Class is nice, they can detect real IP for you, and get location , returned JSON with country, city, latidude, calling code, user's languages and more.
They also support Javascript. Check out example at their site.
<?php
// Required Libraries
require_once("ip.codehelper.io.php");
require_once("php_fast_cache.php");
// New Class
$_ip = new ip_codehelper();
// Detect Real IP Address & Location
$real_client_ip_address = $_ip->getRealIP();
$visitor_location = $_ip->getLocation($real_client_ip_address);
// Output result
echo $visitor_location['Country']."";
echo "<pre>";
print_r($visitor_location);