优化谷歌百度地图光波会卡顿问题
This commit is contained in:
@@ -28,9 +28,9 @@ android {
|
|||||||
applicationId "com.abbidot.tracker"
|
applicationId "com.abbidot.tracker"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode 2601
|
versionCode 2606
|
||||||
// versionName "2.6.1"
|
// versionName "2.6.6"
|
||||||
versionName "2.6.1-Beta4"
|
versionName "2.6.6-Beta1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class HistoryDataMapCommon : BaseMapCommon() {
|
|||||||
|
|
||||||
fun resetMarkerInfoViewOffset() {
|
fun resetMarkerInfoViewOffset() {
|
||||||
mHistoryDataGoogleMapFragment?.resetMarkerInfoViewOffset()
|
mHistoryDataGoogleMapFragment?.resetMarkerInfoViewOffset()
|
||||||
|
mHistoryDataBaiduMapFragment?.resetMarkerInfoViewOffset()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPetUserLatLng() {
|
fun setPetUserLatLng() {
|
||||||
|
|||||||
@@ -24,15 +24,12 @@ import com.abbidot.tracker.R
|
|||||||
import com.abbidot.tracker.base.BaseFragment
|
import com.abbidot.tracker.base.BaseFragment
|
||||||
import com.abbidot.tracker.bean.FencesBean
|
import com.abbidot.tracker.bean.FencesBean
|
||||||
import com.abbidot.tracker.bean.HistoryDataBean
|
import com.abbidot.tracker.bean.HistoryDataBean
|
||||||
import com.abbidot.tracker.bean.MapDeviceBean
|
|
||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.databinding.FragmentBaseBaiduMapBinding
|
import com.abbidot.tracker.databinding.FragmentBaseBaiduMapBinding
|
||||||
import com.abbidot.tracker.ui.fragment.map.googlemap.GoogleBitmapHelper
|
import com.abbidot.tracker.ui.fragment.map.googlemap.GoogleBitmapHelper
|
||||||
import com.abbidot.tracker.util.ImageUtil
|
import com.abbidot.tracker.util.ImageUtil
|
||||||
import com.abbidot.tracker.util.LonAndLatUtil
|
import com.abbidot.tracker.util.LonAndLatUtil
|
||||||
import com.abbidot.tracker.util.Util.Companion.safeRecycle
|
import com.abbidot.tracker.util.Util.Companion.safeRecycle
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
|
||||||
import com.abbidot.tracker.widget.MapMarkerInfoView
|
|
||||||
import com.abbidot.tracker.widget.TypefaceTextView
|
import com.abbidot.tracker.widget.TypefaceTextView
|
||||||
import com.baidu.location.BDLocation
|
import com.baidu.location.BDLocation
|
||||||
import com.baidu.mapapi.map.BaiduMap
|
import com.baidu.mapapi.map.BaiduMap
|
||||||
@@ -939,31 +936,6 @@ abstract class BaseBaiduMapFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置Marker弹窗设备电量的位置
|
|
||||||
*/
|
|
||||||
fun setMapDeviceBatteryOffset(
|
|
||||||
viewGroup: ViewGroup, latLng: LatLng, mapDeviceBean: MapDeviceBean
|
|
||||||
) {
|
|
||||||
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
|
||||||
viewGroup.x = it.x.toFloat() - viewGroup.width / 2 + AppUtils.dpToPx(5)
|
|
||||||
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
|
||||||
if (mapDeviceBean.canShowBattery && !mapDeviceBean.isCloseBattery) ViewUtil.instance.viewShow(
|
|
||||||
viewGroup
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置Marker弹窗消息的位置
|
|
||||||
*/
|
|
||||||
fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
|
||||||
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
|
||||||
ViewUtil.instance.viewShow(markerInfoView)
|
|
||||||
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param needConvertGCJ02 是否需要转换GCJ02坐标/国内火星坐标
|
* @param needConvertGCJ02 是否需要转换GCJ02坐标/国内火星坐标
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.graphics.Typeface
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.AppCompatSeekBar
|
import androidx.appcompat.widget.AppCompatSeekBar
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import com.abbidot.baselibrary.constant.MMKVKey
|
import com.abbidot.baselibrary.constant.MMKVKey
|
||||||
import com.abbidot.baselibrary.util.AppUtils
|
import com.abbidot.baselibrary.util.AppUtils
|
||||||
import com.abbidot.baselibrary.util.LogUtil
|
import com.abbidot.baselibrary.util.LogUtil
|
||||||
@@ -16,8 +15,10 @@ import com.abbidot.tracker.bean.HistoryDataBean
|
|||||||
import com.abbidot.tracker.bean.PetBean
|
import com.abbidot.tracker.bean.PetBean
|
||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.ui.fragment.map.googlemap.GoogleBitmapHelper
|
import com.abbidot.tracker.ui.fragment.map.googlemap.GoogleBitmapHelper
|
||||||
|
import com.abbidot.tracker.util.LonAndLatUtil
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.GeoCoderViewModel
|
import com.abbidot.tracker.vm.GeoCoderViewModel
|
||||||
|
import com.abbidot.tracker.widget.MapMarkerInfoView
|
||||||
import com.baidu.mapapi.map.BaiduMap
|
import com.baidu.mapapi.map.BaiduMap
|
||||||
import com.baidu.mapapi.map.BitmapDescriptor
|
import com.baidu.mapapi.map.BitmapDescriptor
|
||||||
import com.baidu.mapapi.map.BitmapDescriptorFactory
|
import com.baidu.mapapi.map.BitmapDescriptorFactory
|
||||||
@@ -48,6 +49,8 @@ class HistoryDataBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
private var isMapSnapshot = true
|
private var isMapSnapshot = true
|
||||||
|
|
||||||
private lateinit var mMapLoadOk: () -> Unit
|
private lateinit var mMapLoadOk: () -> Unit
|
||||||
|
|
||||||
|
//当前位置火星坐标
|
||||||
private var mCurLatLng: LatLng? = null
|
private var mCurLatLng: LatLng? = null
|
||||||
private var mPetBean: PetBean? = null
|
private var mPetBean: PetBean? = null
|
||||||
|
|
||||||
@@ -189,21 +192,30 @@ class HistoryDataBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mGeoCoderViewModel.getLatLonAddress(
|
mGeoCoderViewModel.getLatLonAddress(
|
||||||
mLatLngList[maxIndex].latitude, mLatLngList[maxIndex].longitude, false
|
data[maxIndex].latitude, data[maxIndex].longitude, false
|
||||||
)
|
)
|
||||||
setMapAddressLocationOffset(mMarkerInfoView, mLatLngList[maxIndex])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置Marker弹窗设备电量的位置
|
* 设置Marker弹窗设备电量的位置
|
||||||
*/
|
*/
|
||||||
fun setMapAddressLocationOffset(viewGroup: ViewGroup, latLng: LatLng) {
|
private fun setMapAddressLocationOffset(viewGroup: ViewGroup, latLng: LatLng) {
|
||||||
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
||||||
viewGroup.x = it.x.toFloat() - viewGroup.width / 2 + AppUtils.dpToPx(5)
|
viewGroup.x = it.x.toFloat() - viewGroup.width / 2
|
||||||
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Marker弹窗消息的位置
|
||||||
|
*/
|
||||||
|
private fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
||||||
|
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
||||||
|
ViewUtil.instance.viewShow(markerInfoView)
|
||||||
|
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setPetBean(petBean: PetBean) {
|
suspend fun setPetBean(petBean: PetBean) {
|
||||||
if (mPetBean?.petId == petBean.petId) {
|
if (mPetBean?.petId == petBean.petId) {
|
||||||
return
|
return
|
||||||
@@ -225,7 +237,7 @@ class HistoryDataBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
|
|
||||||
fun resetMarkerInfoViewOffset() {
|
fun resetMarkerInfoViewOffset() {
|
||||||
mCurLatLng?.let {
|
mCurLatLng?.let {
|
||||||
if (mMarkerInfoView.isVisible) setMapAddressLocationOffset(mMarkerInfoView, it)
|
setMapAddressLocationOffset(mMarkerInfoView, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,12 +258,14 @@ class HistoryDataBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
needConvertGCJ02 = false,
|
needConvertGCJ02 = false,
|
||||||
isAnimMoveCamera = true
|
isAnimMoveCamera = true
|
||||||
)
|
)
|
||||||
mGeoCoderViewModel.getLatLonAddress(
|
|
||||||
mLatLngList[progress].latitude, mLatLngList[progress].longitude, false
|
|
||||||
)
|
|
||||||
|
|
||||||
|
val gpsLatLng = LonAndLatUtil.convertFromGCJ02ToWGS84(
|
||||||
|
mLatLngList[progress].latitude,
|
||||||
|
mLatLngList[progress].longitude
|
||||||
|
)
|
||||||
mCurLatLng = mLatLngList[progress]
|
mCurLatLng = mLatLngList[progress]
|
||||||
setMapAddressLocationOffset(mMarkerInfoView, mLatLngList[progress])
|
mGeoCoderViewModel.getLatLonAddress(gpsLatLng[0], gpsLatLng[1], false)
|
||||||
|
resetMarkerInfoViewOffset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.abbidot.tracker.vm.GeoCoderViewModel
|
|||||||
import com.baidu.location.BDLocation
|
import com.baidu.location.BDLocation
|
||||||
import com.baidu.mapapi.map.BaiduMap
|
import com.baidu.mapapi.map.BaiduMap
|
||||||
import com.baidu.mapapi.map.BitmapDescriptor
|
import com.baidu.mapapi.map.BitmapDescriptor
|
||||||
|
import com.baidu.mapapi.map.Circle
|
||||||
import com.baidu.mapapi.map.CircleOptions
|
import com.baidu.mapapi.map.CircleOptions
|
||||||
import com.baidu.mapapi.map.MapStatus
|
import com.baidu.mapapi.map.MapStatus
|
||||||
import com.baidu.mapapi.map.MapStatusUpdateFactory
|
import com.baidu.mapapi.map.MapStatusUpdateFactory
|
||||||
@@ -42,7 +43,6 @@ import com.baidu.mapapi.map.Stroke
|
|||||||
import com.baidu.mapapi.model.LatLng
|
import com.baidu.mapapi.model.LatLng
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.pow
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,15 +71,15 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
//是否是地图摄像头移动了
|
//是否是地图摄像头移动了
|
||||||
private var isMapCameraMove = false
|
private var isMapCameraMove = false
|
||||||
|
|
||||||
private var mRippleCircle: Overlay? = null
|
private var mRippleCircle: Circle? = null
|
||||||
private var mValueAnimator: ValueAnimator? = null
|
private var mValueAnimator: ValueAnimator? = null
|
||||||
private var mRippleCirclePercent = 0.0
|
private var mRippleCirclePercent = 0.0
|
||||||
private var mRippleCircleRadius = 200
|
private val mRippleCircleRadius = AppUtils.dpToPx(20)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水波纹圆的颜色
|
* 水波纹圆的颜色
|
||||||
*/
|
*/
|
||||||
private var mRippleCircleColor: Int = R.color.black10
|
private var mRippleCircleColor = R.color.black10
|
||||||
|
|
||||||
private val mOtherPetMarkerList = mutableListOf<Overlay?>()
|
private val mOtherPetMarkerList = mutableListOf<Overlay?>()
|
||||||
|
|
||||||
@@ -292,6 +292,21 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Marker弹窗设备电量的位置
|
||||||
|
*/
|
||||||
|
private fun setMapDeviceBatteryOffset(
|
||||||
|
viewGroup: ViewGroup, latLng: LatLng, mapDeviceBean: MapDeviceBean
|
||||||
|
) {
|
||||||
|
mBaiduMap?.projection?.toScreenLocation(latLng)?.let {
|
||||||
|
viewGroup.x = it.x.toFloat() - viewGroup.width / 2 + AppUtils.dpToPx(5)
|
||||||
|
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
||||||
|
if (mapDeviceBean.canShowBattery && !mapDeviceBean.isCloseBattery) ViewUtil.instance.viewShow(
|
||||||
|
viewGroup
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var mUserAndPetLine: Overlay? = null
|
private var mUserAndPetLine: Overlay? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -330,14 +345,28 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
private fun addRippleCircle() {
|
private fun addRippleCircle() {
|
||||||
getPetLatLng()?.apply {
|
getPetLatLng()?.apply {
|
||||||
mBaiduMap?.let {
|
mBaiduMap?.let {
|
||||||
mRippleCircle?.remove()
|
if (null == mRippleCircle) {
|
||||||
val sColor = ContextCompat.getColor(mContext!!, mRippleCircleColor)
|
val sColor = ContextCompat.getColor(mContext!!, mRippleCircleColor)
|
||||||
mRippleCircle = it.addOverlay(
|
val overlay = it.addOverlay(
|
||||||
CircleOptions().center(this)
|
CircleOptions().center(this)
|
||||||
.radius((mRippleCircleRadius * mRippleCirclePercent).toInt()).stroke(
|
.radius((mRippleCircleRadius * mRippleCirclePercent).toInt()).stroke(
|
||||||
Stroke(AppUtils.dpToPx(1), sColor)
|
Stroke(AppUtils.dpToPx(1), sColor)
|
||||||
).fillColor(sColor)
|
).fillColor(sColor)
|
||||||
)
|
)
|
||||||
|
mRippleCircle = overlay as Circle
|
||||||
|
} else {
|
||||||
|
mRippleCircle?.let { c ->
|
||||||
|
if (mRippleCircleColor != R.color.black10) {
|
||||||
|
val sColor = ContextCompat.getColor(mContext!!, mRippleCircleColor)
|
||||||
|
c.fillColor = sColor
|
||||||
|
c.stroke = Stroke(AppUtils.dpToPx(1), sColor)
|
||||||
|
}
|
||||||
|
if (!c.isVisible) c.isVisible = true
|
||||||
|
c.center = this
|
||||||
|
c.radius =
|
||||||
|
(mRippleCircleRadius * mRippleCirclePercent).toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,7 +377,7 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
private fun setRippleCircleAnim() {
|
private fun setRippleCircleAnim() {
|
||||||
if (null == mValueAnimator) {
|
if (null == mValueAnimator) {
|
||||||
mValueAnimator = ViewUtil.instance.setValueAnimator(
|
mValueAnimator = ViewUtil.instance.setValueAnimator(
|
||||||
0.0, 100.0, 1500, LinearInterpolator()
|
0.0, 100.0, 900, LinearInterpolator()
|
||||||
) {
|
) {
|
||||||
mRippleCirclePercent = it.animatedValue as Float / 100.0
|
mRippleCirclePercent = it.animatedValue as Float / 100.0
|
||||||
addRippleCircle()
|
addRippleCircle()
|
||||||
@@ -369,8 +398,8 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
fun startRippleCircleAnim() {
|
fun startRippleCircleAnim() {
|
||||||
getPetLatLng()?.apply {
|
getPetLatLng()?.apply {
|
||||||
//一像素对应几米
|
//一像素对应几米
|
||||||
val pxDis = 2.0.pow(17.0 - getBaiduMapZoom())
|
// val pxDis = 2.0.pow(17.0 - getBaiduMapZoom())
|
||||||
mRippleCircleRadius = (pxDis * 150).toInt()
|
// mRippleCircleRadius = (pxDis * 200).toInt()
|
||||||
setRippleCircleAnim()
|
setRippleCircleAnim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,8 +426,7 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
|||||||
|
|
||||||
fun clearRippleCircleAnim() {
|
fun clearRippleCircleAnim() {
|
||||||
mValueAnimator?.cancel()
|
mValueAnimator?.cancel()
|
||||||
mRippleCircle?.remove()
|
mRippleCircle?.isVisible = false
|
||||||
mRippleCircle = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@ import com.abbidot.tracker.R
|
|||||||
import com.abbidot.tracker.base.BaseFragment
|
import com.abbidot.tracker.base.BaseFragment
|
||||||
import com.abbidot.tracker.bean.FencesBean
|
import com.abbidot.tracker.bean.FencesBean
|
||||||
import com.abbidot.tracker.bean.HistoryDataBean
|
import com.abbidot.tracker.bean.HistoryDataBean
|
||||||
import com.abbidot.tracker.bean.MapDeviceBean
|
|
||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.databinding.FragmentGoogleMapBinding
|
import com.abbidot.tracker.databinding.FragmentGoogleMapBinding
|
||||||
import com.abbidot.tracker.util.ImageUtil
|
import com.abbidot.tracker.util.ImageUtil
|
||||||
import com.abbidot.tracker.util.LonAndLatUtil
|
import com.abbidot.tracker.util.LonAndLatUtil
|
||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
|
||||||
import com.abbidot.tracker.widget.MapDeviceNetView
|
|
||||||
import com.abbidot.tracker.widget.MapMarkerInfoView
|
|
||||||
import com.google.android.gms.maps.CameraUpdate
|
import com.google.android.gms.maps.CameraUpdate
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory
|
import com.google.android.gms.maps.CameraUpdateFactory
|
||||||
import com.google.android.gms.maps.GoogleMap
|
import com.google.android.gms.maps.GoogleMap
|
||||||
@@ -1132,44 +1128,6 @@ abstract class BaseGoogleMapFragment :
|
|||||||
return zoom
|
return zoom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置Marker弹窗消息的位置
|
|
||||||
*/
|
|
||||||
fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
|
||||||
val newLatLng = toGCJ02LatLon(latLng)
|
|
||||||
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
|
||||||
ViewUtil.instance.viewShow(markerInfoView)
|
|
||||||
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置Marker弹窗设备电量的位置
|
|
||||||
*/
|
|
||||||
fun setMapDeviceBatteryOffset(
|
|
||||||
viewGroup: ViewGroup, latLng: LatLng, mapDeviceBean: MapDeviceBean
|
|
||||||
) {
|
|
||||||
val newLatLng = toGCJ02LatLon(latLng)
|
|
||||||
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
|
||||||
viewGroup.x = it.x.toFloat() - viewGroup.width / 2 + AppUtils.dpToPx(5)
|
|
||||||
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
|
||||||
if (mapDeviceBean.canShowBattery && !mapDeviceBean.isCloseBattery) ViewUtil.instance.viewShow(
|
|
||||||
viewGroup
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置地图网络类型显示位置
|
|
||||||
*/
|
|
||||||
fun setMapNetTypeViewOffset(mapDeviceNetView: MapDeviceNetView, latLng: LatLng) {
|
|
||||||
mGoogleMap?.projection?.toScreenLocation(latLng)?.let {
|
|
||||||
mapDeviceNetView.visibility = View.VISIBLE
|
|
||||||
mapDeviceNetView.setOffsetXY(it.x + AppUtils.dpToPx(11), it.y - AppUtils.dpToPx(56))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换国内火星坐标
|
* 转换国内火星坐标
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.abbidot.tracker.bean.PetBean
|
|||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.GeoCoderViewModel
|
import com.abbidot.tracker.vm.GeoCoderViewModel
|
||||||
|
import com.abbidot.tracker.widget.MapMarkerInfoView
|
||||||
import com.google.android.gms.maps.GoogleMap
|
import com.google.android.gms.maps.GoogleMap
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptor
|
import com.google.android.gms.maps.model.BitmapDescriptor
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
||||||
@@ -124,10 +125,9 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置Marker弹窗 的位置
|
* 设置地址和距离弹窗位置
|
||||||
*/
|
*/
|
||||||
fun setMapAddressLocationOffset(viewGroup: ViewGroup, latLng: LatLng) {
|
private fun setMapAddressLocationOffset(viewGroup: ViewGroup, latLng: LatLng) {
|
||||||
LogUtil.e("xxxx $latLng},${viewGroup.width},${viewGroup.height}")
|
|
||||||
val newLatLng = toGCJ02LatLon(latLng)
|
val newLatLng = toGCJ02LatLon(latLng)
|
||||||
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
||||||
viewGroup.x = it.x.toFloat() - viewGroup.width / 2
|
viewGroup.x = it.x.toFloat() - viewGroup.width / 2
|
||||||
@@ -135,6 +135,17 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Marker弹窗消息的位置
|
||||||
|
*/
|
||||||
|
private fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
||||||
|
val newLatLng = toGCJ02LatLon(latLng)
|
||||||
|
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
||||||
|
ViewUtil.instance.viewShow(markerInfoView)
|
||||||
|
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setPetBean(petBean: PetBean) {
|
suspend fun setPetBean(petBean: PetBean) {
|
||||||
if (mPetBean?.petId == petBean.petId) {
|
if (mPetBean?.petId == petBean.petId) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.abbidot.tracker.databinding.LayoutPetLocationInfoBinding
|
|||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.GeoCoderViewModel
|
import com.abbidot.tracker.vm.GeoCoderViewModel
|
||||||
|
import com.abbidot.tracker.widget.MapDeviceNetView
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory
|
import com.google.android.gms.maps.CameraUpdateFactory
|
||||||
import com.google.android.gms.maps.GoogleMap
|
import com.google.android.gms.maps.GoogleMap
|
||||||
import com.google.android.gms.maps.model.Circle
|
import com.google.android.gms.maps.model.Circle
|
||||||
@@ -33,7 +34,6 @@ import com.google.android.gms.maps.model.MarkerOptions
|
|||||||
import com.google.android.gms.maps.model.Polyline
|
import com.google.android.gms.maps.model.Polyline
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.pow
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Created by .yzq on 2022/1/13/013.
|
*Created by .yzq on 2022/1/13/013.
|
||||||
@@ -59,7 +59,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
private var mRippleCircle: Circle? = null
|
private var mRippleCircle: Circle? = null
|
||||||
private var mValueAnimator: ValueAnimator? = null
|
private var mValueAnimator: ValueAnimator? = null
|
||||||
private var mRippleCirclePercent = 0.0
|
private var mRippleCirclePercent = 0.0
|
||||||
private var mRippleCircleRadius = 200
|
private val mRippleCircleRadius = AppUtils.dpToPx(20)
|
||||||
|
|
||||||
//是否是地图摄像头移动了
|
//是否是地图摄像头移动了
|
||||||
private var isMapCameraMove = false
|
private var isMapCameraMove = false
|
||||||
@@ -218,6 +218,32 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Marker弹窗设备电量的位置
|
||||||
|
*/
|
||||||
|
private fun setMapDeviceBatteryOffset(
|
||||||
|
viewGroup: ViewGroup, latLng: LatLng, mapDeviceBean: MapDeviceBean
|
||||||
|
) {
|
||||||
|
val newLatLng = toGCJ02LatLon(latLng)
|
||||||
|
mGoogleMap?.projection?.toScreenLocation(newLatLng)?.let {
|
||||||
|
viewGroup.x = it.x.toFloat() - viewGroup.width / 2 + AppUtils.dpToPx(5)
|
||||||
|
viewGroup.y = it.y.toFloat() - AppUtils.dpToPx(56) - viewGroup.height
|
||||||
|
if (mapDeviceBean.canShowBattery && !mapDeviceBean.isCloseBattery) ViewUtil.instance.viewShow(
|
||||||
|
viewGroup
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置地图网络类型显示位置
|
||||||
|
*/
|
||||||
|
private fun setMapNetTypeViewOffset(mapDeviceNetView: MapDeviceNetView, latLng: LatLng) {
|
||||||
|
mGoogleMap?.projection?.toScreenLocation(latLng)?.let {
|
||||||
|
mapDeviceNetView.visibility = View.VISIBLE
|
||||||
|
mapDeviceNetView.setOffsetXY(it.x + AppUtils.dpToPx(11), it.y - AppUtils.dpToPx(56))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算用户和宠物的距离
|
* 计算用户和宠物的距离
|
||||||
*/
|
*/
|
||||||
@@ -272,7 +298,6 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
.fillColor(ContextCompat.getColor(mContext!!, R.color.black10))
|
.fillColor(ContextCompat.getColor(mContext!!, R.color.black10))
|
||||||
.strokeColor(ContextCompat.getColor(mContext!!, R.color.black10))
|
.strokeColor(ContextCompat.getColor(mContext!!, R.color.black10))
|
||||||
)
|
)
|
||||||
|
|
||||||
setRippleCircleAnim()
|
setRippleCircleAnim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +310,7 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
private fun setRippleCircleAnim() {
|
private fun setRippleCircleAnim() {
|
||||||
if (null == mValueAnimator) {
|
if (null == mValueAnimator) {
|
||||||
mValueAnimator = ViewUtil.instance.setValueAnimator(
|
mValueAnimator = ViewUtil.instance.setValueAnimator(
|
||||||
0.0, 100.0, 1500, LinearInterpolator()
|
0.0, 100.0, 1000, LinearInterpolator()
|
||||||
) {
|
) {
|
||||||
mRippleCirclePercent = it.animatedValue as Float / 100.0
|
mRippleCirclePercent = it.animatedValue as Float / 100.0
|
||||||
mRippleCircle?.apply {
|
mRippleCircle?.apply {
|
||||||
@@ -352,7 +377,6 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// addPolyLines(mGoogleMap!!, latLngList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -361,9 +385,8 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
fun startRippleCircleAnim() {
|
fun startRippleCircleAnim() {
|
||||||
getPetLatLng()?.apply {
|
getPetLatLng()?.apply {
|
||||||
//一像素对应几米
|
//一像素对应几米
|
||||||
val pxDis = 2.0.pow(15.5 - getGoogleMapZoom())
|
// val pxDis = 2.0.pow(15.5 - getGoogleMapZoom())
|
||||||
mRippleCircleRadius = (pxDis * 150).toInt()
|
// mRippleCircleRadius = (pxDis * 150).toInt()
|
||||||
// addUserAndPetLine(this)
|
|
||||||
addRippleCircle()
|
addRippleCircle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,21 +395,20 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
|||||||
* 直播开始之后,改变绿色波纹动画
|
* 直播开始之后,改变绿色波纹动画
|
||||||
*/
|
*/
|
||||||
fun greenRippleCircleAnim() {
|
fun greenRippleCircleAnim() {
|
||||||
if (null == mRippleCircle) addRippleCircle()
|
if (null == mRippleCircle) addRippleCircle() else setRippleCircleAnim()
|
||||||
mRippleCircle?.apply {
|
mRippleCircle?.apply {
|
||||||
//一像素对应几米
|
//一像素对应几米
|
||||||
val pxDis = 2.0.pow(15.5 - getGoogleMapZoom())
|
// val pxDis = 2.0.pow(15.5 - getGoogleMapZoom())
|
||||||
mRippleCircleRadius = (pxDis * 150).toInt()
|
// mRippleCircleRadius = (pxDis * 150).toInt()
|
||||||
fillColor = (ContextCompat.getColor(mContext!!, R.color.select_color5))
|
fillColor = (ContextCompat.getColor(mContext!!, R.color.select_color5))
|
||||||
strokeColor = (ContextCompat.getColor(mContext!!, R.color.select_color5))
|
strokeColor = (ContextCompat.getColor(mContext!!, R.color.select_color5))
|
||||||
mValueAnimator?.duration = 2000
|
if (!isVisible) isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearRippleCircleAnim() {
|
fun clearRippleCircleAnim() {
|
||||||
mValueAnimator?.cancel()
|
mValueAnimator?.cancel()
|
||||||
mRippleCircle?.remove()
|
mRippleCircle?.isVisible = false
|
||||||
mRippleCircle = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -471,8 +471,8 @@
|
|||||||
<string name="txt_set_measurement_units">选择计量单位</string>
|
<string name="txt_set_measurement_units">选择计量单位</string>
|
||||||
<string name="txt_metric">公制 (厘米, 千克)</string>
|
<string name="txt_metric">公制 (厘米, 千克)</string>
|
||||||
<string name="txt_imperial">英制 (英寸, 磅)</string>
|
<string name="txt_imperial">英制 (英寸, 磅)</string>
|
||||||
<string name="txt_m">米 (m)</string>
|
<string name="txt_m">米</string>
|
||||||
<string name="txt_ft">英尺 (ft)</string>
|
<string name="txt_ft">英尺</string>
|
||||||
<string name="txt_fences_alerts">围栏告警</string>
|
<string name="txt_fences_alerts">围栏告警</string>
|
||||||
<string name="txt_my_pet_fence">我的宠物围栏</string>
|
<string name="txt_my_pet_fence">我的宠物围栏</string>
|
||||||
<string name="txt_feedback_helps_us">您的宝贵意见将帮助我们做得更好。</string>
|
<string name="txt_feedback_helps_us">您的宝贵意见将帮助我们做得更好。</string>
|
||||||
@@ -710,8 +710,8 @@
|
|||||||
<string name="txt_perMonth">$%s/月</string>
|
<string name="txt_perMonth">$%s/月</string>
|
||||||
<string name="txt_congratulations_tip">宠物信息设置成功,获得安全徽章!</string>
|
<string name="txt_congratulations_tip">宠物信息设置成功,获得安全徽章!</string>
|
||||||
<string name="txt_add_tracker_tip2">设备已被绑定,请核对后重试</string>
|
<string name="txt_add_tracker_tip2">设备已被绑定,请核对后重试</string>
|
||||||
<string name="txt_ft_unit">%s英尺 (ft)</string>
|
<string name="txt_ft_unit">%s英尺</string>
|
||||||
<string name="txt_mph_unit">%s英里/小时 (mph)</string>
|
<string name="txt_mph_unit">%s英里/小时</string>
|
||||||
<string name="txt_family_delete">您确定要删除家庭成员%s</string>
|
<string name="txt_family_delete">您确定要删除家庭成员%s</string>
|
||||||
<string name="txt_create_fence_tip4">开启通知:前往“账户” > \"设置\"。点击\"通知\"并开启。</string>
|
<string name="txt_create_fence_tip4">开启通知:前往“账户” > \"设置\"。点击\"通知\"并开启。</string>
|
||||||
<string name="txt_month_unit">/月 x%s</string>
|
<string name="txt_month_unit">/月 x%s</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user