How to get user mobile location on website?

I have a mobile app which is in vue and ionic. Another is a web app which is in laravel and jquery.

Now I want to share mobile phone location on the website how I can achieve that. I am confused about how google will tell a website where mobile phone user is?

18 thoughts on “How to get user mobile location on website?”

  1. The javascript geolocation API is used to do this.

    Some points from w3schools:

    The HTML Geolocation API is used to get the geographical position of a user.

    Since this can compromise privacy, the position is not available unless the user approves it.

    Note: Geolocation is most accurate for devices with GPS, like smartphones.

    On the linked page, a short piece of example code is provided that shows you how to do this:

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

Leave a Comment