Why does didUpdateLocation value differ from "my location" on map? - ios

I'm getting a user's location over time and continuously overlaying this information on an MKMapView.
My problem is, the location isn't correct. Hear me out. MKMapView's blue dot for my current location is showing my location EXACTLY correct. Correct as could be. However, my location from didUpdateLocations is not this same location. It's showing up ~500 meters WNW. I'm storing locations as CLLocation and displaying them using their coordinate member.
I can walk around and it will show my path very precisely, but offset 500m WNW. Why is this happening? How do I get my current location without this offset?

Well, it seems that the problem is China's cartography. This is well-documented:
All Maps In China Are Wrong
What The Map?
A Solution (too complicated in my opinion)
...so.... what next?
I'm going to use Chinese map providers' APIs to provide a simpler solution (Autonavi, Baidu, etc)

Related

iOS google map sdk user location image

1.It possible to change user location image in IOS google map sdk?
If yes, I must use accelerometer or something other way?
2.Can I change the radius of my location?
I think the answers are no and no.
As far as I can see from the official documentation, there seems to be no way to change the default user location dot. There is an open issue about it. You could hide the user location and draw your own annotation with an overlay of your own choice.
As for changing the radius, you can't do that either. That radius depends on the precision of the GPS signal, but you could draw your own overlays and hide the user location as stated above. However, I really don't see why you would do that.

Check if user is in the defined area

In my app I want to check if my position is within defined area. I know the area coordinates and I want to check it when app is launched. How can I do it? As far as I know, geofencing can help me, but this technique always scans user's location. And I need only a manual check.
If you've got the users coordinates from a manual check with CLLocationManager then store them as a CLLocation object, then have another CLLocation object that contains the centre point of the region you want to check. You can then use [someUserLocationObject distanceFromLocation:centralPointOfArea] which will give you the distance the user is (in metres) from the central point, and you can make a determination from there.

Snapping user location in MKMapView to a line/trail

I am working on a trails/maps app that has custom trails mapped out in a region and will aid the user navigate his or her way around some trails in a "foresty" area.
Currently, I am using MKMapView to get the user data/location, and loading the trails as overlays from a KML file. The problem I am having is that while testing the app, I noticed that in some situations the blue dot representing the user position goes off the trail overlays, which is expected since GPS (especially on phones) is not that great, plus some error that might have been obtained when getting the values for the trails to put in the KML file.
I apologize if all of that is a bit confusing, my question is: Is it possible to "snap" the user location (the blue dot that we all love) to a trail/overlay/path that is placed on the map with a specific tolerence? for example, if the blue dot appears to be a few pixels off the trails, then it would be placed right in the middle of the trails. If it is far off, then the user probably walked off the trails, and no snapping will happen to the user's location.
First off I wouldn't bother. If they are just a few pixels off they won't care, but if they are further away then it's important that they know where they are as accurately as possible. They could be lost in the snow and looking for trail markings.
If you do go ahead with that you'll have to abandon the userLocation dot and build our own. Using a LocationManager you can get told every time the device gets new location information and move your custom annotation dot to where you think they should be. More trouble that it's worth IMHO.

How to find the inverse of the China transform in MKMapView?

It seems to be a known fact that MKMapView (and Google's maps in general) have a varying offset on 100-600m which makes annotations display incorrectly on the map.
According to this thread, Google has a private method called _applyChinaLocationShift, and it works, but apparently only for CLLocations that are given by CLLocationManager. For arbitrary CLLocations, it returns nil. The app I'm writing only needs to work in one city, so I've thought of pre-sampling the area using _applyChinaLocationShift and store the inverse transforms in the shipped app if that was possible.
So basically, is there any way to convert a coordinate to a coordinate that corresponds to the transformed China maps?
How about using location simulation in the Simulator and feeding it a bunch of coordinates in that particular city.

iOS Dev: Map Offset in China

I made a very simple APP in which I can throw a pin right onto the location I am standing at (just a beginner's practice). But I found a problem.
I swear neither I was moving nor the device thought I was moving. And I directly use the geolocation to set the pin. but the pin and the current-location blue point are hundreds of meters apart.
(By the way, the blue point expressed my real location at the time.)
This is a famous problem of Google Map on iOS in China. Put aside the complicated issue of the so-called national security, where I want help is what should we do as a developer. Technically, is there a way, in programming, to figure out what exactly the offset is and correct it?
Does anyone have any idea?
At what time did you place the pin? iOS has up to three sources of location data (cell tower triangulation, Wifi sniffing and GPS) and will keep you up to date with the most accurate. So often you get a not very accurate location, then a more accurate location, then an even more accurate location.
If you have a MKMapView open then something you can do is key-value observe on its userLocation property rather than starting any sort of CLLocationManager. That way you'll always be updated with whatever the map view has decided is the current location, meaning that you don't need to try to match your logic to its.
I did some research on the offset, but haven't gotten a satisfying result yet. The added offset is deterministic, i.e. given a location, the deviated location is fixed. So my goal is to get the deviation function, f(p)=p', where both p and p' are 2D points. You can check here if you are interested.

Resources