1.增加百度地图和谷歌地图多宠物位置更新

This commit is contained in:
2026-10-09 09:50:26 +08:00
parent 64a94f2a7c
commit 0a7a059363
6 changed files with 63 additions and 4 deletions

View File

@@ -28,9 +28,9 @@ android {
applicationId "com.abbidot.tracker" applicationId "com.abbidot.tracker"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 35 targetSdkVersion 35
versionCode 2600 versionCode 2601
versionName "2.6.0" // versionName "2.6.1"
// versionName "2.6.0-Beta5" versionName "2.6.1-Beta1"
4 4
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -33,6 +33,7 @@ data class MapDeviceBean(
var ledBlueValue: Int, var ledBlueValue: Int,
var fences: MutableList<FencesBean>?, var fences: MutableList<FencesBean>?,
var wifiZones: MutableList<WiFiZoneBean>?, var wifiZones: MutableList<WiFiZoneBean>?,
var otherPets: MutableList<PetBean>?,
var startTime: String, var startTime: String,
var endTime: String, var endTime: String,
var deviceType: Int, var deviceType: Int,
@@ -71,6 +72,7 @@ data class MapDeviceBean(
0, 0,
null, null,
null, null,
null,
"", "",
"", "",
1, 1,

View File

@@ -227,6 +227,13 @@ class HomeMapCommonV3 @Inject constructor() : BaseMapCommon() {
} }
} }
fun updateOtherPetLatLng(otherPets: MutableList<PetBean>?) {
if (!otherPets.isNullOrEmpty()) {
mHomeMapGoogleMapFragment?.updateOtherPetLatLng(otherPets)
mHomeMapBaiduMapFragment?.updateOtherPetLatLng(otherPets)
}
}
fun clearOtherPetHeadMarker() { fun clearOtherPetHeadMarker() {
mHomeMapGoogleMapFragment?.clearOtherPetHeadMarker() mHomeMapGoogleMapFragment?.clearOtherPetHeadMarker()
mHomeMapBaiduMapFragment?.clearOtherPetHeadMarker() mHomeMapBaiduMapFragment?.clearOtherPetHeadMarker()

View File

@@ -813,6 +813,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
isMoveCamera = false isMoveCamera = false
} }
mHomeMapCommon.startRefreshUserLocation() mHomeMapCommon.startRefreshUserLocation()
mHomeMapCommon.updateOtherPetLatLng(otherPets)
if (isShowFence) { if (isShowFence) {
fences?.let { fences -> fences?.let { fences ->

View File

@@ -3,6 +3,7 @@ package com.abbidot.tracker.ui.fragment.map.baidumap
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.content.Context import android.content.Context
import android.graphics.Point import android.graphics.Point
import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
@@ -21,6 +22,7 @@ import com.abbidot.tracker.bean.HistoryDataBean
import com.abbidot.tracker.bean.MapDeviceBean import com.abbidot.tracker.bean.MapDeviceBean
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.constant.ConstantString
import com.abbidot.tracker.databinding.LayoutPetLocationInfoBinding 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
@@ -30,6 +32,7 @@ import com.baidu.mapapi.map.BaiduMap
import com.baidu.mapapi.map.BitmapDescriptor import com.baidu.mapapi.map.BitmapDescriptor
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.Marker
import com.baidu.mapapi.map.MarkerOptions import com.baidu.mapapi.map.MarkerOptions
import com.baidu.mapapi.map.Overlay import com.baidu.mapapi.map.Overlay
import com.baidu.mapapi.map.PolylineDottedLineType import com.baidu.mapapi.map.PolylineDottedLineType
@@ -399,6 +402,10 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
val newLatLng = getBaiduMapLatLng(pet.latitude, pet.longitude) val newLatLng = getBaiduMapLatLng(pet.latitude, pet.longitude)
val markerOptions = MarkerOptions().position(newLatLng) val markerOptions = MarkerOptions().position(newLatLng)
markerOptions.icon(bitmapDescriptor as BitmapDescriptor) markerOptions.icon(bitmapDescriptor as BitmapDescriptor)
val bundle = Bundle().apply {
putString(ConstantString.PetId, pet.petId)
}
markerOptions.extraInfo(bundle)
mBaiduMap?.apply { mBaiduMap?.apply {
mOtherPetMarkerList.add(addOverlay(markerOptions)) mOtherPetMarkerList.add(addOverlay(markerOptions))
} }
@@ -406,6 +413,27 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
} }
} }
/**
* 更新其他多宠物位置
*/
fun updateOtherPetLatLng(otherPets: MutableList<PetBean>?) {
if (!otherPets.isNullOrEmpty()) {
for (marker in mOtherPetMarkerList) {
marker?.apply {
if (this is Marker) {
for (other in otherPets) {
if (extraInfo.getString(ConstantString.PetId) == other.petId && other.latitude != 0.0 && other.longitude != 0.0) {
val newLatLng = getBaiduMapLatLng(other.latitude, other.longitude)
position = newLatLng
break
}
}
}
}
}
}
}
/** /**
* 清空其他宠物的头像Marker * 清空其他宠物的头像Marker
*/ */

View File

@@ -389,7 +389,28 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
val markerOptions = MarkerOptions().position(newLatLng) val markerOptions = MarkerOptions().position(newLatLng)
markerOptions.icon(bitmapDescriptor) markerOptions.icon(bitmapDescriptor)
mGoogleMap?.apply { mGoogleMap?.apply {
mOtherPetMarkerList.add(addMarker(markerOptions)) val m = addMarker(markerOptions)
m?.tag = pet.petId
mOtherPetMarkerList.add(m)
}
}
}
}
/**
* 更新其他多宠物位置
*/
fun updateOtherPetLatLng(otherPets: MutableList<PetBean>?) {
if (!otherPets.isNullOrEmpty()) {
for (marker in mOtherPetMarkerList) {
marker?.apply {
for (other in otherPets) {
if (tag == other.petId && other.latitude != 0.0 && other.longitude != 0.0) {
val newLatLng = toGCJ02LatLon(LatLng(other.latitude, other.longitude))
position = newLatLng
break
}
}
} }
} }
} }