1

Have a simple function for init. lon and lat coordinates and this function returns the object with them.

function initPosMethod() {
  if (navigator.geolocation) {
    return navigator.geolocation.getCurrentPosition(initKoord);
  }
}

function initKoord(position) {
    var koordObj = {
        lan:position.coords.latitude,
        lon:position.coords.longitude
    };
    
    return koordObj;
}

initPosMethod();

So my question is, how it is possible, to get access to the 'koordObj'?

This is not working:

alert(initPosMethod.koordObj.lan);
  • Should call the function initPostMethod inside the alert, like : alert( initPosMethod().lan ); i think the call does not return a "koordObj" just return the Object so dot lan or lon but that's possible if change the return of navigator.geolocation coz is undefined.. – Joel Garcia Nuño Aug 18 '19 at 10:15

0 Answers0