Hi! I’m a transport logistic company and my clients are looking for carbon emission report. Is there any way whereby Bubbleio can create such report? I’m thinking of by anyway integrating Google Maps into Bubble.io, from there I input the locations and from the distance travelled multiply by the estimated Carbon output by the type of vehicle I allocate for the job. Not sure if I’m at the right direction.
simplest way would be to calc the miles then multiply by a CO2 produced
you could get more involved than that (truck age, type, avg speed, weight etc) but I doubt your client wants to get into the weeds with it so a simple A x B should suffice
You can use Routes API from Google to get distances between points.
@ademiguel thank you for this information! Do you happen to know how much roughly the API charges? How to better be cost efficient when using such api?
@mitchbaylis thanks for sharing! Yeah these additional information would be very helpful!
As per my knowledge, the specific API would be “Compute Route Matrix” under Routes API tab. The pricing is free up to 10k requests per month, however the onwards the price becomes too steep. You can check more details here:
Thank you brother! Any chance whereby you know if Bubble.io can do any Google Map integration to find the fastest route from destination to destination?
You can always use Gemini Flash 2.0 to find answers as it will be able to answer the best due to being a product of Google itself. For now here is what it says:
The primary Google Maps Platform API that helps you find the fastest route between destinations is the Routes API .
Here’s why and what you need to know:
Routes API:
- Calculates Optimal Routes: The core function of the Routes API is to calculate the best route between one or more origins and destinations, considering factors like distance, estimated travel time, and real-time traffic conditions to find the fastest option.
- Multiple Travel Modes: It supports various transportation modes, including driving, walking, bicycling, and public transit. For driving, it specifically takes into account current and predicted traffic to suggest the quickest path.
- Waypoints: You can specify intermediate points (waypoints) along the route, and the API will calculate the optimal sequence to visit them.
- Route Modifiers: You can influence the route calculation by specifying preferences such as avoiding tolls, highways, or ferries.
- Real-time Traffic: When requesting driving directions with a departure time specified as “now” or a future time, the API considers real-time traffic conditions to provide the fastest route at that moment.
- Toll Information: The API can provide estimated toll costs along the route (depending on the data availability for the region).
- Polylines: It returns a polyline representing the calculated route that you can display on a map.
Why Not the Distance Matrix API for Fastest Route?
While the Distance Matrix API calculates travel times, it primarily focuses on providing the distance and duration between multiple origins and destinations. It doesn’t inherently calculate a specific route or optimize for the fastest path considering intermediate points or route preferences in the same way the Routes API does. It gives you point-to-point estimates, not a sequenced fastest route through multiple stops.
How to Use the Routes API for Finding the Fastest Route:
- Enable the API: Ensure the Routes API is enabled in your Google Cloud project.
- Authentication: You’ll need a valid API key or use authenticated sessions.
- Make a Request: Construct an HTTP request to the Routes API’s
computeRoutes
endpoint. This request will include:
origin
: The starting point (address or coordinates).destination
: The ending point (address or coordinates).travelMode
: Set this to"DRIVE"
for finding the fastest driving route considering traffic. Other modes like"TRANSIT"
will find the fastest public transport route based on schedules.routingPreference
: Set this to"TRAFFIC_AWARE_OPTIMAL"
to request the fastest route considering real-time traffic. You can also use"TRAFFIC_UNAWARE"
for a route based purely on distance and road network without real-time traffic.- Optional:
waypoints
for intermediate stops,avoidTolls
,avoidHighways
,departureTime
to specify when the journey begins for traffic-aware routing.
- Process the Response: The API will return a JSON response containing details about the route, including the polyline, distance, duration, and potentially toll information. You’ll need to parse this response to display the route and relevant information to the user.
Example Request (JSON):
JSON{ "origin": { "address": "Liberty Chowk, Lahore, Pakistan" }, "destination": { "address": "Clock Tower, Faisalabad, Pakistan" }, "travelMode": "DRIVE", "routingPreference": "TRAFFIC_AWARE_OPTIMAL", "departureTime": { "time": "2025-04-19T19:45:00+05:00" }, "computeTravelTime": true }
This request asks for the fastest driving route from Liberty Chowk, Lahore, to Clock Tower, Faisalabad, considering the traffic conditions at the specified departure time (April 19, 2025, 7:45 PM PKT).
By using the Routes API with the appropriate parameters, you can effectively find the fastest route between destinations based on various factors, including real-time traffic.
Much to digest. Thank you brother @deejay.shani !