1

Is there any free API/Web Service where I can get geolocation of those who visit my HTTP secure website?

before I use https://ssl.geoplugin.net/ to check this, but now they require a premium key to request location. I also tried to use the Google Maps GeoLocation API but it gives a wrong location. So I end up asking for any free javascript plugin to use. Thanks

roybalderama
  • 1,650
  • 21
  • 38

1 Answers1

3

This is actually a feature of HTML5, so to do this:

var x=document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else{
        x.innerHTML="Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML="Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude; 
}

Sourced from http://www.w3schools.com/html/html5_geolocation.asp

Joe F
  • 642
  • 4
  • 12
  • You should paste the code here instead of just including links. – Derek 朕會功夫 Apr 19 '13 at 01:06
  • How can I get Country and Region with that? – roybalderama Apr 19 '13 at 01:12
  • @lexeRoy, for that you could use google maps. Look [here](http://stackoverflow.com/questions/6747833/how-can-i-find-a-users-country-using-html5-geolocation). – Joe F Apr 19 '13 at 01:15
  • This kind of answers the problem--but not really. There are two types of geolocation. Explicit (which is the example you provided) and implicit which tries to determine on its own where you are located (which is like the ssl.geoplugin site) – Andrew Bowman May 24 '18 at 19:15