Jesse Quote

geocoder.geocode({ address: address }, (results, status) => { if (status !== 'OK') { resultDiv.innerHTML = 'An error occurred while geocoding the address.'; return; } const [latitude, longitude] = [results[0].geometry.location.lat(), results[0].geometry.location.lng()]; const origin = `${latitude},${longitude}`; const destination = '492 creek road, genoa, NY 13071 USA'; // Use the distance matrix service to calculate the distance and duration of the trip distanceMatrixService.getDistanceMatrix({ origins: [origin], destinations: [destination], travelMode: google.maps.TravelMode.DRIVING }, (response, status) => { if (status !== 'OK') { resultDiv.innerHTML = 'An error occurred while calculating the distance.'; return; } const distanceInMiles = response.rows[0].elements[0].distance.value / 1609.34; // Convert meters to miles // Calculate the cost const costPerMile = 1.30; const costPerHorse = 35;const quantity = parseInt(quantityInput.value); const totalCostForMiles = distanceInMiles * costPerMile; const totalCostForHorses = quantity * costPerHorse; let totalHoofTrimmingQuote = totalCostForMiles + totalCostForHorses; totalHoofTrimmingQuote = Math.ceil(totalHoofTrimmingQuote/5) * 5; // round up to nearest 5 // Display the result resultDiv.innerHTML = `The total hoof trimming quote is $${totalHoofTrimmingQuote.toFixed(2)}.`; }); }); }

Comments

Popular posts from this blog