How to determine the approximate location of the user by IP?

25

When I use search engines for certain searches, mostly related to maps or commercial establishments, these systems often serve me relevant results for my geographical location.

When I'm on the PC, search engines may not even know my geographical location with GPS accuracy, but they know at least which city I am in.

I believe this is determined by the IP address, since a specific address range is usually provided by the provider for well-defined regions.

But at the implementation level, how is this determination made? Is there a formula for determining the city or region of the user from their address? Or at least one known provider from which we can consume a service to obtain this information?

    
asked by Renan 05.10.2014 в 22:23
source

3 answers

6

Take a look here: link

We use this our site (www.ansb-brasil.org). If you write using the contact form, when the site thanks you, it indicates the IP, the country, and the city of you.

This does not really give the name of your city, but the name of your internet access point.

    
answered by 06.10.2014 / 21:50
source
7

IP GEOLOCATION

This is actually very simple and works as follows:

answered by 28.10.2014 в 19:58
6

Without wanting to make a soap, but already doing it, I have a library called WallaceMaxters\IPInfo , which takes the information from a determined IP.

See an example usage:

 IPInfo::get('8.8.8.8')->getCountry();

It internally uses the ipinfo.io API.

If you want an example, go to the url below to capture the information:

link

As stated in previous answers, you can not determine the exact location of the person. Maybe just approximate or even just inside the country.

    
answered by 20.07.2016 в 02:07