Geolocation without permission request

Ive noticed that modern html5-based geolocation always asks the user: "Do you want to share your location with this site?" This is normal, but I know that there are other ways to determine the geolocation of balls without requiring this permission. If I remember, these services use ip databases to try and track geolocation information and provide it to a web application.

So, on my site, I would like to get a β€œbest guess” in the user's zip code without asking for a geolocation. What is the easiest and / or best way to do this?

+6
source share
3 answers

IP geolocation of IP addresses is less accurate, but you do not need user permission to do this. The http://ipinfo.io API (which is my service) makes it extremely simple. Here is a jQuery example:

$.get("http://ipinfo.io", function(response) { console.log(response.city, response.region, response.country); }, "jsonp"); 

More information is available here .

+8
source

Use the IP address of the script on the internal server using _SERVER variables. This is the only way without permission, but with huge drawbacks: 1) This is not entirely accurate 2) The IP address can be changed by the user if he uses a proxy server

But, nevertheless, this is the only way if you do not want to request permission.

Or you can just ask the user your zip code, since they want to use your site, they can also :)

Also, check out this post: Geolocation Without Request

+1
source

With https://ipdata.co API

 $.get("https://api.ipdata.co", function (response) { $("#response").html(JSON.stringify(response, null, 4)); }, "jsonp"); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <pre id="response"></pre> 
0
source

All Articles