ParseGeoPoint features with users Example
Parse allows you to associate real-world latitude and longitude coordinates with an object. Adding a ParseGeoPoint to a ParseUser allows your app to estimate the proximity of an user to a reference point. That way, you will be able to easily find out the location of a user, which user is closest to another, show the locations of the users of your app, among other possibilities.
This tutorial explains how to use some of ParseGeoPoint features with users through Back4App.
This is how the example of this tutorial will look like:
At any time, you can access the complete Android Project built with this tutorial at our GitHub repository.
To complete this tutorial, you need:
Step 1 - Set up a Google API Key
To display the location you will save using ParseGeoPoint, you will need to display a Map. To do that, it’s interesting to use a Google Maps Activity.
In order to create a Google Maps Activity in Android Studio, do the following:
- Go to
Google Maps Activity. Then, automatically, it will create a
layoutfile and a
valuesfile corresponding to the Google Maps Activity that you have created.
- Go to the created
valuesfile (you can do this by accessing
google_maps_api.xml), as shown in the image below. This file will give you some instructions on how to get a Google Maps API Key. Basically, you should open the link shown in the image.
- After opening it, you should login in your Google Account and click on
Create a project. While creating the project, Google will enable your API.
- After your API is enabled, you will be able to get an API key, to do so click on
Create API key.
- Then, your key will be created and you can copy it and paste it in the
valuesfile that lead you to this page, in the place where its written
YOUR KEY HERE.
- It’s important to have the following
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
If you created the
Google Maps Activityfollowing the instructions above, then it should already be in your manifest, anyway, it’s good to check if this is right, otherwise your app may not collect the user location.