0
다음 코드는 Google지도에서 아이콘을 생성하는 'genxml.php'에 저장되어 있습니다. 파일은 다른 파일 'mobileInterface.php'에서 호출됩니다. 데이터베이스에 다른 마커 위치를 추가하면 컴퓨터 브라우저에서 모든 것이 제대로 작동합니다. 문제는 모바일 브라우저에서로드 할 때 마커가 즉시 업데이트하지 않고 브라우저를 종료하고 다시로드해야합니다. . 그렇지 않으면 URL에서 'genxml.php'를 직접로드해야합니다. 일종의 컨텐츠를 다운로드 한 다음 'mobileInterface.php'를 다시로드해야합니다.Google지도 xml 아이콘
페이지 내용을 캐싱하지 않았지만 여전히이 문제가 있습니다. 어떤 아이디어라도 제발?
는 //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);
}
10ks에 설명 된대로 서버에서 데이터 요청에 타임 스탬프를 추가 이제 괜찮아 보인다 – bmw318mt