Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Found the problem, it seemes that two parts of the code are in conflict if in the same scope (e.g. same routine).</p> <p>When I moved the api into its own routine, everything started working. The code in conflict/causing the error is:</p> <pre><code>xmlhttp.open(\"GET\",getClubURL,false); xmlhttp.send(); textToParse = xmlhttp.responseText; function calculateDistances(start,end) { //alert('Made it to calculateDistances'); var service = new google.maps.DistanceMatrixService(); alert('In calculateDistances, start is '+start+', end is '+end); service.getDistanceMatrix( { origins: [start], destinations: [end], travelMode: google.maps.TravelMode.DRIVING, unitSystem: google.maps.UnitSystem.IMPERIAL, avoidHighways: false, avoidTolls: false }, callback); } function callback(response, status) { if (status != google.maps.DistanceMatrixStatus.OK) { alert('Error was: ' + status); } else { var origins = response.originAddresses; var destinations = response.destinationAddresses; document.getElementById("mileage[mileageidx]").value = response.destinationAddresses; for (var i = 0; i &lt; origins.length; i++) { var results = response.rows[i].elements; for (var j = 0; j &lt; results.length; j++) { var tmpTxt = new String(results[j].distance.text); eos = tmpTxt.indexOf(' '); alert('eos = '+eos); tmpTxt = tmpTxt.substr(0,eos); alert('tmpTxt is '+tmpTxt); var miles = new Number(tmpTxt); miles = Math.round(miles); document.getElementById(\"mileage[\"+mileageidx+\"]\").value=miles; } } } } // End of callback routine </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload