2

私は、航空機マーカーを含むマップを表示し、シミュレーターでの実際の位置に従って移動する必要がある ACARS ページに取り組んでいます。それらの実際の位置は、telnet を使用してシムに接続する別の Java GUI を使用して、毎分 MySQL テーブルに供給されます。

さて、このために、私は基本的にこれを使用しています:

setInterval(function(){
    $("#tracking").load("atc.php #tracking");
    $("#mapcode").load("update_map.php");
}, 30000);

#tracking 部門は、航空機に関するデータを含む ACARS テーブル用であり、マーカーを更新するコード用の場合は #mapcode 部門です。ところで、ACARS テーブルは機能し、正常に更新されます。問題があるのはマップだけです。

update_map.phpのコードは次のとおりです。

    <?php

echo '<script type="text/javascript">

        function updateMap() {
';

mysql_connect("localhost", "<hidden here>", "<hidden here>");
mysql_select_db("virtua6_flightdeck");

$sql = mysql_query(" SELECT * FROM `flightdeck_acars` ");

echo 'map.clearOverlays();';

    while($result = mysql_fetch_assoc($sql)) {

        echo 'aircraftPos = new google.maps.LatLng(' . $result['lat'] . ', ' . $result['lon'] . ');
        ';

    $code = substr($result['flightnum'], 0, 3); 

    if ($result['pilotid'] > 999) {

        $pilotid = $code . $result['pilotid'];

    } elseif ($result['pilotid'] > 99) {

        $pilotid = $code . '0' . $result['pilotid'];

    } elseif ($result['pilotid'] > 9) {

        $pilotid = $code . '00' . $result['pilotid'];

    } else {

        $pilotid = $code . '000' . $result['pilotid'];

    }

    $hdgInt = $result['hdg'];           

    echo    'new google.maps.Marker({
            position: aircraftPos,
            map: map,
            title: "' . $result['flightnum'] . ' [' . $result['depicao'] . '-' . $result['arricao'] . ']",
            icon: "plane/' . $hdgInt . '.png"
        });';

    }

    echo '}

    </script>
    ';

?>

しかし、これはマップを更新していないようです。ところで、マップコード部分に表示されるテキストを取得した後に soem テキストを追加すると、唯一の問題はマップが更新されないことです。これが私がマップを呼び出す方法です。ところで、マップは機能しますが、更新されません。

<div id="map" style="width:100%; height: 400px;"></div>



  <script type="text/javascript"> 

   var map = new google.maps.Map(document.getElementById('map'), { 
     mapTypeId: google.maps.MapTypeId.TERRAIN
   });

   var markerBounds = new google.maps.LatLngBounds();

   var aircraftPos;

    <?php

    # PHPScript to create markers for flights

    mysql_connect("localhost", "virtua6_omega", "Dogsrock99");
    mysql_select_db("virtua6_flightdeck");

    $sql = mysql_query(" SELECT * FROM `flightdeck_acars` ");

    while($result = mysql_fetch_assoc($sql)) {

        echo 'aircraftPos = new google.maps.LatLng(' . $result['lat'] . ', ' . $result['lon'] . ');';

    $code = substr($result['flightnum'], 0, 3); 

    if ($result['pilotid'] > 999) {

        $pilotid = $code . $result['pilotid'];

    } elseif ($result['pilotid'] > 99) {

        $pilotid = $code . '0' . $result['pilotid'];

    } elseif ($result['pilotid'] > 9) {

        $pilotid = $code . '00' . $result['pilotid'];

    } else {

        $pilotid = $code . '000' . $result['pilotid'];

    }

    $hdgInt = $result['hdg'];           

?>

        new google.maps.Marker({
            position: aircraftPos,
            map: map,
            title: "<?php echo $result['flightnum'] . ' [' . $result['depicao'] . '-' . $result['arricao'] . ']'; ?>",
            icon: "<?php echo 'plane/' . $hdgInt . '.png'; ?>"
            // labelContent: "<?php echo $result['flightnum']; ?>",
            // labelAnchor: new google.maps.Point(22, 0),
            // labelClass: "labels", // the CSS class for the label
            // labelStyle: {opacity: 0.5}
        });

        markerBounds.extend(aircraftPos);

<?php

    }

?>

    // At the end markerBounds will be the smallest bounding box to contain
    // our 10 random points

    // Finally we can call the Map.fitBounds() method to set the map to fit
    // our markerBounds
   map.fitBounds(markerBounds)

;

4

0 に答える 0