Android:建立多边形形状地理围栏 [英] Android: Build Polygonal Shape Geofence

查看:296
本文介绍了Android:建立多边形形状地理围栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据API文档,仅允许使用圆形地理围栏:

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

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

例如: https://developer.android.com/training/location/geofencing.html

但是我有4个位置,代表矩形的4个角,并且我希望我的Geofence是那个矩形.

But I have 4 locations, representing 4 corners of rectangle, and I want my Geofence to be that rectangle.

我想避免构建扩展自定义地理位置监视服务的解决方案来扩展监视Geofence的功能,因为我认为这种服务是CPU&耗电...

I want to avoid solution of building my custom location monitoring service extending the functionality of monitoring Geofences, because I think this kind of services are CPU & power consuming...

谢谢

推荐答案

您必须自己做(但是我认为这是毫无意义的-地理围栏/定位服务不够准确,甚至无法提醒圈子,不要甚至不考虑其他一些混凝土形状.

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:

这篇关于Android:建立多边形形状地理围栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