Does the accuracy property influence the accuracy of mapview.userLocation? [Titanium] - geolocation

I'm using the mapview property userLocation to show the users location on a map. Does it matter what value Ti.Geolocation.accuracy has or is the accuracy of the position marker (as it is a part of the map app) only influenced by the map app?
If it's latter: On Android I (as a User) can choose only between wifi/gps accuracy. Is the accuracy controlled automaticly (e.g. according to the battary charge)?

It seems that accuracy settings only apply to the Geolocation module. According to this thread, these settings have no effect on the user location accuracy on map views.

Based on the accuracy you choose, iOS uses its own logic to select location providers and filter location updates to provide location updates that meet your accuracy requirements.
Also remember: Location services stay enabled for as long as a listener is registered for the location event, so be sure to remove the event listener when you do not require location updates.
You can read more about it in Titanium.Geolocation documentation.
Rule of thumb is not overusing accuracy level when you are accessing user location. Be nice for your users and their devices. If your app will drain their battery in minutes they will remove your app and never come back to it.

Related

What Does startMonitoringSignificantLocationChanges uses to Deliver Location

I want to Know what does startmonitoringsignificantlocationchanges uses to deliver location, is it GPS or Wifi/Internet? My Understanding is it uses cellular or wifi,to know if device has moved significantly but what I don't know is, at time of picking location does it use GPS alone to pick up location.
My Findings are : I travelled 30 KM in City Train but did not get any locations in background and during this journey my Wifi and Cellular data was off. So please tell if Significant fails to provide locations based on GPS only.
Building location apps in the past, I assumed that GPS was only used when startUpdatingLocation() was called. After double-checking the docs, Apple doesn't explicitly state whether significantLocationChanges CAN use GPS, but it is a power-saving option, and their docs specify that it "requires the presence of cellular hardware", which makes me pretty certain that my assumption (and yours) are correct. I'd leave this up for a bit, in case there's a hardware expert who knows for sure. The docs you want: https://developer.apple.com/reference/corelocation/cllocationmanager
Like all location functionality, it uses a combination of cell, wifi, and GPS. Use of cell is primary. The idea is to keep use of GPS to a minimum, in order to prevent drain on the battery.
You certainly cannot expect this to work with the cell turned off; indeed, if your code properly checks significantLocationChangeMonitoringAvailable with the cell off, I would intuitively expect the answer to be false.
(Also note that you will not get any events unless you have a location manager with a delegate.)
As explained in this answer "Hows does Significant Location Change work?" (and in WWDC videos from 2013-2015) Significant location change monitoring uses a technique called Cell Tower Triangulation.
You can think of it as almost the same mechanism as GPS triangulation except that the cellular hardware will be used to gauge distance from nearby cell towers instead of firing the GPS hardware to get signals from actual satellites.
In my experience I've noticed that this method gives accuracy of approx. 1000m. It does not use the GPS hardware and hence is more battery efficient. It is good for coarse location updates. See WWDC 2013 session Harnessing iOS to Create Magic in Your Apps where the presenter makes a passing reference to this technology.

How does CLLocationManager get location?

TL;DR:
My objective: Try all forms of getting a location and then choose the most accurate one, (try get a location for a minute then time out).
I'm a little confused about where it gets the location from, is it GPS? Cellular? or a mix of both depending on toolkit?
While getting location on Android I used both and then choose which provider based on accuracy. I do not see anything similar for iOS.
I'm using CLLocationManager which is showing good accuracy but I'm not sure where the location is from.
On iOS, location manager is built more intelligently. Relying on your configuration, it either uses GPS or WiFi/cell radios, as described in the CLLocationManager documentation:
For the services you use, configure any properties associated with
that service accurately. Core Location manages power aggressively by
turning off hardware when it is not needed. For example, setting the
desired accuracy for location events to one kilometer gives the
location manager the flexibility to turn off GPS hardware and rely
solely on the WiFi or cell radios, which can lead to significant power
savings.
For more information, read
CLLocationManager documentation.
EDIT
And, If you want the most accurate location, you should put kCLLocationAccuracyBestForNavigation for location manager's desiredAccuracy property.

