Android: Build Polygonal Shape Geofence

后端 未结 2 839
暗喜
暗喜 2020-12-03 16:04

According to the API documentation, only Circular shape Geofences allowed:

https://developers.google.com/android/reference/com/google/android/gms/location/Geofence.B

2条回答
  •  执笔经年
    2020-12-03 16:24

    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?

提交回复
热议问题