2
I wish to MONITOR the user’s movement from the Android APP, which will be configured with the link from my dashboard.
I have the following code:
---------------------------------------------------------------------
    var geocoder;
var map;
var marker;
//PARTE PRINCIPAL
  function initialize() {
    var latlng = new google.maps.LatLng(-18.8800397, -47.05878999999999);
    var options = {
        zoom: 5,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("mapa"), options);
    geocoder = new google.maps.Geocoder();
    marker = new google.maps.Marker({
        map: map,
        draggable: true,
    });
    marker.setPosition(latlng);
}
//PARTE 000001
if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){ // callback de sucesso
        // ajusta a posição do marker para a localização do usuário
        marker.setPosition(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
    }, 
    
    function(error){ // callback de erro
       alert('Para um melhor desempenho nas entregas, ative a sua localização!');
       console.log('Erro ao obter localização.', error);
    });
} else {
    console.log('Navegador não suporta Geolocalização!');
}
//**************************
//**************************
//PARTE 00002
window.onload = function() {
  var startPos;
  var geoOptions = {
  timeout: 10 * 1000,
  maximumAge: 5 * 60 * 1000
  }
  var geoSuccess = function(position) {
    startPos = position;
    document.getElementById('startLat').innerHTML = startPos.coords.latitude;
    document.getElementById('startLon').innerHTML = startPos.coords.longitude;
  };
  
 
  navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions);
};
//PARTE 00003
//ATUALIZAR NO BANCO DE DADOS           
function Atualiza_Posicao(){
$.ajax({
    data: {"lat": + POSICAO-LAT-AQUI, "lng": + POSICAO-LNG-AQUI},
        type:'POST',        
        dataType: 'json',
        url:"atualizar-posicao.php"});
        //******************
    
}
//atualiza o mapa a cada segundo predefinido 
function foo() {
    //Colocar as funções aqui
    Atualiza_Posicao();
    
}
setInterval(foo, 4000);  
//****************************************************
  
---------------------------------------------------------------------
In the "/PART 00002" of the code there is this:
document.getElementById('startLat').innerHTML = startPos.coords.latitude;
    document.getElementById('startLon').innerHTML = startPos.coords.longitude;
Instead of showing the result of this in the DIV, I want to save in the database LATITUDE and LONGITUDE, but I’m not getting.
In this case, the result would be played for "/PART 00003", more precisely in "POSITION-LAT-HERE" and "POSITION-LNG-HERE"
    //ATUALIZAR NO BANCO DE DADOS           
    function Atualiza_Posicao(){
    $.ajax({
        data: {"lat": + POSICAO-LAT-AQUI, "lng": + POSICAO-LNG-AQUI},
            type:'POST',        
            dataType: 'json',
            url:"atualizar-posicao.php"});
            //******************
        
    }
In the question just put content and technical contextualization. If you need to do social contextualizations use the comment field.
– Augusto Vasques