How to specify the entire country as a region in region identifier.Wether it will accept the
identifier as :#"Uk"
here the code to reo identifier.How can i specify England or UK.Please help me to sort out
CLLocationCoordinate2D location2D = mapView.region.center;
CLRegion *regionForMonitoring = [[CLRegion alloc] initCircularRegionWithCenter:location2D radius:1 identifier:#"RegionIdentifier"];
[[Utils getLocationManager] startMonitoringForRegion:regionForMonitoring];
CLRegions are totally unsuitable for this purpose.
First of all, the radius specified is the distance in meters that the region covers - so in your case you are asking the system to monitor a region at a specific lat/long with a radius of 1 meter!
Also, system regions have a maximum number of regions that can be monitored (around 10 or so), and a maximum radius that can be used of around 400 meters after which the region will not work.
You really need to read the "Monitoring Shape Based Regions" section of this Apple document:
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html
There are two other possible approaches to what you are trying to do:
1) Use Significant Location Updates, and test on each update if you are in an area with a shape you specify.
2) Use CoreTelephony to look up the cell carrier your device is on and see if the carrier number matches one in the country of interest. Of course, this will not work on some iPads or other iOS devices with no cell connection.
Neither of those approaches will be exact around the edges, but will also not consume nearly as much battery life as using the GPS.
Related
I am working on Geo fence with Google map. My question is about the minimum radius for CLCircularRegion. As I want to work with the region for 30 meters. But the functionality works for the 100 meters. I have searched a lot and found that Apple needs minimum radius 100 to create a region, no matter I have set 30 meters or 50 meters.
Here is the link -
Geofencing iOS 6
Moreover, didEnterRegion call at 100 meters and didExitRegion works very oddly and took much time.
I have also read, that it depends upon tower cells etc according to that these methods call.
Here is the link -
What is the maximum and minimum radius that can be set for regions in iOS geofencing.
I want to know if I have set the region for 50 meters. Why it is not working as per required region radius. In fact, I observe that it is working for the radius 100 meters.
Here is the code:
func createRegion(lat : CLLocationDegrees,lng : CLLocationDegrees) -> CLCircularRegion?
{
let latitude = lat
let longitude = lng
var radius = CLLocationDistance(50)
if radius > locationManager.maximumRegionMonitoringDistance
{
radius = locationManager.maximumRegionMonitoringDistance
}
let region = CLCircularRegion(center: CLLocationCoordinate2DMake(latitude, longitude), radius: radius, identifier: "TEST")
region.notifyOnEntry = true
region.notifyOnExit = true
return region
}
Or also can anyone refer a good app that has Geo fence functionality. So that I can compare my app's accuracy with it.
Question: I have selected 50 meters radius and 'upon exit' notification should come. But I am getting a notification on/around 250 meters and some time more than this. Please help me out
Thanks!
Take a look at Apple`s developer documentation:
Article Apple
Official Documentation
When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.
The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.
And remind that if the Wi-Fi is disabled, then it will be less accurate.
I think you can reverse engineer the minimum radius on your device by looking at the device logs in Console. For example, if I set a radius of less than 100m on my iPhone 8 with iOS 14.7, I get the following log statement:
Fence:Start Started monitoring fence myapp/<private> (<<private>,<private>>, radius 100.000, active tech <private>)...
So, 100m seems to be the minimum in my case.
i am developing an app which is particularly dependent upon the distance between two iOS devices. I am using GPS location of devices to calculate the distance between them.
To calculate distance, i am using cllocation -distanceFromLocation method but the values generated by method is fluctuating and differs from actual distance between devices and cannot be considered even as an approximate result.
For example, if the actual distance between devices is 2 to 3 meters, it gives me the result around 14 meters at some point and 43 meters at another point. Is the the function -distanceFromLocation: is not so precise and accurate????
Is there any better alternative for calculating distance using GPS latitude and longitude of devices???
Please help me out.
Thanx in advance.
The accuracy of CoreLocation GPS varies greatly depending on your surroundings.
At it's most accurate it can go down to a couple of metres resolution (I'm not sure exactly) but if you're indoors it will be more like 20-50 metres.
I'm guessing that you're developing and testing the app indoors and so the fluctuations would be about normal.
Even outdoors in perfect weather CoreLocation will struggle to accurately tell you the distance between two devices over a short distance. (i.e. a couple metres).
For short range you might be better using wifi signal strength instead. Although this can also change from room to room.
Essentially, it's difficult to accurately detect the distance between two devices.
I've encountered problem with startMonitoringForRegion method in iOS 5. Documentation says that method is taking parameter "accuracy":
- (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
I'm currently developing an app that should notify user when he's in 25 meters radius from monitored point. App uses GPS with kCLLocationAccuracyBestForNavigation setting. I'm creating (CLRegion *)region like this:
CLRegion *pointRegion = [[CLRegion alloc] initCircularRegionWithCenter:pointLocation radius:25.0 identifier:identifier];
and setting accuracy parameter in startMonitoringForRegion for kCLLocationAccuracyBestForNavigation.
Region monitoring works well in my app, however didEnterRegion method fires when user is around 100 meters from monitored region, not 25 meters.
Is there minimum value of radius in startMonitoringForRegion that is not described in Apple's documentation or am I doing something wrong? Is it possible to set region monitoring to relatively small values (like 5-25 meters)?
You cannot set iOS Region Monitoring to lower values unless turning on significantLocationChanges. It's only working in US in bigger cities because region monitoring is based on cellular network.
Sorry for being a noob here. I am not able to clearly differentiate between CLLocationManager's properties distanceFilter and desiredAccuracy.
If I want my application to give different coordinates for even small distances (say 100-200 metres) what values should i set for these properties.
Help would be greatly appreciated.
According to developer.apple.com
distanceFilter
The minimum distance (measured in meters) a device must move laterally
before an update event is generated.
That means, based on previous location event, another location update will only be received after exceeding distanceFilter value distance.
desiredAccuracy refers to how accurate your location data should be.
For example if you wish to see the exact street you're on you a high accuracy value for this parameter. (kCLLocationAccuracyBest)
If you only wish to see the approximate area (such as in which neighbourhood you're in) you'd set a lower accuracy value for this param. (kCLLocationAccuracyThreeKilometers)
Choose this to suit your needs, however be aware that the more precise you wish to be and the more often you request updates, the more power it will drain from your device.
Hope this helps,
Vlad
distanceFilter - this is minimal distance which device should pass from previous location which was passed to delegate with ...didUpdateToLocation:... method. And as soon as distance reached location service will invoke ...didUpdateToLocation... again and so on.
desiredAccuracy - tells to location service how accurate coordinate you want and this is minimal location error radius. If value is very low (ex. 5) radio will try to use GPS hardware and will keep powering it up hardly to make it give most accurate location. If value is large,than system may decide to use data which was retrieved from WiFi hotspots location triangulation.
I'd like to know (from a high level view) what would be required to take a pdf floor plan of a building and determine where exactly you are on that floor plan using GPS coordinates? In addition to location, the user would be presented with a "turn by turn" directions to another point on the map, navigating down hallways, between cubicles, etc.
Use case: an iPhone app that determined a user's location and guided them to a conference room or person's office in the building.
I realize that this is by no means trivial, but any help is appreciated. Thanks!
It's an interesting problem. When you're using Core Location, you're not necessarily using GPS. Using WiFi and cell tower triangulation, you can get pretty good location results. So from Core Location you get a latitude and longitude fix. (You might also get altitude info, since GPS data is 3-dimensional. You also will get an accuracy value.)
So you have lat and lon. You need to map these coordinates to the PDF plan's coordinates. Assuming that the plan is aligned with the latitude and longitude lines, and that you have a lat-long fix for one of the points on the plan, you need to calculate the x-axis scale and y-axis scale. Then it's some calculations to map the lat-long to x-y coordinates on the PDF plan.
GPS may not be accurate enough for this purpose, especially indoors. Assuming errors on
the order of 10 meters, you'll have difficulty determining which floor the user is on.
Here's a neat (?) idea that might work: can you post some "You are here" placards
at various locations around the building? You could label each one with a unique,
machine-readable location code (maybe a QR code or something similar), then take an
image using the camera, have your app read that image and interpret the location code,
and use that instead of GPS to determine the start location.
GPS inside? That's your first -- and biggest -- hurdle.
Next hurdle is knowing the GPS coordinates of at least three points on that PDF to define the plane of of your map in the real world. (The PDF will need to be to scale, of course.)
So that gives you where you are on the PDF. Now you'll need to figure out some way to determine where you can walk (or where you can't) to get directions.