How to create a non-circular geofence area?

Asked

Viewed 56 times

3

From what I saw, the geofence creates a circular area from the measurement of the radius, in case it creates a circular area, but it is possible to create a non circular area?

For example a square or an abstract shape (polygon).

In my case I wanted to create areas the size of the neighborhoods of a given city, if they know some other way of doing it is also valid

1 answer

1

In the form of a generic polygon.

If the shape of a rectangle is sufficient use the class Latlngbounds

To use, build a Latlngbounds informing Latlng of the lower left corner (Southwest) and Latlng of the upper right corner (norhtEast)

LatLngBounds bounds = new LatLngBounds(southWest,norhtEast);

To check if a particular Latlng is inside the rectangle use:

boolean contains = bounds.contains(point); 
  • You don’t have to put the LatLgn of the centre or measurement of the radius?

  • It takes some other lib, apart from the geofence?

  • "No need to put the Latlgn of the center or the measurement of the radius?": if you want to do so see this reply, I believe this class belongs to the google maps api.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.