Hallo,
Ik heb volgens script gevonden op deze site, en ik heb het bijgewerkt voor te kunnen automatiseren.
index.php
en dan uiteraard afstand.html:
Ik krijg enkel de adressen te zien ( echo's), geen afstanden van het javascript.
Kan er iemand mij helpen?
Ik heb volgens script gevonden op deze site, en ik heb het bijgewerkt voor te kunnen automatiseren.
index.php
PHP:
<?php
include('../sec/inc_mysql_connect.php');
$sql = "SELECT VVBnummer, Adres, Postcode FROM tblscheidsrechters";// echo($sql);
$result = mysql_query($sql);
$sql_sh = "SELECT ID, SporthalAdres, Postcode FROM tblsporthal"; //echo('<br>' . $sql_sh);
$result_sh = mysql_query($sql_sh);
while($record = mysql_fetch_array($result))
{
while($record_sh = mysql_fetch_array($result_sh))
{
$fromAddress = $record['Adres'] . ',' . $record['Postcode']; echo($fromAddress . '<br>');
$toaddress = $record_sh['SporthalAdres'] . ',' . $record_sh['Postcode']; echo($toaddress . '<br>');
include('afstand.html');
}
}
?>
HTML:
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=AIzaSyA_F6jvnChhojxeCahfRF1okNB9LOl11oU" type="text/javascript"></script>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
// nieuw object ZONDER parameters, want we willen nl. geen geschreven route EN geen map tonen....
// [url]http://code.google.com/apis/maps/doc...ml#GDirections[/url]
gdir = new GDirections();
GEvent.addListener(gdir,"load", set_distance);
}
}
function setDirections(fromAddress, toAddress, locale)
{
// [url]http://code.google.com/apis/maps/doc...ectionsOptions[/url]
gdir.load("from: " + fromAddress + " to: " + toAddress, {locale: locale, travelMode:G_TRAVEL_MODE_DRIVING,avoidHighways: false} );
}
function set_distance()
{
// extra: foutafhandeling, kan handig zijn!!!
handleErrors();
// document.getElementById("afstand").innerHTML = (gdir.getDistance().meters);
var adl_afstand = (gdir.getDistance().meters)/500
adl_afstand = Math.round(adl_afstand * 1,35)
aant_km = 'Het aantal km is: ' + adl_afstand + ' km'
document.getElementById("ritprijs").innerHTML = aant_km;
}
function handleErrors()
{
// [url]http://code.google.com/apis/maps/doc...GGeoStatusCode[/url]
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY || gdir.getStatus().code == G_GEO_MISSING_ADDRESS)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNAVAILABLE_ADDRESS)
alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS)
alert("The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_TOO_MANY_QUERIES)
alert("The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.\n Error code: " + gdir.getStatus().code);
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<script language="javascript">setDirections(<?php echo($fromAddress) ?>, <?php echo($toaddress) ?>, 'BE'); </script>
</body>
Kan er iemand mij helpen?
Laatst bewerkt door een moderator: