How to obtain your accurate location and why the iPhone on app is not positioned accurately? Why?
I believe that most apps use AMAP and Baidu maps, and use the user location retrieval function. Then you will find that you have set the filter precision for the map interface, and the result you get is not accurate. You often run on the road, and the result shows that your car is swimming in the river on your application, burst into tears. Let me tell you why it is so difficult for you to get the correct user location.
First, the GPS Positioning of the IPHONE can obtain location information around the world. It is not as hard as Android to enter the room and cannot be located. If you cannot locate your location on the map on the back of a mountain, it is not that your map did not receive the GPS location information, but that your map did not include your coordinate information ,. In this scenario, I tested the position of a Trojan near my position in Hangzhou after the Tigers run. Another test application I wrote on the back of the mountain received the GPS position information, but neither the AMAP nor the Baidu map was located. My mobile phone switches from 4G to 3G network on the top of the Tianzhu Mountain. The application I wrote received the GPS location information. Neither the AMAP nor the Baidu map had the location information. The Baidu map was able to load the map, AMAP cannot be loaded. After testing the IPHONE application, your mobile app can still receive the location information as long as there is a network when it is turned on and the network is closed later. Therefore, the IPHONE obtains the GPS location information or the location information of the base station. Unlike installation, it is a base station location, GPS location, and network location N. However, the accuracy of GPS information in IOS is still affected by obstacles such as buildings and mountains. If the test is performed on the sixth floor of the main building of our company, use a 4G network to locate the location that is far away (500 metres away), enable wifi, and generally enable AMAP, the precision obtained is about 65, and the accuracy of 4G network outside the company can reach 10-20 meters.
Take AMAP as an example:
Autonavi has two types of Location Information Filtering settings: Set the filtering distance and set the expected precision.
_ MapView. distanceFilter = 20.0;
// _ MapView. desiredAccuracy = kCLLocationAccuracyHundredMeters;
After you set the filtering accuracy, when your application starts, three points with an accuracy of over 20 meters (up to 65 meters) enter if (updatingLocation). It's not the coordinates you expected. In the future, there will be a point with a precision of 20-45 meters to enter. So what do you expect? Unreliable.
-(Void) mapView :( MAMapView *) mapView didUpdateUserLocation :( MAUserLocation *) userLocationupdatingLocation :( BOOL) updatingLocation {if (updatingLocation) {// operation related to location information and location saving, running Track of the picturesque car }}
Let's get to the point where the precision reaches 20 meters. Of course, it depends on the progress. Note: If the GPS signal in a certain area is poor and the precision cannot reach 20 meters, you may filter out all the location information, so your car will not have a track in this area. Who made you filter too much! You are so cruel to me that I have been on Earth for a while. Because of our application of Caocao, we do not consider the vertical height of the car, but the horizontal precision. If you want to control the horizontal precision, you can control it on your own! If you are not satisfied with the precision control, we recommend that you use the three-point filter method (take the last three points. If the error of the 2nd points is too large, the second point is eliminated ).
The correct location code is:
-(Void) mapView :( MAMapView *) mapView didUpdateUserLocation :( MAUserLocation *) userLocationupdatingLocation :( BOOL) updatingLocation {if (updatingLocation) {if (userLocation. location. horizontalAccuracy <= 20.0) {// Save the location information and operations related to the location, the running track of the picturesque car }}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.