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