navigator.geolocation.getCurrentPosition Callbacks won't work on Firefox 10

后端 未结 2 1507
情话喂你
情话喂你 2021-02-05 14:57

I am building an app that uses the Geolocation API. I cant seem to get a very simple piece of code to work on Firefox 10. Here is the code:

    window.onload = f         


        
2条回答
  •  执笔经年
    2021-02-05 15:32

    I've made this example for you:

    if(!navigator.geolocation){
    alert('El Navegador no soporta GeoLocalización');
    }
    
    function doGeo( position ) 
    {
        var coords = position.coords.latitude + '+' + position.coords.longitude;
        var url = 'https://maps.google.es/?q=' + coords;
        $( "#lat" ).html("Latitud: " + position.coords.latitude );
        $( "#lon" ).html("Longitud: " + position.coords.longitude );
        $( "#acc" ).html("Precisión: " + position.coords.accuracy );
        $( "#alt" ).html("Altitud: " + position.coords.speed );        
        var link = 'Ir a la     Ubicación en Google Maps';
        $(link).appendTo('#GoogleMaps');
    }
    
    function lost()
    {
        alert('Algo salió mal, Intentelo más tarde...');
    };
    navigator.geolocation.watchPosition(doGeo, lost, {maximumAge:0,enableHighAccuracy:true}          );
    

    http://jsfiddle.net/aA2zv/35/

    hope it helps!

提交回复
热议问题