How to calculate the distance between two locations in Bubble.io? (One location will be dynamic)
As an advertising agency, you have a unique opportunity to display ads on premises such as restaurants and pubs. By using QR codes, users can easily scan them and find businesses advertised. To make this feature effective, we can use Bubble.io to create a geographical location database and calculate the distance between the user's premise location and the advertised businesses. Here's how you can do it:
- Set up the Google Geo Location API key in the Bubble application by going to Setting -> General -> General Services API Keys and adding the Google Geocode API and Google Map API keys.
Here is the process of generating these keys: Youtube Link
Create a database with the "place" data type that includes fields such as name, longitude, latitude, location, category, and visibility status. You can also add other fields such as business description and category. Additionally, create a separate data type called "Premise-Advertise" that includes the premises and a list of advertisements visible on the premise.
Create an admin form where admins can add advertisements by entering the longitude and latitude of the business. Use the calculation formula to automatically generate a geolocation for each business.
Develop a landing page that is populated based on the selections of the premise in which the advertisement is going to be displayed.
Create a hidden popup on the landing page that stores the location of the selected premise for each user.
Use a repeating group of advertisements sourced from Premise-Advertise where the premise is equal to the current premises selected by the user. Add a text field to display the distance between each advertising business and the selected premise. Insert the calculation dynamically using Current Cell's Place's location distance from Current Page Premise's Value's Location.
By following these steps, every user can easily see how far each advertised business is from their current premise location. You can also add other features such as showing a Google Map link to the business or an inquiry form for the business, making it even more convenient and user-friendly.
Help me!
If you enjoyed this post and found it helpful, Kindly consider supporting my work by buying me a coffee! Your support helps me create more valuable content and continue sharing useful resources. Thank you!