- Build Location-Aware App with Backendless & Adalo - Part 1
- Build Location-Aware App with Backendless & Adalo - Part 2
We talk about building the API with Backendless in part 1; today, let's continue to see how we integrate the API with Adalo.
1.First, we need to modify the user database added two fields for Latitude and Longitude. The reason for doing this is that only the user's attribute can be inserted into the question when querying external collection.
2. Let's set up the external database collection; for Backendless connection, you need application-id and api-key, set up both as Header.
3. Complete the external Backendless collection first and test it, make sure there is data return before continue editing the connection
4. Once the connection is successful, we can add a parameter using Query Param fields. Let's add Props first; props set up the database fields you need to return. Take note that you need to provide a sample of longitude & latitude that works for your query to succeed. Both longitude & latitude should be inserted with the magic text and choosing from the attribute you created for the user table in the first step.
props=name,distanceOnSphere('POINT(<longitude>,<latitude>)', location) as distanceToPoint
5. Added the last Query Param field for sortBy = distanceToPoint so that the location list will be sort based on the calculated distance.
6. You can place the Location list on your preview screen, but it might not work? Remember the query just now taking the Latitude & Longitude from users? You need to log in to the user account first then it will work; if you set your Location screen as the first screen, you won't be able to see the list appear.
7. Put up any location component that will update the user's lat and lot field; once it updates, the list of locations will reflect the changes.
You can find out more about how to query location data through API for Backendelss.
You can also check checkout the demo of Location-Aware app I build.