Baidu Map API, specify scale size

Source: Internet
Author: User

Baidu map in the automatic positioning, the size of the scale is the default 5 km. However, this range is too large to meet the needs of the application, you need to specify the size of the scale when positioning. Through groping and inquiry, finally found a solution.

is to add the following code to the location listener ,

float f = mbaidumap.getmaxzoomlevel ();//19.0 Minimum scale
Float m = mbaidumap.getminzoomlevel ();//3.0 Maximum scale
Mapstatusupdate U = mapstatusupdatefactory.newlatlngzoom (ll, f-2);//set to 100 meters in size

The overall code:

/**
* Locate the SDK listener function
*/
Protected class Mylocationlistenner implements Bdlocationlistener {


@Override
public void Onreceivelocation (bdlocation location) {
Map view is not processed in the new receive location after it is destroyed
if (location = = NULL | | mmapview = = NULL)
Return
Mylocationdata locdata = new Mylocationdata.builder ()
. Accuracy (Location.getradius ())//Here Set the direction information the developer obtains, clockwise 0-360
. direction (+). Latitude (Location.getlatitude ())
. Longitude (Location.getlongitude ()). build ();
Mbaidumap.setmylocationdata (Locdata);
LATLNG ll = new Latlng (Location.getlatitude (),
Location.getlongitude ());
float f = mbaidumap.getmaxzoomlevel ();//19.0
// float m = Mbaidumap.getminzoomlevel ();//3.0
Mapstatusupdate U = mapstatusupdatefactory.newlatlngzoom (ll, f-2);
Mbaidumap.animatemapstatus (U);
}


public void Onreceivepoi (Bdlocation poilocation) {

}
}

Baidu Map API, specify scale size

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.