Android via Baidu Map location to get coordinates in the navigation map above the display, coordinates are shifted

Source: Internet
Author: User


private void Initmap () {

Positioning initialization

Mlocclient = new Locationclient (this);

Mlocclient.registerlocationlistener (MyListener);

locationclientoption option = new Locationclientoption ();

Option.setopengps (TRUE);//Turn on GPS

Option.setcoortype ("Bd09ll"); Set the coordinate type

Setscanspan < 1000 is the app active request location;

setscanspan>=1000, the Timed positioning mode (the value of Setscanspan is the time interval of the timed position))

In the timed positioning mode, the Positioning SDK will update the location according to the time position set by the app, and the callback location result is timed.

Http://developer.baidu.com/map/index.php?title=android-locsdk/qa

Option.setscanspan (1000);

mlocclient.setlocoption (option);

Mlocclient.start ();

}

by Baidu Map (above) to get the current coordinates, displayed on the navigation map, the position will be offset


Workaround (obtained with Locationmanager location manager):

Locationmanager lm = (locationmanager) getsystemservice (Context.location_service);

Location location = lm.getlastknownlocation (Locationmanager.gps_provider);

double longitude = Location.getlongitude ();

double latitude = Location.getlatitude ();

Set the latitude and longitude obtained by the Locationmanager location Manager to the navigation map to display the current position (smaller offset)

This article from "Rookie of the Mind Course" blog, reproduced please contact the author!

Android via Baidu Map location to get coordinates in the navigation map above the display, coordinates are shifted

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.