package xgpushdemo.qt.an.appmap;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
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.MapView;
import com.baidu.mapapi.map.MyLocationData;
/***
* 百度定位、导航
* */
public class MainActivity extends Activity {
private Button clickbtn;
private TextView txt1;
private TextView txt2;
private MapView mMapView = null;
private BaiduMap mBaiduMap=null;
//定位相关申明
private LocationClient locationClient;
//是否第一次定位
private Boolean isFirstloc=true;
//是否开启
private Boolean isStart=true;
private String la;
private String lo;
private String city;
public BDLocationListener myListener=new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
if(bdLocation==null||mMapView==null)
return;
MyLocationData myLocationData= new
MyLocationData.Builder().accuracy(bdLocation.getRadius()).direction(100).
latitude(bdLocation.getLatitude()).longitude(bdLocation.getLongitude()).build();
mBaiduMap.setMyLocationData(myLocationData);
city= bdLocation.getCity();
la=bdLocation.getLatitude()+"";
lo=bdLocation.getLongitude()+"";
// if(isFirstloc){
// isFirstloc=false;
// LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude());
// MapStatusUpdate mapStatusUpdate= MapStatusUpdateFactory.newLatLngZoom(ll,16);
// mBaiduMap.animateMapStatus(mapStatusUpdate);
// }
}
};
2021-05-25 22:31:07
951KB
sDk
1