Determine whether user is at a specific location

What's the best way to determine whether the user is at a specific location, i.e. at a gas station?
I've implemented an approach where the app is listening for major location changes until the user get's close enough to a location. Then the app switches to the more accurate location updates (kCLLocationAccuracyBest). It then checks if the user is close enough, and if so, I consider this as a "check-in". This works quite well. If the user moves away from our location of interest, I switch back to the major location updates to save energy.
This works as the user does not live or work within the first threshold (I currently use 300 meters). This situation drains the user's battery for no reason. If I set this threshold to low, the major location updates might not be accurate enough to detect the user in front of our location.
I'm using MKLocalSearchRequest to find all the places of interest in close proximity to the user.
So, I assume there are better ways. Any suggestions?
Thanks!
– Flo
iBeacons are the low power way if that fits your use case. http://en.m.wikipedia.org/wiki/IBeacon Is a suprisingly good overview
They are reasonably cheap, and can be simulated with computer software

Switch btw. Location Manager & Region Monitoring

for an app that is part of a scientific study I have to implement location tracking (the users who take part in the study know this and are willing to supply this data). The two premises for this app are:
track the user's location with the highest accuracy possible while he/she is on the move
use as little power as possible so that users don't feel the need to shut down the app (turn off location services for it), while they aren't using it
I know these two requirements normally exclude each other :) So the general question is "What would be the best strategy to meet in the middle here?"
My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.
So two questions:
Can you tell me if the proposed approach will work for an app that is running in the background?
Have you maybe implemented something similar and know if it really saves a lot of battery power?
Regards,
Sebastian
My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.
Using region monitoring to re-engage the location monitoring has a few draw backs, that I have found:
If you set up a region for the user's current location, then wait for -didExitRegion to fire, you're reliant upon the system's default radius cushion, (probably 200m) and some time (probably 20 sec) after they cross out of their boundary before you'll get the message. If accuracy is your main goal, you're likely to loose a lot of data points in between when region monitoring started and when you cross out of the region. Is that acceptable for your needs?
So, to answer your questions:
Can you tell me if the proposed approach will work for an app that is running in the background?
You should not have any trouble running this type of thing in the background. Both location monitoring and region monitoring work when an app is backgrounded, provided you've set it up to do so. Also, to ensure Region Monitoring works on iOS 7 you must have Background App Refresh turned on for your app. That tripped me up.
Have you maybe implemented something similar and know if it really saves a lot of battery power?
In our experience the battery savings were not noticeable. Region Monitoring can be a battery drain that's just as significant as the high accuracy location updates because it uses all kinds of hardware to do it's thing. So pick your poison. Apple's recommendation for saving battery is and always has been to use the significant change location service. It gives you good location data just not as often.

CLLocationManager - Monitoring regions vs. Significant Location Changes

I am currently using significant location change updates to monitor whether or not the user has entered a particular area of interest (my definition of an area of interest is more broad than can be defined simply by geographic regions). My requirements are that my app should be woken up periodically to check if the user is said defined area (if it is not currently running).
My question is: would registering for region updates (since I have a number of regions that are known to fit my area of interest), provide me with more updates than simply listening for all significant lcoation changes, or would they simply be duplicate updates? The reason I ask this question is to clairify whether or not region monitoring is simply a filter on significant location change updates (since neither are documented as powering the GPS), or if region monitoring somehow is able to be more specific (maybe it powers the GPS, but with more specificity). In particular, I would be interested to know if anyone has seen data or documentation on this issue.
Thanks.
Region monitoring seems to pull from more specific location signal changes than the significant location change service. I say this because I've defined small regions (~100 m radius) that region monitoring picks up in the background, but that Significant location change does not. However please remember that the two events are triggered on different types of user actions.
Region monitoring - triggered on boundary crossings only. So a user must have two location update events on either side of the boundary. If you define large regions and the user walks around inside of them you will get no updates.
Significant location change - Seems to be triggered on the phone switching cell towers and the Location Awareness docs seem to suggest that. Here is some great data on general accuracy of these updates that suggests about 500 m between notification.

Resources