简体   繁体   中英

Too Much Recursion

I'm having problems in trying to run an HTML Google Map form. Everytime I try and run it I get the following message 'Stack overflow at line: 26', then when I click ok I get 'Stack overflow at line: 28'. This isn't the most helpful of error messages so I've run it thorugh Firebug and it tells me that there is 'Too much recursive' in main.js. Again I haven't a clue what this means

I've listed my PHP script and HTML form below.

PHP Code

<?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 Form

<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>

All, I've solved the problem. When I was looking at Firebug the error, it kept mentioning the 'gstatic' files which I know are to do with the Lat and Lng co-ordinates.

It got me thinking to what I had done recently and I realised that for testing purposes I had just keyed in one set of the Lat and Lng co-ordinates which were obviously wrong. Apologies to all for the time and effort you put in to help. Kind regards Chris

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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