Click here to Skip to main content
15,851,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to make it so when a truck driver presses a button when he starts for the day, i can see what his location is at that very moment so i know where my drivers are starting from.

I am trying to get it when someone gives acces to their location you can get a straight adress out of it as a variable. it just needs to be city and a country.

like this: Nottingham, NG1 1AJ, UK
Here the link as an example:

i can only find reverse geocoding where it just shows the location on the map.
below code uses reverse geocoding but gets an adress on a map.
i am trying to get it as a variable output to show in an app.
Thanks for the help!

What I have tried:

<!DOCTYPE html>
   <html lang="en">
       <meta charset="UTF-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <a href="#" id="get_location"><button>Get location</button></a>

       <div id="map">
           <iframe id="google_map"

           var x = document.getElementById("demo");
   function getLocation() {
     if (navigator.geolocation) {
     } else {
       x.innerHTML = "Locatie niet supported door jouw browser.";

   function showPosition(position) {
     x.innerHTML = "Latitude: " + position.coords.latitude +
     "<br>Longitude: " + position.coords.longitude;

   var c = function(pos) {
       var lat     = pos.coords.latitude
           long    = pos.coords.longitude
           coords  = lat + ', ' + long;

           document.getElementById('google_map').setAttribute('src', ''+ coords +'0&z=60&output=embed');

       document.getElementById('get_location').onclick = function() {
           return false;



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900