Fjern decimaler efter komma i javascript i ruteberegner fra google map.
Hejsa.Jeg har et seriøst problem med et ruteberegner script hvor google map indgår i. Jeg har decimaler efter komma i både km og prisen der beregnes. Jeg ønsker ikke decimaler efter kommaet. Har fundet flere eksempler, men forstår ikke og mikse det ind i dette regne eksempel. Håber der er en ekspert der kan hjælpe mig.
I kan se min ruteberegner i funktion her:
http://www.findtaxa.dk/taxa-priser/
På forhånd mange tak.
Mvh
Martin.
KODE:
---------------------
<script src="http://maps.google.com/maps?file=api&v=2&key=MIN-EGEN-KODE" type="text/javascript"></script>
<!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: http://code.google.com/apis/maps/terms.html -->
<script type="text/javascript">
var geocoder, location1, location2, gDir;
function initialize() {
geocoder = new GClientGeocoder();
gDir = new GDirections();
GEvent.addListener(gDir, "load", function() {
var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
var drivingTakst1 = gDir.getDistance().meters / 1000 * 13.30 + 37;
var drivingTakst3 = gDir.getDistance().meters / 1000 * 16.80 + 50;
document.getElementById('results').innerHTML = '<strong>Fra Adresse: </strong>' + location1.address + ' <br /><strong>Til Adresse: </strong>' + location2.address + ' <br /><strong>Kørsles afstand: </strong>' + drivingDistanceKilometers + ' Km <br /><strong>Kørsles Takst 1: </strong>' + drivingTakst1 + ' Kr <br /><strong>Kørsles Takst 3: </strong>' + drivingTakst3 + ' Kr';
});
}
function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first address");
}
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>
<body onload="initialize()">
<form action="#" onsubmit="showLocation(); return false;">
<br>
<p>
<input type="text" name="address1" value="Fra Adresse" class="address_input" size="40" />
<input type="text" name="address2" value="Til Adresse" class="address_input" size="40" />
<input type="submit" name="find" value="Søg" />
</p>
</form>
<p id="results"></p>
</body>