Subscribe rss
Blog categories
All | Backendless features
Feature 57: Searching for geopoints in a rectangular area
March 5, 2015 by markpiller

In my post from yesterday I demonstrated sample code which shows how to search for Backendless geopoints in a radius. While on the same subject I also wanted to review the API for searching for geopoints in a rectangular area. The API is very similar to the one for search in radius, except the app must define the “view port” or the rectangular area on the map where the search must occur. Consider the example below:

 Asynchronous sample (Android and Plain Java):

Synchronous sample (Plain Java only):

Asynchronous sample:

Synchronous sample:

Asynchronous sample:

Synchronous sample:

Notice the code above sets the search rectangle as two pairs of coordinates. The first two numbers in the setSearchRectangle method are the latitude and longitude coordinates of the North-West corner of the search rectangle. The other two numbers are the coordinates of the South-East corner.

Backendless console makes it easy to identify the coordinates of the search rectangle and also provides a way to run rectangle-based search for diagnostics purposes. To run a rectangle-based search in console:

  1. Login to Backendless console, select your app and click the Geolocation icon.
  2. Select the geo category for which you would like to perform the search.
  3. Click the Map-driven navigation toggle located under the map.
  4. As you pan and zoom the map, the console runs rectangle-based geo point searches and displays the returned geo points on the map. Also, the map displays the coordinates of the North-West and South-East corners to make it easier for developers to replicate the same behavior in an API call.



Share this post
Tweet about this on TwitterShare on FacebookGoogle+