0

I need to get the users lat and lon from browser to display something related to their location.

I found some websites ask for allow access your location question when we load it.

May i know how can i do it for code igniter or any php based website?

Harikris
  • 314
  • 1
  • 6
  • 16

1 Answers1

1

HTML5 has a geolocation function, which is probably the access request you're thinking of:

Geolocation request

From http://www.w3schools.com/HTML/html5_geolocation.asp:

 <script>
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;
}
</script>
Jacey
  • 639
  • 6
  • 13