Inspiration

When most people go on road trips, they usually pull over at the closest gas stations they find on their route. Oftentimes, these stations are extremely cost inefficient, forcing you to pay unreasonable amounts of money for gas. We wanted to create an application that maximizes the efficiency of your trips, whether that be in cost, time, or distance.

What it does

Based on the user’s chosen starting location and final destination, Petrol Pal then searches for all of the nearby gas stations using numerous Google Maps APIs. Our algorithm is able to find the best gas stations to stop by for the cheapest gas, the fastest route to the user’s destination, and for the shortest distance. This allows the user to choose their preferred gas station along their route.

How we built it

We mainly used JavaScript and HTML (+ CSS) to build our application. An essential interface we used was the Google Maps API. Specifically, we used Google Places API to find gas stations near the user’s location, Google Directions API for the directions to chosen gas stations, and Google Distance Matrix API to calculate the distance and time it takes to travel to nearby gas stations.

Challenges we ran into

It was hard to handle all of the data from the different APIs. The different APIs returned data in different formats, so we had to make sure that we used a common format for all of the data. There were many asynchronous API calls, which meant we had to properly deal with the calls in the proper order.

It was also hard to design a user interface that could accommodate both mobile view and desktop view, as well as fit all of the controls for the app.

Accomplishments that we're proud of

This project marks the first time that all four of us have worked with Google Maps API, and it even is the first time working with JavaScript for some of our team members. We successfully built a ready-for-production app within 36 hours, and we learned so much along the way.

What we learned

As mentioned, we learned a lot about using Google Maps API, and how to implement APIs in general with JavaScript and HTML. Furthermore, we all developed stronger collaboration skills and problem solving skills.

What's next for Petrol Pal

When searching and sorting for all nearby gas stations, we can take the gas stations’ google ratings into consideration. Additionally, we can extend the features of Petrol Pal so that we can also find charging stations for electric cars. Finally, the Google Maps API does not have the ability to provide real-time gas prices at gas stations (as they are also receiving this information from a third-party API). As a result, applying real life data would make our application accurate and fully functional.

Share this project:

Updates