Browse Source

APIModuleGis 2.1.2 高德地图SDK 修改相关代码

1037015548@qq.com 6 months ago
parent
commit
f1fb257bfe

+ 1 - 0
moduleGis/build.gradle

@@ -52,6 +52,7 @@ dependencies {
     // 高德定位 SDK(检查版本号,确保为最新)
     implementation files('libs/AMap_Location_V6.4.8_20241029.jar')
     implementation files('libs/commons-collections4-4.4.jar')
+    implementation files('libs/fastjson-1.2.83.jar')
 //    compileOnly files('../app/libs/AMap_Location_V6.4.8_20241029.jar')
 //    compileOnly files('../app/libs/commons-collections4-4.4.jar')
 //    implementation 'com.amap.api:location:latest.integration'

+ 29 - 3
moduleGis/src/main/java/com/example/moduleGis/APIModuleGis.java

@@ -27,6 +27,7 @@ import android.widget.RelativeLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.amap.api.location.AMapLocation;
 import com.amap.api.location.AMapLocationClient;
 import com.amap.api.location.AMapLocationClientOption;
@@ -1366,7 +1367,7 @@ public class APIModuleGis extends UZModule {
 	class AMapZidingyiLocation{
 		int code = 1;                           //0--成功;非0--失败
 		long acceptTime = 0L;                   //接收高德定位回调的时间
-		AMapLocation data = null;         //高德定位结果
+		Map<String,Object> data = null;         //高德定位结果
 
 		public AMapZidingyiLocation(){
 
@@ -1374,10 +1375,35 @@ public class APIModuleGis extends UZModule {
 		public AMapZidingyiLocation(int code,long acceptTime,AMapLocation data){
 			this.code = code;
 			this.acceptTime = acceptTime;
-			this.data = data;
+			Map<String,Object> newData = new HashMap<>();
+			newData.put("latitude",data.getLatitude());//纬度
+			newData.put("longitude",data.getLongitude());//经度
+			newData.put("accurac",data.getAccuracy());//精度
+			newData.put("altitude",data.getAltitude());//海拔
+			newData.put("speed",data.getSpeed());//速度
+			newData.put("bearing",data.getBearing());//方向角
+			newData.put("buildingId",data.getBuildingId());//室内定位建筑物Id
+			newData.put("floor",data.getFloor());//室内定位楼层
+			newData.put("address",data.getAddress());//地址描述
+			newData.put("country",data.getCountry());//国家
+			newData.put("province",data.getProvince());//省份
+			newData.put("city",data.getCity());//城市
+			newData.put("district",data.getDistrict());//城区
+			newData.put("street",data.getStreet());//街道
+			newData.put("streetNum",data.getStreetNum());//街道门牌号
+			newData.put("cityCod",data.getCityCode());//城市编码
+			newData.put("adCode",data.getAdCode());//区域编码
+			newData.put("poiName",data.getPoiName());//当前位置POI名称
+			newData.put("aoiName",data.getAoiName());//当前位置所处AOI名称
+			newData.put("gpsAccuracyStatus",data.getGpsAccuracyStatus());//设备当前 GPS 状态
+			newData.put("locationType",data.getLocationType());//定位来源
+			newData.put("locationDetail",data.getLocationDetail());//定位信息描述
+			newData.put("errorInfo",data.getErrorInfo());//定位错误信息描述
+			newData.put("errorCode",data.getErrorCode());//定位错误码
+			this.data = newData;
 		}
 		public String toString(){
-			return "{\"code\":"+code+",\"acceptTime\":"+acceptTime+",\"data\":"+ (data==null?"":com.qx.wz.external.fastjson.JSONObject.toJSONString(data)) +"}";
+			return "{\"code\":"+code+",\"acceptTime\":"+acceptTime+",\"data\":"+ (data==null?"{}": com.alibaba.fastjson.JSONObject.toJSONString(data)) +"}";
 		}
 	}
 	CircularFifoQueue<AMapZidingyiLocation> lastAMapLocations = new CircularFifoQueue<>(10);