My friend and I, who don’t have much experience in Java Script and HTML, created a website that uses the Google API to calculate the carbon emissions released by driving a car a certain distance. This was for a weekend event that has already ended, and now I just want to get the website complete.
We were able to get a Google map up and working so the user can click on two places on the map and have the map gives you the shortest drivable distance. This is stored in a variable called “distance” and the code can be found in mpaStuff.js. The user can also type in the miles per gallon of their vehicle, which is stored in a variable called GasMileageInput, who’s input is taken in from the html file and used in mapStuff.js.
In mapStuff.js is a function called getEmissions(distance, gasMileage) that divides distance by mileage, multiplies by a constant, then returns the value (emissions).
Our problem is that we can’t seem to get “emissions” to transfer to our .html file and show on the screen, in part to our lack of knowledge in the languages. It either shows a blank value or a NaN value. We believe that it’s simply a variable-across-files issue, but we’re not sure. Any help would be greatly helpful, and please let me know if I need to add more clarification to this post.
Link to our Git Repo:
I took out some of the html file that contained our Google API Key, just in case.
Thank you very much!
Josh