It always comes down to IP databases (ipinfo, maxmind, ip2location, ipdata, etc...), a website that wants to know your geolocation pays a fee to these databases to access their data via an API or any other interface (e.g. an actual local copy of the db).
IP DBs themselves always use WhoIS and...