How to calculate the distance between two locations in (One location will be dynamic)

How to calculate the distance between two locations in (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 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:

  1. 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

  1. 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.

  2. 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.

  1. Develop a landing page that is populated based on the selections of the premise in which the advertisement is going to be displayed.

  2. Create a hidden popup on the landing page that stores the location of the selected premise for each user.

  3. 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.