Android: Build Polygonal Shape Geofence

喜欢而已 提交于 2019-11-28 00:11:50

You have to do it by yourself (however I think it's rather senseless - geofences/location services are inaccurate enough to not even be able to alert about circles, don't even think about some other concrete shape).

Create smallest circular geofence which contains your polygon and if triggered just check if you are in the polygon inside with Google Maps Android API utility library.

In other words check if you are in white area not in grey:

The Android Geofencing API only provides support for Circular Geofences. If you want to monitor Polygon shaped geofences then you have to implement it your self.

One solution would be something like this:

Get the current location update using Location API.

Now you have polygon shaped geofence. You can use ray-casting Algorithm to check if a point is inside the Closed Polygon or not?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!