Hello,

Pour realiser le suivi d'un objet, j'aimerais afficher des lignes entre les positions successives de mon GPS.
En suivant ce tuto j'arrive a tracer des lignes mais c'est moi qui ecrit les coordonnees a la main.

Je recupere mes donnees GPS qui sont sotckees dans un tableau comme cela:
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<h2>Démo récupération données SigFox par l'API"</h2>
    <table>
        <thead>
            <tr>
                <th>Ref.</th>
                <th>Heure</th>
                <th>Data</th>
                <th>Lat</th>
                <th>Long</th>
                <th>Alt</th>
                <th>Temp</th>
                <th>SNR</th>
                <th>Qualite_Liaison</th>
            </tr>
        </thead>
    <tbody>
    <?php
    //$current = current($data['data']);
    //var_dump($current);
    $current_tab = current($data['data']);
    $current_data = $current_tab['data'];
    //var_dump($current_data);
    $current_lat=substr($current_data, 0,6);
    $current_lat_int = hexdec($current_lat); //conversion hexa -> decimal
    $current_lat_result = $current_lat_int/(float)(0xFFFFFF/360.0)-180; //conversion, precision
    //echo $current_lat_result;
 
    $current_long=substr($current_data, 6,6);
    $current_long_int = hexdec($current_long); //conversion hexa -> decimal
    $current_long_result = $current_long_int/(float)(0xFFFFFF/180.0)-90; //conversion, 
    //echo $current_long_result;
 
    $current_alt=substr($current_data, 12,4);
    $current_alt_int = hexdec($current_alt); //conversion hexa -> decimal
    //echo $current_alt_int;
 
    foreach($data['data'] as $reg){
      //print_r($data);
    ?>
    <tr>
        <td><?php echo $reg['device'];?></td>
        <td><?php echo date(DATE_RFC2822, $reg['time']);?></td>
 
        <td><?php 
        $data= $reg['data'];  //frame data
        echo $data;
        ?></td>
        <td><?php
        $lat_str = substr($data, 0, 6); //6 premiers caracteres
        $lat_int = hexdec($lat_str); //conversion hexa -> decimal
        $lat_result = $lat_int/(float)(0xFFFFFF/360.0)-180; //conversion, precision
        echo $lat_result; 
        ?></td>
 
        <td><?php
        $long_str = substr($data, 6, 6);
        $long_int = hexdec($long_str);
        $long_result = $long_int/(float)(0xFFFFFF/180.0)-90; //conversion, precision
        echo $long_result;
        ?></td>
 
        <td><?php
        $alt_str = substr($data, 12, 4);
        $alt_int = hexdec($alt_str);
        echo $alt_int;
        ?></td> 
        <td><?php
        $temp_str = substr($data, 16, 4);
        $temp_int = hexdec($temp_str);
        $temp_result = $temp_int/(float)(0xFFFF/200.0)-128; //conversion, precision
        echo $temp_result;
        ?></td>
 
        <td><?php echo $reg['snr'];?></td>
        <td><?php
        $qualite= $reg['linkQuality'];
        switch ($qualite) {
            case "EXCELLENT":
                echo "Excellente";
                break;
            case "GOOD":
                echo "Bonne";
                break;
            case "AVERAGE":
                echo "Moyenne";
                break;
            case "LIMIT" :
                echo "Faible";
                break;
        }
        ?>
 
        </td>
    </tr>
    <?php
     }
    ?>
    </tbody>
    </table>

Ce qui donne cela:
Nom : tabsigfoxgps.jpg
Affichages : 664
Taille : 417,1 Ko

Pour tracer les lignes j'ai le code suivant:
Code js : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var flightPlanCoordinates = [
         // {lat: lat, lng: long},
          {lat: <?php echo $current_lat_result; ?>, lng: <?php echo $current_long_result; ?>},
          {lat: -18.143333422, lng: 178.431},
          {lat: -27.4325567, lng: 153.02235257},
          {lat: 56.2, lng: 18.3},
          {lat: 12.2, lng: 33.356363},
          {lat: 44, lng: 62.3},
          {lat: 4.2, lng: 62.3}
        ];
 var flightPath = new google.maps.Polyline({
          path: flightPlanCoordinates,
          geodesic: true,
          strokeColor: '#FF0000',
          strokeOpacity: 1.0,
          strokeWeight: 2
        });
 
 flightPath.setMap(map);

Ici le point de depart c'est ma position actuelle et les autres positions ont ete rentrees a la main.
Nom : trajetmap.jpg
Affichages : 685
Taille : 128,3 Ko

Comment faire pour qu'a chaque fois qu'une position GPS s'ajoute dans mon tableau, une ligne soit tracee entre la position precedente et cette nouvelle position GPS ?

Merci!

EDIT:
En ecrivant cela j'obtiens un trace entre ma position actuelle (qui est la premiere position de mon tableau) et la derniere position du tableau:

Code js : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
var flightPlanCoordinates = [
        {lat: <?php echo $lat_result; ?>, lng: <?php echo $long_result; ?>},  
        {lat: <?php echo $current_lat_result; ?>, lng: <?php echo $current_long_result; ?>}
        ];

Nom : map.jpg
Affichages : 651
Taille : 72,2 Ko

Bon, il me manque plus que toutes les positions entre le debut et la fin..
Je suppose que je dois faire une boucle et j'essaye des trucs mais pour l'instant je n'y arrive pas.