userLocation so different to CLLocation - ios

I am using CoreLocation to plot my lat/long. This is displayed as Homer in the attached picture (http://i.imgur.com/IRRwOS0.png). I have kCLLocationAccuracyBest set:
self.locMgr.distanceFilter = kCLDistanceFilterNone;
self.locMgr.desiredAccuracy = kCLLocationAccuracyBest;
When I enable userLocation on the map (blue dot) there appears to be a pretty big difference between the accuracies. The blue dot is alot more accurate to my actual location.
How can I improve CoreLocations accuracy to position my MKAnnotations closers to my actual location?
Why am I getting this inaccuracy? userLocation is wifi based while Homer is GPS?
Screenshot:

Implement mapView:didUpdateUserLocation and, within that, set your annotation location to equal the mapView's userLocation.
I'm not entirely sure, but I assume it's probably due to mapview using a private framework for location.

China offsets the GPS for annotations other then users current location. More information can be found here:
http://www.sinosplice.com/life/archives/2013/07/16/a-more-complete-ios-solution-to-the-china-gps-offset-problem

Related

What is the default coordinate of GMSMapView

I am using Google Maps iOS SDK.
I have installed the pod 'GoogleMaps'.
I have done the instantiation of Google Maps Services with Google API Key in App delegate.
I have created a UIView in storyboard and changed the view's class to GMSMapView and created outlet as mapView.
In viewDidLoad(), if i print mapview's coordinate as below, i get the lat long 51.1789, -1.8264
Can any one let me know if (51.1789, -1.8264) is the default coordinate of GMSMapView
No, (51.1789, -1.8264) are not default coordinate of GMSMapView.
Actually you are calling the mapView.camera which is used to control the camera, which defines how the map is oriented.
& You are try to access the target object which defines the location on the Earth towards which the camera points.
Here
target.latitude returns the equator position (In which Positive values indicate latitudes north of the equator & Negative values indicate latitudes south of the equator).
target.longitude returns meridian position (It Measurements are relative to the zero meridian, with positive values extending east of the meridian and negative values extending west of the meridian).
Here is the visual explanation:
For learn in depth, just follow official documentation iOS >
Maps SDK for iOS

iOS core location heading and course changing

I am working on an app in which I show the location and direction a plane is heading when flying. I also want to then show labels of the cities one is flying by using augmented reality. I have everything set up and it was working ok when sitting still or driving in a car but when I used it on a plane something weird happened.
When sitting at the gate with the door open or closed the heading of the location icon shows the correct direction when the device is in landscape mode (home button to right). If I rotate the device to the right the plane icon rotates to the right the appropriate amount. Same with left. This is important because when I rotate the phone to the right or left and open the camera for augmented reality the correct cities show up in the correct place. This works completely fine even when we are taxiing on the runway.
However when we take off the function changes. Now no matter what way I change the rotation of the device the plane icon always points in the direction the plane is moving.
I am trying to figure out why this happens and was wondering if this is because at the slower speed sitting still or taxiing core location is using HEADING whereas when we take off enough information is being gather to use COURSE information.
I don't thing this is happening because I am in a faraday cage because it wouldn't work when at the gate or taxiing.
If it is in fact using Heading/Course information how do I compensate so the city labels are where they are supposed to be instead of constantly moving to the front of the plane?
am getting the user latitude, longitude and altitude and the correct heading to the cities so all that is working fine. It is just heading/course problem.
Here is some code just to show I have these things going.
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
Can I use gyroscope to tell what direction the phone is pointing and add it to the heading/course to get the labels in the correct place if the speed is above a certain amount?
Has anyone ran into the problem and solved it?
This is all well documented by Apple. The location manager uses your direction of motion to determine heading, and ignores phone attitude, if you are moving quickly. If you want the phone attitude independently you must use Core Motion instead.

keep track with the distance between user's location and other coordinates

I'm trying to send notification when user is 300 meter from any map pin (all pins coming from an API)
I calculate the distance by ..
currentLocation = CLLocationManager()
currentLocation!.distance(from: pinLoc)
I get the distance right, however, to keep tracking the user's location (Driving) I have to put the my code in the (didUpdateLocations) function, which will keep looping forever [I don't use stopUpdatingLocation() because I need to keep getting the user's location]
Is there any other ways to keep getting the user's location (coordinates) constantly without having to go inside infinite loop!
I also use
mapView.userTrackingMode = .follow
To track the user's location on the map.
Thank you.
You can use userLocation property of mapView to keep getting the user's location (coordinates) constantly.
mapView.userLocation.coordinate

How to zoom to current location on map with Skobbler

I want to zoom to current user's location upon initialising SKMap.
Right now I don't know if it's even possible (even though it's impossible that it's impossible) but I fail to find the way through documentation.
Only thing I found is method for android
mapView.setZoom(int);
But there is nothing like it for iOS.
How can I zoom to the users current location then?
Simply create a region for your map to focus onto:
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(52.5233, 13.4127);
region.zoomLevel = 17;
mapView.visibleRegion = region;
I've never used SKMap before, but, yes you can simply obtain the user's location in iOS using CLLocationManager. I assume there's a function in SKMap by which you can zoom to a particular set of coordinates, to which you can simply pass the coordinates obtained from CLLocation Manager.

MKMapView show extra zoomed region. How?

I need to show very small area (30x30 meters) on MKMapView. Setting appropriate region or visibleMapRect doesn't work. MapView shows much bigger region.
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([centerLocation coordinate], 30, 30);
[mapView setRegion:region];
It seems with extra small regions MapView corrects with regionThatFits method before update map.
Manually zoom allows displaying such region.
MapKit is not really designed for such high-zoom indoor uses. You may want to check out alternatives such as the open source MapBox iOS SDK, which has been used for indoor applications. In particular iOS 7's iBeacons technology as well may be useful to you for indoor triangulation and higher accuracy than something like GPS, which was neither designed for indoor nor high-zoom use.
According to Apple docs:
When setting a new region, the map may adjust the value in the region
parameter so that it fits the visible area of the map precisely. This
is normal and is done to ensure that the value in the region property
always reflects the visible portion of the map. However, it does mean
that if you get the value of that property right after calling this
method, the returned value may not match the value you set. (You can
use the regionThatFits: method to determine the region that will
actually be set by the map.)
So, when you apply distance, it creates the region which is best fit for your request. It will not be exactly same as what you have requested.
Also, 30*30 meters is very very high zoom level which might not be supported. Hope it will help.

Resources