In this video, Matt Peterson, a trainer at Pragmatic Works, demonstrates how to calculate mileage within a Power Apps canvas application using the Bing Maps connector. This practical use case originated from a real-world hackathon scenario, where IT technicians needed to log mileage between locations for reimbursement purposes.
Matt Peterson introduces a business scenario where IT technicians travel between schools and need to track their mileage efficiently. Instead of manually calculating distances, he shows how Power Apps can automate this process using the Bing Maps connector.
This approach allows users to:
The first step in this process is integrating the Bing Maps connector into Power Apps. Matt explains that this is a free connector, but it requires setting up an API key.
To configure the connector:
Once connected, developers can access various mapping functionalities, including route calculations.
To demonstrate the functionality, Matt creates a simple interface using:
He renames the input fields for clarity:
He also removes default values and adds hint text to guide users when entering addresses.
The core functionality lies in using the Bing Maps GetRoute function. Matt demonstrates how to construct the formula to calculate driving distance between two locations.
Key steps include:
The function returns a record, so Matt highlights an important tip: use a period (.) after the function to explore available properties. In this case, the travelDistance property is used to extract the mileage value.
This calculated value is then displayed in the label for users to see in real time.
Matt tests the application by entering sample addresses, such as the White House and a business location in Florida. The app successfully calculates and displays the mileage between the two points.
He notes that while Bing Maps provides accurate estimates, results may vary slightly depending on routing logic.
To enhance usability, Matt adds conditional logic to handle missing inputs. This ensures that users receive feedback when required fields are not completed.
He uses an If statement combined with IsBlank to check whether either input field is empty.
If either field is blank, the app displays a message:
Otherwise, it proceeds with the mileage calculation.
This demonstration highlights how Power Apps can integrate external services like Bing Maps to automate real-world business processes. Key benefits include:
Matt Peterson emphasizes that this is just one example of what the Bing Maps connector can achieve. Developers can expand on this by integrating dropdowns, forms, or databases to create more robust solutions.
By leveraging Power Platform capabilities, organizations can streamline workflows and reduce manual effort in everyday operations.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Apps and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.