获得经纬度
//导入百度地图
1 private void initBaiDuInfo() { 2 mLocationClient = new LocationClient(getApplicationContext()); 3 setLocationOption(); 4 mLocationClient.registerLocationListener(myListener); 5 mLocationClient.start(); 6 } 7 8 private class MyLocationListenner implements BDLocationListener { 9 @Override 10 public void onReceiveLocation(BDLocation location) { 11 System.out.println("onReceiveLocation"); 12 // if (null != location.getCity()) { 13 // LocalCity = location.getCity().substring(0, 14 // location.getCity().lastIndexOf("市")); 15 // System.out.println("LocalCity:"+LocalCity); 16 // new SharedPClass("LocalCity", LocalCity, 17 // PeopleActivity.this); 18 // } 19 if(location != null){ 20 latitude = location.getLatitude(); 21 longitude = location.getLongitude(); 22 23 initViewLVDataToDisplay(); 24 mLocationClient.stop(); 25 } 26 27 private void setLocationOption() { 28 LocationClientOption option = new LocationClientOption(); 29 option.setLocationNotify(true); 30 option.setOpenGps(true); 31 option.setIsNeedAddress(true); 32 option.setCoorType("bd09ll"); // 设置返回值的坐标类型 33 option.setLocationMode(LocationMode.Hight_Accuracy); 34 option.setTimeOut(30 * 1000); 35 mLocationClient.setLocOption(option); 36 }