简体   繁体   English

谷歌地图XML标记

[英]google maps xml markers

I have the following code stored in a 'genxml.php' that generates markers on google maps. 我将以下代码存储在“ genxml.php”中,该代码会在Google地图上生成标记。 The file is called from another file 'mobileInterface.php'. 从另一个文件“ mobileInterface.php”调用该文件。 If I add another marker location in the database everything is working fine on a computer browser, the only problem that I have is when loading from a mobile browser, markers do no update instantly, I have to exit the browser and load it again to update. 如果我在数据库中添加另一个标记位置,则在计算机浏览器上一切正常,唯一的问题是从移动浏览器加载时,标记不会立即更新,我必须退出浏览器并再次加载以进行更新。 Else I have to load the 'genxml.php' directly from the URL, sort of downloading the contents and then load 'mobileInterface.php' again. 否则,我必须直接从URL加载“ genxml.php”,然后下载内容,然后再次加载“ mobileInterface.php”。

I have tried not caching the page contents but still I have this problem. 我尝试过不缓存页面内容,但仍然有此问题。 Any ideas please? 有什么想法吗?

//genxml.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 //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); 

            }

如此答案中所述,将时间戳添加到来自服务器的数据请求中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM