sql >> Database >  >> RDS >> Mysql

Stuur de geolocatie van de gebruiker elke minuut naar de server

Je moet iets doen als:

var currPosition;
navigator.geolocation.getCurrentPosition(function(position) {
    updatePosition(position);
    setInterval(function(){
        var lat = currPosition.coords.latitude;
        var lng = currPosition.coords.longitude;
        jQuery.ajax({
            type: "POST", 
            url:  "myURL/location.php", 
            data: 'x='+lat+'&y='+lng, 
            cache: false
        });
    }, 1000);
}, errorCallback); 

var watchID = navigator.geolocation.watchPosition(function(position) {
    updatePosition(position);
});

function updatePosition( position ){
    currPosition = position;
}

function errorCallback(error) {
    var msg = "Can't get your location. Error = ";
    if (error.code == 1)
        msg += "PERMISSION_DENIED";
    else if (error.code == 2)
        msg += "POSITION_UNAVAILABLE";
    else if (error.code == 3)
        msg += "TIMEOUT";
    msg += ", msg = "+error.message;

    alert(msg);
}



  1. Dubbele waarden elimineren op basis van slechts één kolom van de tabel

  2. mysql_connect VS mysql_pconnect

  3. Fix "ERROR 1054 (42S22):Onbekende kolom '...' in 'on-clausule' in MariaDB

  4. Is er een Oracle SQL-query die meerdere rijen in één rij samenvoegt?