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 anonymous 05.10.2014 / 22:23

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.

    
06.10.2014 / 21:50
7

IP GEOLOCATION

This is actually very simple and works as follows:

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.

    
20.07.2016 / 02:07