Is it possible to get user's location information through their ip?

Question:

Is there any possibility using programming to get locations from a supposed visitor to your website?

Example: "So and so" with ip: 192.168.254.1 visited my site: www.meusite.com.br

Through this ip obtained can I accurately determine geographic information of such user? The locality details I am referring to are the country , the state , the city and if possible the neighborhood .

I want to know if through programming (regardless of language) I can obtain such data from a visitor to my site.

Answer:

function getLocation(){
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  else{
    alert("O seu navegador não suporta Geolocalização.");
    }
}

function showPosition(position){
   alert("Latitude: " + position.coords.latitude + " Longitude: " + position.coords.longitude);  
}
Scroll to Top