Baidu Map Positioning principle

Source: Internet
Author: User

Positioning we are using the Baidu Android positioning SDKv4.0, we first understand the positioning principle and positioning accuracy


Positioning principle

Use the Baidu Android Location SDK to register GPS and network usage rights. Positioning SDK uses GPS, base station, Wi-Fi signal to locate. When an application initiates a location request to the Location SDK, the Location SDK locates according to the actual situation of the application's positioning factors (GPS, base station, Wi-Fi signal), such as whether the GPS is turned on, whether the network is connected, whether there is a signal, etc.
The user can set the positioning basis to meet their own needs:
If the user sets the GPS first, the priority is to use GPS positioning, if the GPS location is not open or no available location information, and the network connection is normal, the Location SDK will return to the network location (i.e. Wi-Fi and base station) the best results. To make the resulting network positioning result more accurate, turn on the phone's Wi-fi switch.




Positioning accuracy



Understand the principle of Baidu positioning and positioning accuracy, then we will use Baidu positioning SDKv4.0 Bar

One. Import library files

Before using Baidu to locate SDKv4.0, we want to download the latest library file: Click to download the relevant library file, copy the liblocsdk4.so file to the Libs/armeabi directory. Copy the Locsdk4.0.jar file to the project's Libs directory

Two. A tool class to get the current position

Package Com.smarteye.baidumap;import Java.util.calendar;import Com.baidu.location.bdlocation;import Com.baidu.location.bdlocationlistener;import Com.baidu.location.locationclient;import Com.baidu.location.locationclientoption;import Com.baidu.location.locationclientoption.locationmode;import Com.smarteye.adapter.bvcu_pucfg_gpsdata;import Com.smarteye.adapter.bvcu_walltime;import Com.smarteye.coresdk.bvpu;import Android.content.context;import Android.util.log;public class BaiduLocationTools { Private locationclient locationclient;private Locationlistener listener;public baidulocationtools (context context) { Locationclient = new Locationclient (Context.getapplicationcontext ()); listener = new Locationlistener (); Locationclient.registerlocationlistener (listener); locationclientoption option = new Locationclientoption (); Option.setlocationmode (locationmode.device_sensors); o Ption.setopengps (True); Option.settimeout (+); Option.setcoortype ("Bd09ll"); Option.setscanspan (+); o Ption.setisneedaddRess (True); Option.setneeddevicedirect (true); locationclient.setlocoption (option);} public void Startlocationstart () {Locationclient.start ();} public void Stoplocationstart () {if (locationclient! = null) {locationclient.stop ();}} Private class Locationlistener implements Bdlocationlistener {@Overridepublic void onreceivelocation (bdlocation Location) {if (location = null) {LOG.I ("Baidulocationtools", "location.getloctype----->" + location.getloctype ()); GLOBALTOOL.BAIDU_TO_WGS84 (location);d ouble latitude = location.getlatitude ();d ouble longitude = Location.getlongitude (); Bvcu_pucfg_gpsdata data = new Bvcu_pucfg_gpsdata (); Bvcu_walltime time = new Bvcu_walltime (); Calendar calendar = Calendar.getinstance (); time.iday = (char) calendar.get (calendar.day_of_month); time.ihour = ((char) Calendar.get (Calendar.hour)); Time.iminute = ((char) calendar.get (Calendar.minute)); time.imonth = ((char) ( Calendar.get (Calendar.month) + 1); Time.isecond = ((char) calendar.get (Calendar.second)); time.iyear = ((short) Calendar.get (calendar.year));d ata.sttime = Time;data.ilatitude = ((int) (latitude * 10000000));d ata.ilongitude = ((int ) (Longitude * 10000000)); LOG.I ("Baidulocationtools", "ilatitude------>" + data.ilatitude); LOG.I ("Baidulocationtools", "ilongitude------>" + data.ilongitude);d ata.borientationstate = 1;data.bantennastate = 1; Bvpu. Inputgpsdata (data);}}}

    • bdlocation The locating results of the positioning SDK are encapsulated and obtained in the Bdlocationlistener OnReceive method. By this kind of user can get error code, location coordinates, precision radius, address and other information, for its getloctype () method obtained error code some cases
    1. 61:gps Locating results
    2. 62: Scan consolidation location based on failure. The positioning result is not valid at this time.
    3. 63: Network exception, the request was not successfully initiated to the server. The positioning result is not valid at this time.
    4. 65: The result of locating the cache.
    5. 66: Offline location results. The corresponding return result when called by Requestofflinelocaiton
    6. 67: Offline location failed. The corresponding return result when called by Requestofflinelocaiton
    7. 68: When a network connection fails, find the corresponding return results for local offline targeting
    8. 161: Network Targeting results
    9. 162~167: Service-side location failed

Baidu Map Positioning principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.