国内经纬度转换后反地理显示
This commit is contained in:
@@ -98,6 +98,9 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
|||||||
//是否可用直播
|
//是否可用直播
|
||||||
private var isCanLive = false
|
private var isCanLive = false
|
||||||
|
|
||||||
|
//是否需要gps坐标转火星坐标
|
||||||
|
private var needGpsToGCJ02 = true
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newInstance(context: Context) = MapV3Fragment().apply {
|
fun newInstance(context: Context) = MapV3Fragment().apply {
|
||||||
@@ -507,6 +510,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
|||||||
if (mPetList.size == 0) {
|
if (mPetList.size == 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
needGpsToGCJ02 = true
|
||||||
mCountDownTimerViewModel.isStartCountDown = false
|
mCountDownTimerViewModel.isStartCountDown = false
|
||||||
mCurrentShowPetPos = position
|
mCurrentShowPetPos = position
|
||||||
|
|
||||||
@@ -564,8 +568,11 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
|||||||
mHomeMapCommon.switchShowLocation(ConstantInt.UserLocationType)
|
mHomeMapCommon.switchShowLocation(ConstantInt.UserLocationType)
|
||||||
} else {
|
} else {
|
||||||
//判断是否国内经纬度,需要坐标转换
|
//判断是否国内经纬度,需要坐标转换
|
||||||
|
if (needGpsToGCJ02) {
|
||||||
|
needGpsToGCJ02 = false
|
||||||
val isOutOfChina = LonAndLatUtil.isLocationOutOfChina(latitude, longitude)
|
val isOutOfChina = LonAndLatUtil.isLocationOutOfChina(latitude, longitude)
|
||||||
MMKVUtil.putBoolean(MMKVKey.isGpsToGCJ02, !isOutOfChina)
|
MMKVUtil.putBoolean(MMKVKey.isGpsToGCJ02, !isOutOfChina)
|
||||||
|
}
|
||||||
mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera)
|
mHomeMapCommon.refreshPetCurrentLocation(latitude, longitude, isMoveCamera)
|
||||||
isMoveCamera = false
|
isMoveCamera = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ class GeoCoderViewModel : ViewModel() {
|
|||||||
baiduMapReverseGeocoder(latitude, longitude)
|
baiduMapReverseGeocoder(latitude, longitude)
|
||||||
} else {
|
} else {
|
||||||
if (MMKVUtil.getBoolean(MMKVKey.isGpsToGCJ02)) {
|
if (MMKVUtil.getBoolean(MMKVKey.isGpsToGCJ02)) {
|
||||||
val convertLatLon = LonAndLatUtil.convertFromWGS84ToGCJ02(latitude, longitude)
|
baiduMapReverseGeocoder(latitude, longitude)
|
||||||
mapBoxReverseGeocoder(convertLatLon[0], convertLatLon[1])
|
|
||||||
} else {
|
} else {
|
||||||
mapBoxReverseGeocoder(latitude, longitude)
|
mapBoxReverseGeocoder(latitude, longitude)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user