我把一个应用程序放在一起,当用户离开房子时发出通知.所以我实现了半径为25的区域监控.我遇到的问题是模拟时(iPhone模拟器5.0),我设置了一个自定义位置(home)设置区域边界.然后输入区域边界外的另一个自定义位置,即在街道的尽头.但该应用程序没有注册退出该地区.只有当我设置了家庭位置和地区,然后更改为Apple总部,它会注册并发出通知.在后台模式下,应用切换到重要的位置更改.但是在前台或后台时它有同样的问题.正在寻找的内容,如"提醒"应用程序,是应用程序在退出/离开区域边界后立即发出通知,即走到街道的尽头.我如何使其更准确?
这是我的一些viewcontroller.m文件:
- (void)viewDidLoad {
[super viewDidLoad];
// Create empty array to add region events to.
updateEvents = [[NSMutableArray alloc] initWithCapacity:0];
// Create location manager with filters set for battery efficiency.
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLLocationAccuracyBest; //could try KLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// Start updating location changes.
[locationManager startUpdatingLocation];
}
- (void)viewDidAppear:(BOOL)animated {
// Get all regions being monitored for this application.
NSArray *regions = [[locationManager monitoredRegions] allObjects];
// Iterate through the regions and …Run Code Online (Sandbox Code Playgroud) 在我的IOS应用程序中,我正在实现地理围栏.在当前的实现中,我使用的代码如下:
CLRegion* region3 = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:100 identifier:@"region3"];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyHundredMeters];
Run Code Online (Sandbox Code Playgroud)
然后我使用这些委托方法:
(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
NSLog(@"didenterregion");
}
(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region{
NSLog(@"didexitregion");
}
(void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{NSLog(@"monitoringDidFailForRegion");}
Run Code Online (Sandbox Code Playgroud)
但是,此代码仅适用于大于100米的半径.
以下是一些问题:
我也想到了.Apple表示可以支持多达20个地区.像这样的溶剂有什么优点/缺点(我还没有实现,但我想要你的意见).
伪代码将是这样的:
Declare the regions - save them in an array
Do not call start monitoring
Run Code Online (Sandbox Code Playgroud)
然后在委托方法中:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
for loop in all my regions {
if ([region containsCoordinate: newLocation.coordinate])
code for entering region
}
}
Run Code Online (Sandbox Code Playgroud)
我一直致力于在谷歌地图中创建地理围栏.我创建了一个用户可以放置纬度和经度的表单.现在我想在地图中显示特定的选定部分.一旦用户输入值并按"创建地理围栏",它应该在地图上显示给定的范围.在将经度和纬度值放在表单上之后,请帮我在地图上创建地理围栏.
Below is the link of JSFiddle for geofence.
http://jsfiddle.net/h0abau2q/
Run Code Online (Sandbox Code Playgroud) 我创建了一个 Xamarin 表单应用程序。应用程序应定期(每 10 秒)获取设备的位置(iOS 和 Android)。我怎样才能做到这一点?我知道有一些库,例如:Xamarin.Essentials,但我无法决定该位置应该被占用多少次。
当 Xamarin 表单应用程序在后台运行时(在 IOS 和 Android 上),也应该可以获取设备的本地信息。
我正在编写一个Android应用程序(不是一个新颖的应用程序),它将根据用户的位置关闭/打开用户的wifi.它将使用网络的位置获取大致位置.我基本上使用Google地图将他们创建的地理围栏保存到我的数据库中.我很好奇什么是最好的方法,确保应用程序不必在前台才能正常工作.
我应该使用addProximityAlert或不同的东西?考虑到我正在创建多个地理围栏并且用户可能有10个设置,我担心为每个地理围栏使用不同的邻近侦听器.相反,每15分钟左右查询位置似乎更节能,然后让应用程序决定它是否在任何这些地理围栏的合理范围内.
让我知道,感谢帮助.
iOS和gefencing有一些问题......
//
// ViewController.m
//
//
// Created by me on 14.05.13.
// Copyright (c) 2013 me. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()<CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
CLRegion *testRegion;
}
#define METERS_PER_MILE 1609.344
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initlocationManager];
// [self startlocationManager];
}
// init location Manager Object, set delegation, result and accurate
- (void)initlocationManager {
//create location manager object
locationManager = [[CLLocationManager alloc]init];
//this instance send its messages to our AppDelegate
[locationManager setDelegate:self]; …Run Code Online (Sandbox Code Playgroud) 我正在尝试 Google 的地理围栏示例项目。我正确获取进入/退出事件。但我怎样才能从中获取用户的当前位置。我想即使在进入/退出点之后也能跟踪用户位置。请帮忙。示例项目来自开发者门户。
location geolocation latitude-longitude geofencing android-geofence
我在android上使用Geofencing,当创建geo-fence时,如果用户已经在geo-fence中,设备会收到通知,这不是我正在寻找的行为,我只想通知转换ENTER和出口.
这就是我创建地理围栏请求的方式:
private GeofencingRequest createGeoFenceRequest(List<Geofence> geofenceList) {
return new GeofencingRequest.Builder()
//The INITIAL_TRIGGER_ENTER is used to notify the user initially if he/she/other
//is already inside the geo-fence zone
//.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
.addGeofences(geofenceList)
.build();
}
Run Code Online (Sandbox Code Playgroud)
在我的GeofenceTransitionService.java中:
@Override
protected void onHandleIntent(@Nullable Intent intent) {
if (intent != null) {
geofencingEvent = GeofencingEvent.fromIntent(intent);
// Retrieve the transition type.
geoFenceTransition = geofencingEvent.getGeofenceTransition();
}
}
Run Code Online (Sandbox Code Playgroud)
过渡类型以Geofence.GEOFENCE_TRANSITION_ENTER的形式返回,即使我没有进入,我已经在地理围栏中了.任何人都知道如何阻止这个初始触发器?
是否可以使用iOS 5 API检查给定的经度和纬度是否属于给定的GeoFence?怎么样?
我想计算后端的地理围栏破坏和行驶距离计算.这是我第一次使用谷歌API.我在网上找到的只是Android版.是否有任何特定于常规计算的API.
我的iOS 9应用程序需要地理围栏功能.哪些API提供商提供地理围栏功能?我检查了Foursquare,他们似乎没有提供这个. Geoloqi刚刚被收购,这个选择似乎也是不可能的.
如果没有第三方选项可用,那么如何为iOS实现地理围栏呢?
geofencing ×11
ios ×5
geolocation ×4
location ×3
android ×2
clregion ×2
google-maps ×1
ios9 ×1
java ×1
javascript ×1
mkmapview ×1
objective-c ×1