我在尝试运行HTML Google地图表单时遇到问题。每次我尝试运行它时,我得到以下消息'Stack overflow at line:26',然后当我点击ok时,我得到'Stack overflow at line:28'。这不是最有用的错误消息,所以我运行它来看看Firebug它告诉我main.js中有“Too much recursive”。我再也不知道这意味着什么
我在下面列出了我的PHP脚本和HTML表单。
PHP代码
<?php
require("phpfile.php");
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a MySQL server
$connection=mysql_connect ("hostname", $username, $password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$query = "SELECT finds.userid,
finds.findid,
finds.locationid,
finds.findosgb36lat,
finds.findosgb36lon,
finds.detectorid,
detectors.detectorid,
detectors.detectorname,
finds.searchheadid,
searchheads.searchheadid,
searchheads.searchheadname,
FROM finds, detectors, searchheads
WHERE finds.detectorid=detectors.detectorid AND
finds.searchheadid=searchheads.searchheadid AND `locationid` = '52' 'userid'='1'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("userid",$row['userid']);
$newnode->setAttribute("findid",$row['findid']);
$newnode->setAttribute("locationid",$row['locationid']);
$newnode->setAttribute("detectorname",$row['detectorname']);
$newnode->setAttribute("searchheadname",$row['searchheadname']);
}
echo $dom->saveXML();
?>
HTML表单
<script type="text/javascript">
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(54.312195845815246,-4.45948481875007),
zoom:14,
mapTypeId: 'satellite'
});
var infoWindow = new google.maps.InfoWindow;
downloadUrl("loadfindsperlocation.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var locationid = markers[i].getAttribute("locationid");
var detectorname = markers[i].getAttribute("detectorname");
var searchheadname = markers[i].getAttribute("searchheadname");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("findosgb36lat")),
parseFloat(markers[i].getAttribute("findosgb36lon")));
var marker = new google.maps.Marker({
map: map,
position: point,
formdetectorname: detectorname,
formsearchheadname: searchheadname,
});
bounds.extend(point);
map.fitBounds(bounds);
bindInfoWindow(marker, map, infoWindow, html);
google.maps.event.addListener(marker, "click", function() {
document.getElementById('detectorname').value = this.formdetectorname;
document.getElementById('searchheadname').value = this.formsearchheadname;
});
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
</script>
</head>
<form name="findsperlocation" id="findsperlocation">
FORM FIELDS APPEAR HERE
</form>
<body onLoad="load()">
<div id="map"></div>
</body>
</html>
答案 0 :(得分:0)
所有,我已经解决了这个问题。当我看着Firebug的错误时,它不断提到'gstatic'文件,我知道这些文件与Lat和Lng坐标有关。
它让我思考我最近所做的事情,并且我意识到,出于测试目的,我只是键入了一组显然是错误的Lat和Lng坐标。向所有人致歉,您需要投入时间和精力来提供帮助。亲切的问候克里斯