Android基于位置服务,百度地图的显示
MainActivity类
package com.example.hejun.lbstest;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.model.LatLng;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
public LocationClient mLocationClient;
private TextView positionText;
private MapView mapView;
private BaiduMap baiduMap;
private boolean isFirstLocate = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate ( savedInstanceState );
mLocationClient= new LocationClient ( getApplicationContext () );
mLocationClient.registerLocationListener ( new MyLocationListener());
SDKInitializer.initialize ( getApplicationContext () );
setContentView ( R.layout.activity_main );
mapView = (MapView)findViewById ( R.id.bmapView );
baiduMap = mapView.getMap ();
baiduMap.setBaiduHeatMapEnabled ( true );
positionText = (TextView) findViewById ( R.id.position_text_view );
List<String>permissionList = new ArrayList <> ( );
if (ContextCompat.checkSelfPermission ( MainActivity.this,Manifest.
permission.READ_PHONE_STATE)!=PackageManager.PERMISSION_GRANTED){
permissionList