问题描述
我是编程和这个社区的新手,但我们可以在 broadcastReceiver 中实现 GoogleMaps.Util.polyUtil
- containsLocation 方法吗?
我做了 2 个演示应用程序,第一个是学习 polygon(姑且称之为 appsA)。 AndroidCoding 的代码作为参考 https://www.youtube.com/watch?v=_Sx45CbBsoA
第二个是学习地理围栏(appsB)。我在这里使用你的真实代码https://www.youtube.com/watch?v=nmAtMqljH9M&list=PLdHg5T0SNpN3GBUmpGqjiKGMcBaRT2A-m&index=10
仅供参考>
问题:
我正在尝试从 appsA 实现 containsLocation... https://i.stack.imgur.com/AlWVo.png 其中 currLoc 是 LastLocation 的 LatLng,latLngList 是 polygon 的 ArrayList。
在appsB中进入broadcastReceiver... https://i.stack.imgur.com/GMQvt.png
我已经尝试寻找有关此问题的解决方案,但没有任何工作/相关.. 我正在考虑将 polygon LatLng 的 ArrayList 传递到 broadcastReceiver -> 获取当前位置坐标 -> 最后使用 containsLocation
这是代码
在 MapsActivity 上初始化变量
List<LatLng> latLngList = new ArrayList<>();
List<Marker> markerList = new ArrayList<>();
地图活动
Geofence geofence = geofenceHelper.getGeofence(GEOFENCE_ID,latLng,radius,Geofence.GEOFENCE_TRANSITION_ENTER |
Geofence.GEOFENCE_TRANSITION_DWELL);
GeofencingRequest geofencingRequest = geofenceHelper.getGeofencingRequest(geofence);
PendingIntent pendingIntent = geofenceHelper.getPendingIntent();
地理围栏助手
public PendingIntent getPendingIntent(){
if(pendingIntent!= null){
return pendingIntent;
}
Intent intent = new Intent(this,GeofencebroadcastReceiver.class);
pendingIntent = PendingIntent.getbroadcast(this,2607,intent,PendingIntent.FLAG_UPDATE_CURRENT);
return pendingIntent;
}
广播接收器
int transitionType = geofencingEvent.getGeofenceTransition();
switch(transitionType){
case Geofence.GEOFENCE_TRANSITION_ENTER:
// it should look like this
// boolean contains = polyUtil.containsLocation(currLoc,latLngList,true );
// if(contains)
Toast.makeText(context,"GEOFENCE TRANSITION ENTER",Toast.LENGTH_SHORT).show();
break;
我想问的是:
参考玛丽安在Android: Build Polygonal Shape Geofence中的回答
先谢谢了
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)