From 1bc92e860f7e95a95866a40c38bc6d3be01be46c Mon Sep 17 00:00:00 2001 From: yezhiqiu <983577727@qq.com> Date: Wed, 11 Mar 2026 11:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E5=86=85=E7=BB=8F=E7=BA=AC=E5=BA=A6?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E5=90=8E=E5=8F=8D=E5=9C=B0=E7=90=86=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abbidot/tracker/ui/fragment/map/MapV3Fragment.kt | 11 +++++++++-- .../java/com/abbidot/tracker/vm/GeoCoderViewModel.kt | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt index 58dcca9..b66a104 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/map/MapV3Fragment.kt @@ -98,6 +98,9 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i //是否可用直播 private var isCanLive = false + //是否需要gps坐标转火星坐标 + private var needGpsToGCJ02 = true + companion object { @JvmStatic fun newInstance(context: Context) = MapV3Fragment().apply { @@ -507,6 +510,7 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i if (mPetList.size == 0) { return } + needGpsToGCJ02 = true mCountDownTimerViewModel.isStartCountDown = false mCurrentShowPetPos = position @@ -564,8 +568,11 @@ class MapV3Fragment : BaseFragment(FragmentMapV3Binding::i mHomeMapCommon.switchShowLocation(ConstantInt.UserLocationType) } else { //判断是否国内经纬度,需要坐标转换 - val isOutOfChina = LonAndLatUtil.isLocationOutOfChina(latitude, longitude) - MMKVUtil.putBoolean(MMKVKey.isGpsToGCJ02, !isOutOfChina) + if (needGpsToGCJ02) { + needGpsToGCJ02 = false + val isOutOfChina = LonAndLatUtil.isLocationOutOfChina(latitude, longitude) + MMKVUtil.putBoolean(MMKVKey.isGpsToGCJ02, !isOutOfChina) + } mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera) isMoveCamera = false } diff --git a/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt b/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt index 6f6536a..e8dfa89 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/GeoCoderViewModel.kt @@ -74,8 +74,7 @@ class GeoCoderViewModel : ViewModel() { baiduMapReverseGeocoder(latitude, longitude) } else { if (MMKVUtil.getBoolean(MMKVKey.isGpsToGCJ02)) { - val convertLatLon = LonAndLatUtil.convertFromWGS84ToGCJ02(latitude, longitude) - mapBoxReverseGeocoder(convertLatLon[0], convertLatLon[1]) + baiduMapReverseGeocoder(latitude, longitude) } else { mapBoxReverseGeocoder(latitude, longitude) }