Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
Ask for user permission Location on Smartphone

I am using Geolocation API to detect the location of the user. I want now to get the location of the user on the smartphone. I have read the thread on I set geolocation permission in the manifest, but every page still asks to share location. But it is 8 years old. Is it possible to get the location of the user on smartphone? Should I write the Manifest for every single browser?

This is my code for this:

 <script>
const geoinfo = document.getElementById("geoinfo"); // not necessary thanks to IE quirk but good practice
 
navigator.geolocation.getCurrentPosition = function(success, error, options) { ... };
 
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        const { latitude, longitude, altitude } = position.coords;
        //geoinfo.innerHTML = `Breitengrad: ${latitude}, Längengrad: ${longitude}`;
        if (altitude) geoinfo.innerHTML += `, Höhe über Meeresspiegel: ${altitude}`;
        // send to server
        sendData(latitude, longitude);
    });
} else {
    geoinfo.innerHTML = 'Dieser Browser unterstützt die Abfrage der Geolocation nicht.';
}
 
async function sendData(lat, long) {
    const response = await fetch(`?lat=${lat}&long=${long}`); // send data to this script, regardless of filename
    if (response.ok) {
        const text = await response.text();
        if (text == "received") alert("Geodaten erfolgreich zum Server gesendet.");
    }
}   
    </script>

It is only working on Desktop PC´s....

This code which I found from the doc does not work?

 var options = {
      enableHighAccuracy: true,
      timeout: 5000,
      maximumAge: 0
    };

    function success(pos) {
      var crd = pos.coords;

      console.log('Your current position is:');
      console.log(`Latitude : ${crd.latitude}`);
      console.log(`Longitude: ${crd.longitude}`);
      console.log(`More or less ${crd.accuracy} meters.`);
    };

    function error(err) {
      console.warn(`ERROR(${err.code}): ${err.message}`);
    };

    navigator.geolocation.getCurrentPosition(success, error, options);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda