0

我将以下代码存储在“genxml.php”中,该代码在谷歌地图上生成标记。该文件是从另一个文件“mobileInterface.php”调用的。如果我在数据库中添加另一个标记位置,在计算机浏览器上一切正常,我唯一的问题是从移动浏览器加载时,标记不会立即更新,我必须退出浏览器并再次加载以更新. 否则我必须直接从 URL 加载“genxml.php”,下载内容然后再次加载“mobileInterface.php”。

我试过不缓存页面内容,但我仍然有这个问题。请问有什么想法吗?

//genxml.php

$query = "SELECT * ,DATE_FORMAT( ts,  '%d-%m-%Y  :  %H.%i.%s' ) as tz FROM dataentry WHERE caseStatus = 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");


// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
      // ADD TO XML DOCUMENT NODE
    echo '<marker ';
    echo 'id="' . parseToXML($row['id']) . '" ';
    echo 'riskCategory="' . parseToXML($row['riskCategory']) . '" ';
    echo 'EventAccidentSubject="' . parseToXML($row['EventAccidentSubject']) . '" ';
    echo 'description="' . parseToXML($row['description']) . '" ';
    echo 'peopleInvolved="' . parseToXML($row['peopleInvolved']) . '" ';
    echo 'hazards="' . parseToXML($row['hazards']) . '" ';
    echo 'address="' . parseToXML($row['address']) . '" ';
    echo 'lat="' . $row['lat'] . '" ';
    echo 'lng="' . $row['lng'] . '" ';  
    echo 'caseStatus="' . parseToXML($row['caseStatus']) . '" ';
    echo 'ts="' . $row['tz'] . '" ';   
    echo '/>';
}

// End XML file
echo '</markers>';

?>

//mobileInterface.php

var mobileInterfaceServer = "http://10.0.0.21/genxml.php";          
downloadUrl(mobileInterfaceServer, function(markers) {//replace markers with data
            var xml = markers.responseXML;//replace markers with data
            var markers = xml.documentElement.getElementsByTagName("marker");
            selectBox = document.getElementById('destination');
            for (var i = 0; i < markers.length; i++) {
                var riskCategory = markers[i].getAttribute("riskCategory");
                var EventAccidentSubject = markers[i].getAttribute("EventAccidentSubject");          
                var address = markers[i].getAttribute("address");
                var point = new google.maps.LatLng(
                parseFloat(markers[i].getAttribute("lat")),
                parseFloat(markers[i].getAttribute("lng")));                    

                html = "<b>" + EventAccidentSubject + "</b> <br/>" + address;

                displayLocation(markers[i]);
                //displayLocation(point);
                addOption(selectBox, markers[i].getAttribute("EventAccidentSubject"), point);

                bindInfoWindow(marker, map, infoWindow, html); 

            }
4

1 回答 1

0

本答案中所述,为来自服务器的数据请求添加时间戳

于 2013-05-18T22:40:28.870 回答