添加腾旭地图数据与手机GPS位置修复模型
This commit is contained in:
parent
f12496f5ad
commit
1113503a23
@ -1,6 +1,11 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
// 本地 Maven 仓库(默认路径为 ~/.m2/repository)
|
||||||
|
mavenLocal()
|
||||||
|
// 或自定义本地仓库路径
|
||||||
|
maven { url "file:///sdcard/.m2/repository" }
|
||||||
|
|
||||||
// Nexus Maven 库地址
|
// Nexus Maven 库地址
|
||||||
// "WinBoll Release"
|
// "WinBoll Release"
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||||
@ -15,7 +20,7 @@ buildscript {
|
|||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
mavenLocal()
|
//mavenLocal()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Thu Mar 20 12:32:45 GMT 2025
|
#Fri Mar 21 03:15:13 GMT 2025
|
||||||
stageCount=0
|
stageCount=0
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=1.0
|
baseVersion=1.0
|
||||||
publishVersion=1.0.0
|
publishVersion=1.0.0
|
||||||
buildCount=265
|
buildCount=281
|
||||||
baseBetaVersion=1.0.1
|
baseBetaVersion=1.0.1
|
||||||
|
@ -6,7 +6,6 @@ package cc.winboll.studio.positions.fragments;
|
|||||||
* @Describe 腾讯地图服务视图
|
* @Describe 腾讯地图服务视图
|
||||||
*/
|
*/
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import cc.winboll.studio.positions.R;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
@ -31,6 +30,9 @@ import androidx.core.app.ActivityCompat;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||||
|
import cc.winboll.studio.positions.R;
|
||||||
|
import cc.winboll.studio.positions.models.PostionFixModel;
|
||||||
import cc.winboll.studio.positions.models.PostionModel;
|
import cc.winboll.studio.positions.models.PostionModel;
|
||||||
import cc.winboll.studio.positions.utils.LocationFileStorage;
|
import cc.winboll.studio.positions.utils.LocationFileStorage;
|
||||||
import com.tencent.map.geolocation.TencentLocation;
|
import com.tencent.map.geolocation.TencentLocation;
|
||||||
@ -52,8 +54,6 @@ import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
|
||||||
|
|
||||||
public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener {
|
public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener {
|
||||||
|
|
||||||
@ -68,7 +68,9 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
private int mPage;
|
private int mPage;
|
||||||
private TextureMapView mapView;
|
private TextureMapView mapView;
|
||||||
protected TencentMap tencentMap;
|
protected TencentMap tencentMap;
|
||||||
TextView mtvInfo;
|
TextView mtvTXMyLocationInfo;
|
||||||
|
TextView mtvPhoneMyLocationInfo;
|
||||||
|
TextView mtvPostionFixModelInfo;
|
||||||
private LocationSource.OnLocationChangedListener locationChangedListener;
|
private LocationSource.OnLocationChangedListener locationChangedListener;
|
||||||
|
|
||||||
private TencentLocationManager mTencentLocationManager;
|
private TencentLocationManager mTencentLocationManager;
|
||||||
@ -77,6 +79,10 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
ArrayList<PostionModel> locationPostionModelList;
|
ArrayList<PostionModel> locationPostionModelList;
|
||||||
Location lastLocation;
|
Location lastLocation;
|
||||||
static TXMSFragment _TXMSFragment;
|
static TXMSFragment _TXMSFragment;
|
||||||
|
PostionFixModel mPostionFixModel;
|
||||||
|
Location locationTX;
|
||||||
|
Location locationPhoneGPS;
|
||||||
|
LocationManager locationManagerPhoneGPS;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -95,7 +101,9 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
||||||
tencentMap = mapView.getMap();
|
tencentMap = mapView.getMap();
|
||||||
|
|
||||||
mtvInfo = viewRoot.findViewById(R.id.tv_info);
|
mtvTXMyLocationInfo = viewRoot.findViewById(R.id.txmylocationinfo_tv);
|
||||||
|
mtvPhoneMyLocationInfo = viewRoot.findViewById(R.id.phonemylocationinfo_tv);
|
||||||
|
mtvPostionFixModelInfo = viewRoot.findViewById(R.id.postionfixmodelinfo_tv);
|
||||||
|
|
||||||
checkLocationPermission();
|
checkLocationPermission();
|
||||||
|
|
||||||
@ -107,7 +115,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
//创建Marker对象之前,设置属性
|
//创建Marker对象之前,设置属性
|
||||||
//LatLng position = new LatLng(40.011313,116.391907);
|
//LatLng position = new LatLng(40.011313,116.391907);
|
||||||
BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
||||||
Location location = createLocationFromLatLng(latLng);
|
Location location = createTXLocationFromLatLng(latLng);
|
||||||
addLocationToMap(location);
|
addLocationToMap(location);
|
||||||
Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||||
|
|
||||||
@ -121,36 +129,30 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
|
|
||||||
loadLocations();
|
loadLocations();
|
||||||
|
|
||||||
/*UiSettings uiSettings = tencentMap.getUiSettings();
|
UiSettings uiSettings = tencentMap.getUiSettings();
|
||||||
uiSettings.setAllGesturesEnabled(true);
|
uiSettings.setAllGesturesEnabled(true);
|
||||||
mTencentLocationManager = TencentLocationManager.getInstance(getActivity());
|
mTencentLocationManager = TencentLocationManager.getInstance(getActivity());
|
||||||
//创建定位请求
|
//创建定位请求
|
||||||
mTencentLocationRequest = TencentLocationRequest.create();
|
mTencentLocationRequest = TencentLocationRequest.create();
|
||||||
mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
||||||
|
|
||||||
//地图上设置定位数据源
|
//地图上设置定位数据源
|
||||||
tencentMap.setLocationSource(this);
|
tencentMap.setLocationSource(this);
|
||||||
//设置当前位置可见
|
//设置当前位置可见
|
||||||
tencentMap.setMyLocationEnabled(true);
|
tencentMap.setMyLocationEnabled(true);
|
||||||
//设置定位图标样式
|
//设置定位图标样式
|
||||||
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
||||||
tencentMap.setMyLocationEnabled(true);
|
tencentMap.setMyLocationEnabled(true);
|
||||||
tencentMap.setMyLocationStyle(myLocationStyle);
|
tencentMap.setMyLocationStyle(myLocationStyle);
|
||||||
//startLocation();
|
startLocation();
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// 本机 GPS 定位服务调用服务
|
|
||||||
//
|
|
||||||
// LocationManager locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
|
|
||||||
// String provider = LocationManager.GPS_PROVIDER;
|
|
||||||
// Location location = locationManager.getLastKnownLocation(provider);
|
|
||||||
// locationManager.requestLocationUpdates(provider, 2000, 10, locationListener);
|
|
||||||
// moveToLocation(location);
|
|
||||||
|
|
||||||
return viewRoot;
|
return viewRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void genLocationFixModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void startLocation() {
|
private void startLocation() {
|
||||||
mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
||||||
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
||||||
@ -170,7 +172,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
locationPostionModelList = LocationFileStorage.loadFromFile(getActivity());
|
locationPostionModelList = LocationFileStorage.loadFromFile(getActivity());
|
||||||
|
|
||||||
for (PostionModel lj : locationPostionModelList) {
|
for (PostionModel lj : locationPostionModelList) {
|
||||||
tencentMap.addMarker(new MarkerOptions(convertToLatLng(lj.toLocation())));
|
tencentMap.addMarker(new MarkerOptions(convertLocationToLatLng(lj.toLocation())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,16 +188,19 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
// LocationFileStorage.saveToFile(getActivity(), locationPostionModelList);
|
// LocationFileStorage.saveToFile(getActivity(), locationPostionModelList);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
LocationListener locationListener = new LocationListener() {
|
// 手机 GPS 定位信息
|
||||||
|
LocationListener phoneGPSLocationListener = new LocationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(Location location) {
|
public void onLocationChanged(Location location) {
|
||||||
|
locationPhoneGPS = location;
|
||||||
// 位置变化时的处理逻辑
|
// 位置变化时的处理逻辑
|
||||||
// double latitude = location.getLatitude();
|
// double latitude = location.getLatitude();
|
||||||
// double longitude = location.getLongitude();
|
// double longitude = location.getLongitude();
|
||||||
String szTemp = String.format("Latitude %f, Longitude %f, Accuracy %f", location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
String szTemp = String.format("Phone GPS MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", locationPhoneGPS.getLatitude(), locationPhoneGPS.getLongitude(), locationPhoneGPS.getAccuracy());
|
||||||
|
mtvPhoneMyLocationInfo.setText(szTemp);
|
||||||
LogUtils.d(TAG, szTemp);
|
LogUtils.d(TAG, szTemp);
|
||||||
|
updatePostionFixModel();
|
||||||
moveToLocation(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,10 +212,29 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
@Override
|
@Override
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void updatePostionFixModel() {
|
||||||
|
mPostionFixModel = PostionFixModel.loadPostionFixModel();
|
||||||
|
mPostionFixModel.setLatitudeFixModel(locationPhoneGPS.getLatitude() - locationTX.getLatitude());
|
||||||
|
mPostionFixModel.setLongitudeFixModel(locationPhoneGPS.getLongitude() - locationTX.getLongitude());
|
||||||
|
PostionFixModel.savePostionFixModel(mPostionFixModel);
|
||||||
|
String szTemp = String.format("PostionFixModel Info\nLatitude Fix %f, Longitude Fix %f", mPostionFixModel.getLatitudeFixModel(), mPostionFixModel.getLongitudeFixModel());
|
||||||
|
mtvPostionFixModelInfo.setText(szTemp);
|
||||||
|
LogUtils.d(TAG, szTemp);
|
||||||
|
|
||||||
|
// 在需要停止监听的地方(如onPause/onDestroy)添加:
|
||||||
|
if (locationManagerPhoneGPS != null) {
|
||||||
|
// 取消位置更新监听
|
||||||
|
locationManagerPhoneGPS.removeUpdates(phoneGPSLocationListener);
|
||||||
|
// 可选:停止后释放资源
|
||||||
|
phoneGPSLocationListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 创建Location对象方法
|
// 创建Location对象方法
|
||||||
private Location createLocationFromLatLng(double latitudeLock, double longitudeLock) {
|
private Location createTXLocationFromLatLng(double latitudeLock, double longitudeLock) {
|
||||||
Location location = new Location("Tencent_Map_Manual");
|
Location location = new Location("Tencent_Map_Manual");
|
||||||
|
|
||||||
// 设置基础坐标
|
// 设置基础坐标
|
||||||
@ -226,7 +250,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建Location对象方法
|
// 创建Location对象方法
|
||||||
private Location createLocationFromLatLng(LatLng latLng) {
|
private Location createTXLocationFromLatLng(LatLng latLng) {
|
||||||
Location location = new Location("Tencent_Map_Manual");
|
Location location = new Location("Tencent_Map_Manual");
|
||||||
|
|
||||||
// 设置基础坐标
|
// 设置基础坐标
|
||||||
@ -241,7 +265,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LatLng convertToLatLng(TencentLocation location) {
|
public static LatLng convertTencentLocationToLatLng(TencentLocation location) {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
double latitude = location.getLatitude();
|
double latitude = location.getLatitude();
|
||||||
double longitude = location.getLongitude();
|
double longitude = location.getLongitude();
|
||||||
@ -250,7 +274,7 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LatLng convertToLatLng(Location location) {
|
public static LatLng convertLocationToLatLng(Location location) {
|
||||||
return new LatLng(
|
return new LatLng(
|
||||||
location.getLatitude(),
|
location.getLatitude(),
|
||||||
location.getLongitude()
|
location.getLongitude()
|
||||||
@ -346,18 +370,36 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
|
|
||||||
public static void moveToLocation(double latitudeLock, double longitudeLock) {
|
public static void moveToLocation(double latitudeLock, double longitudeLock) {
|
||||||
if (_TXMSFragment != null) {
|
if (_TXMSFragment != null) {
|
||||||
Location location = _TXMSFragment.createLocationFromLatLng(latitudeLock, longitudeLock);
|
Location location = _TXMSFragment.createTXLocationFromLatLng(latitudeLock, longitudeLock);
|
||||||
_TXMSFragment.moveToLocation(location);
|
_TXMSFragment.moveToGPSLocation(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Location fixGPSLocationFromPostionFixModel(Location location) {
|
||||||
|
Location locationFix = new Location("GPS_Fix_Map_Manual");
|
||||||
|
|
||||||
private void moveToLocation(Location location) {
|
// 设置基础坐标
|
||||||
ToastUtils.show(String.format("%s", location.toString()));
|
locationFix.setLatitude(location.getLatitude() - mPostionFixModel.getLatitudeFixModel());
|
||||||
|
locationFix.setLongitude(location.getLongitude() - mPostionFixModel.getLongitudeFixModel());
|
||||||
|
|
||||||
|
// 设置必要元数据
|
||||||
|
location.setTime(System.currentTimeMillis());
|
||||||
|
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||||
|
location.setAccuracy(5.0f); // 手动点击精度设为5米
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveToGPSLocation(Location location) {
|
||||||
|
// 用腾讯定位数据与GPS定位数据的数据差修复模型,来修复一下GPS定位数据。
|
||||||
|
mPostionFixModel = PostionFixModel.loadPostionFixModel();
|
||||||
|
Location locationFix = fixGPSLocationFromPostionFixModel(location);
|
||||||
|
//ToastUtils.show(String.format("%s", locationFix.toString()));
|
||||||
|
|
||||||
//对地图操作类进行操作
|
//对地图操作类进行操作
|
||||||
CameraUpdate cameraSigma =
|
CameraUpdate cameraSigma =
|
||||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||||
convertToLatLng(location),
|
convertLocationToLatLng(locationFix),
|
||||||
15,
|
15,
|
||||||
0f,
|
0f,
|
||||||
0f));
|
0f));
|
||||||
@ -385,13 +427,13 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
||||||
|
|
||||||
if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
|
if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
|
||||||
final Location location = new Location(tencentLocation.getProvider());
|
locationTX = new Location(tencentLocation.getProvider());
|
||||||
//设置经纬度以及精度
|
//设置经纬度以及精度
|
||||||
location.setLatitude(tencentLocation.getLatitude());
|
locationTX.setLatitude(tencentLocation.getLatitude());
|
||||||
location.setLongitude(tencentLocation.getLongitude());
|
locationTX.setLongitude(tencentLocation.getLongitude());
|
||||||
location.setAccuracy(tencentLocation.getAccuracy());
|
locationTX.setAccuracy(tencentLocation.getAccuracy());
|
||||||
|
|
||||||
locationChangedListener.onLocationChanged(location);
|
locationChangedListener.onLocationChanged(locationTX);
|
||||||
|
|
||||||
//显示回调的实时位置信息
|
//显示回调的实时位置信息
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@ -414,11 +456,20 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
// locationB.getLatitude(),
|
// locationB.getLatitude(),
|
||||||
// locationB.getLongitude()
|
// locationB.getLongitude()
|
||||||
// );
|
// );
|
||||||
String szTemp = String.format("Latitude %f, Longitude %f, Accuracy %f", location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
String szTemp = String.format("TX MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", locationTX.getLatitude(), locationTX.getLongitude(), locationTX.getAccuracy());
|
||||||
mtvInfo.setText(szTemp);
|
mtvTXMyLocationInfo.setText(szTemp);
|
||||||
LogUtils.d(TAG, szTemp);
|
LogUtils.d(TAG, szTemp);
|
||||||
//打印tencentLocation的json字符串
|
//打印tencentLocation的json字符串
|
||||||
// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 本机 GPS 定位服务调用服务
|
||||||
|
//
|
||||||
|
locationManagerPhoneGPS = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
|
||||||
|
String provider = LocationManager.GPS_PROVIDER;
|
||||||
|
//Location location = locationManager.getLastKnownLocation(provider);
|
||||||
|
locationManagerPhoneGPS.requestLocationUpdates(provider, 2000, 10, phoneGPSLocationListener);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -434,9 +485,9 @@ public class TXMSFragment extends Fragment implements /*EasyPermissions.Permissi
|
|||||||
mTencentLocationManager.removeUpdates(this);
|
mTencentLocationManager.removeUpdates(this);
|
||||||
}
|
}
|
||||||
// 关闭当前位置显示
|
// 关闭当前位置显示
|
||||||
// if (tencentMap != null) {
|
if (tencentMap != null) {
|
||||||
// tencentMap.setMyLocationEnabled(false);
|
tencentMap.setMyLocationEnabled(false);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
package cc.winboll.studio.positions.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
|
* @Date 2025/03/21 10:11:36
|
||||||
|
* @Describe 定位数据修正模型
|
||||||
|
*/
|
||||||
|
import android.location.Location;
|
||||||
|
import android.util.JsonReader;
|
||||||
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
|
import java.io.IOException;
|
||||||
|
import android.content.Context;
|
||||||
|
import cc.winboll.studio.positions.App;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class PostionFixModel extends BaseBean {
|
||||||
|
|
||||||
|
public static final String TAG = "PostionFixModel";
|
||||||
|
|
||||||
|
// 纬度校验数据模型
|
||||||
|
private double latitudeFixModel;
|
||||||
|
// 经度校验数据模型
|
||||||
|
private double longitudeFixModel;
|
||||||
|
|
||||||
|
public PostionFixModel() {
|
||||||
|
this.latitudeFixModel = 0;
|
||||||
|
this.longitudeFixModel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PostionFixModel(double latitudeFixModel, double longitudeFixModel) {
|
||||||
|
this.latitudeFixModel = latitudeFixModel;
|
||||||
|
this.longitudeFixModel = longitudeFixModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitudeFixModel(double latitudeFixModel) {
|
||||||
|
this.latitudeFixModel = latitudeFixModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLatitudeFixModel() {
|
||||||
|
return latitudeFixModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitudeFixModel(double longitudeFixModel) {
|
||||||
|
this.longitudeFixModel = longitudeFixModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLongitudeFixModel() {
|
||||||
|
return longitudeFixModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return PostionFixModel.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
|
jsonWriter.name("latitudeFixModel").value(getLatitudeFixModel());
|
||||||
|
jsonWriter.name("longitudeFixModel").value(getLongitudeFixModel());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
|
if (name.equals("latitudeFixModel")) {
|
||||||
|
setLatitudeFixModel(jsonReader.nextDouble());
|
||||||
|
} else if (name.equals("longitudeFixModel")) {
|
||||||
|
setLongitudeFixModel(jsonReader.nextDouble());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||||
|
jsonReader.beginObject();
|
||||||
|
while (jsonReader.hasNext()) {
|
||||||
|
String name = jsonReader.nextName();
|
||||||
|
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||||
|
jsonReader.skipValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 结束 JSON 对象
|
||||||
|
jsonReader.endObject();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void savePostionFixModel(PostionFixModel model) {
|
||||||
|
saveBeanToFile(getPostionFixModelDataPath(), model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PostionFixModel loadPostionFixModel() {
|
||||||
|
PostionFixModel model = loadBeanFromFile(getPostionFixModelDataPath(), PostionFixModel.class);
|
||||||
|
if(model == null) {
|
||||||
|
model = new PostionFixModel();
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getPostionFixModelDataPath() {
|
||||||
|
return App.szDataFolder + File.separator + TAG + ".data";
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,6 @@ package cc.winboll.studio.positions.models;
|
|||||||
* @Date 2025/02/25 02:58:33
|
* @Date 2025/02/25 02:58:33
|
||||||
* @Describe LocationJson
|
* @Describe LocationJson
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
import cc.winboll.studio.libappbase.BaseBean;
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
|
@ -1,34 +1,66 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<com.tencent.tencentmap.mapsdk.maps.TextureMapView
|
<RelativeLayout
|
||||||
android:id="@+id/mapview"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<TextView
|
<com.tencent.tencentmap.mapsdk.maps.TextureMapView
|
||||||
android:id="@+id/tv_info"
|
android:id="@+id/mapview"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"/>
|
||||||
android:textColor="@color/colorPrimary"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:background="#CAFFFFFF"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentRight="true">
|
|
||||||
|
|
||||||
</TextView>
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txmylocationinfo_tv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:background="#C0FFFFFF">
|
||||||
|
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/phonemylocationinfo_tv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:background="#C0FFFFFF"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/postionfixmodelinfo_tv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/colorPrimary"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:background="#C0FFFFFF"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user