Baidu map API, which specifies the scale
When Baidu maps are automatically located, the default scale is 5 kilometers. However, this range is too large to meet application requirements. You need to specify the scale when positioning. Finally, the solution was found through exploration and query.
Add the following code to the locating listener,
Float f = mBaiduMap. getMaxZoomLevel (); // 19.0 min Scale
// Float m = mBaiduMap. getMinZoomLevel (); // 3.0 maximum scale
MapStatusUpdate u = MapStatusUpdateFactory. newLatLngZoom (ll, F-2); // set the size to 100 meters
Overall code:
/**
* Locate the SDK listener Function
*/
Protected class MyLocationListenner implements BDLocationListener {
@ Override
Public void onReceiveLocation (BDLocation location ){
// After map view is destroyed, it is not processed in the new receiving location
If (location = null | mMapView = null)
Return;
MyLocationData locData = new MyLocationData. Builder ()
. Accuracy (location. getRadius () // set the direction information obtained by the developer, Which is 0-360 clockwise.
. Direction (100). latitude (location. getLatitude ())
. Longpolling (location. getlongpolling (). build ();
MBaiduMap. setMyLocationData (locData );
LatLng ll = new LatLng (location. getLatitude (),
Location. getlongpolling ());
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 ){
}
}