In other posts, we have described how to set up a sample Geolocation data set and how to retrieve geopoints using the API. The geopoints in your application would not be the ones from the sample data set, we used it only to make it easier to get started with Backendless Geolocation. Adding geopoints to your Backendless backend can be done either with the API or by using data import. In this post, we will review the first approach – saving geopoints with API.
From our introduction to geolocation, you might know that a geopoint consists of the following:
The sample code below saves two geopoints in your Backendless backend. One point which represents Dallas, TX on the map is added using the synchronous API. The other one represents Houston, TX and is added with the asynchronous API call. Notice that both geopoints are added to the “cities” category, which will be created dynamically on the server if it does not exist. There is also some metadata such as the city name, population size and a URL of an image of the city skyline:
After you run the code above, you can verify that the geopoints are added to the backend using Backendless Console:
Enjoy!