Baidu map positioning shows the center of the screen

/*****
 * The positioning result callback, rewrite the onReceiveLocation method, you can directly copy the following code to your own project to modify
 */
private BDLocationListener mListener = new BDLocationListener() {
    @Override
    public void onReceiveLocation(final BDLocation location) {

        MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
                // Set the direction information obtained by the developer here, clockwise 0-360
                .direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build();
        Map.setMyLocationData(locData);



        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                tv_addstr.setText(location.getAddrStr());
                LatLnginfo(location.getLatitude(),location.getLongitude());
            }
        });
    }

    @Override
    public void onConnectHotSpotMessage(String s, int i) {
    }

};

 

private void LatLnginfo(double Latitude,double Longitude){
        LatLng ll = new LatLng(Latitude, Longitude);
        BitmapDescriptor bitmap = BitmapDescriptorFactory
                .fromResource(R.mipmap.icon_geo);
//Build a MarkerOption to add a Marker to the map
        OverlayOptions option = new MarkerOptions()
                .position(ll)
                .icon(bitmap);
//Add Marker to the map and display it
        Map.addOverlay(option);
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        Map.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325434847&siteId=291194637