国内经纬度转换后反地理显示
This commit is contained in:
@@ -98,6 +98,9 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(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>(FragmentMapV3Binding::i
|
||||
if (mPetList.size == 0) {
|
||||
return
|
||||
}
|
||||
needGpsToGCJ02 = true
|
||||
mCountDownTimerViewModel.isStartCountDown = false
|
||||
mCurrentShowPetPos = position
|
||||
|
||||
@@ -564,8 +568,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
mHomeMapCommon.switchShowLocation(ConstantInt.UserLocationType)
|
||||
} else {
|
||||
//判断是否国内经纬度,需要坐标转换
|
||||
if (needGpsToGCJ02) {
|
||||
needGpsToGCJ02 = false
|
||||
val isOutOfChina = LonAndLatUtil.isLocationOutOfChina(latitude, longitude)
|
||||
MMKVUtil.putBoolean(MMKVKey.isGpsToGCJ02, !isOutOfChina)
|
||||
}
|
||||
mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera)
|
||||
isMoveCamera = false
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user