|
|
@@ -5,6 +5,7 @@ import android.location.Location;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baidu.location.BDLocation;
|
|
|
+import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
|
/**
|
|
|
@@ -15,8 +16,8 @@ public class LocationUtils {
|
|
|
|
|
|
private static LocationUtils locationUtils;
|
|
|
|
|
|
- public static LocationUtils getInstance(){
|
|
|
- if(locationUtils == null){
|
|
|
+ public static LocationUtils getInstance() {
|
|
|
+ if (locationUtils == null) {
|
|
|
locationUtils = new LocationUtils();
|
|
|
}
|
|
|
return locationUtils;
|
|
|
@@ -27,19 +28,28 @@ public class LocationUtils {
|
|
|
* Latitude:纬度
|
|
|
* 获取经纬度
|
|
|
*/
|
|
|
- public String getLongitudeLatitude(){
|
|
|
+ public String getLongitudeLatitude() {
|
|
|
BDLocation location = SheepApp.getInstance().getCurLocation();
|
|
|
- if(location == null)
|
|
|
+ if (location == null)
|
|
|
return "";
|
|
|
- return location.getLongitude() + "," +location.getLatitude();
|
|
|
+ return location.getLongitude() + "," + location.getLatitude();
|
|
|
}
|
|
|
+
|
|
|
+ public String getGeocode() {
|
|
|
+ BDLocation location = SheepApp.getInstance().getCurLocation();
|
|
|
+ if (location == null)
|
|
|
+ return "";
|
|
|
+ return NumberFormatUtils.retainMost6(location.getLatitude()) + "," + NumberFormatUtils.retainMost6(location.getLongitude());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取定位
|
|
|
*/
|
|
|
- public JSONObject getLocationJSONObject(){
|
|
|
+ public JSONObject getLocationJSONObject() {
|
|
|
BDLocation location = SheepApp.getInstance().getCurLocation();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- if(location != null) {
|
|
|
+ if (location != null) {
|
|
|
jsonObject.put("longitude", location.getLongitude());
|
|
|
jsonObject.put("latitude", location.getLatitude());
|
|
|
jsonObject.put("addrStr", location.getAddrStr());
|