Javascript in PHP afstanden en plaatsnamen
Ik wil graag dat het script ieder geval het land achterwege laat, en het liefst Postcode, straat en plaatsnaam teruggeeft.
Wie weet hoe/waar je dat kan instellen?
<script type="text/javascript">
var geocoder, location1, location2, gDir;
function initialize() {
geocoder = new GClientGeocoder();
gDir = new GDirections();
GEvent.addListener(gDir, "load", function() {
var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
var km = Math.round(drivingDistanceKilometers + 0.5)
if (km > 0 ) {
window.location.href = "http://www.mijnwebsite?km=" + km + "&adres1=" + location1.address + "&adres2=" + location2.address;
}
document.getElementById('results').innerHTML = '<strong>Address 1: </strong>' + location1.address + '<br /><strong>Address 2: </strong>' + location2.address + '<br /><strong>Afstand: </strong>' + drivingDistanceKilometers + ' kilometers';
}); }
function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, wij hebben geen adres bij de postcode gevonden");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(document.forms[0].address2.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the second address");
}
else
{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
gDir.load('from: ' + location1.address + ' to: ' + location2.address);
}});
}});}
</script>
Er zijn nog geen reacties op dit bericht.