1.增加百度地图和谷歌地图多宠物位置更新
This commit is contained in:
@@ -28,9 +28,9 @@ android {
|
||||
applicationId "com.abbidot.tracker"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 35
|
||||
versionCode 2600
|
||||
versionName "2.6.0"
|
||||
// versionName "2.6.0-Beta5"
|
||||
versionCode 2601
|
||||
// versionName "2.6.1"
|
||||
versionName "2.6.1-Beta1"
|
||||
4
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ data class MapDeviceBean(
|
||||
var ledBlueValue: Int,
|
||||
var fences: MutableList<FencesBean>?,
|
||||
var wifiZones: MutableList<WiFiZoneBean>?,
|
||||
var otherPets: MutableList<PetBean>?,
|
||||
var startTime: String,
|
||||
var endTime: String,
|
||||
var deviceType: Int,
|
||||
@@ -71,6 +72,7 @@ data class MapDeviceBean(
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
"",
|
||||
1,
|
||||
|
||||
@@ -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() {
|
||||
mHomeMapGoogleMapFragment?.clearOtherPetHeadMarker()
|
||||
mHomeMapBaiduMapFragment?.clearOtherPetHeadMarker()
|
||||
|
||||
@@ -813,6 +813,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
|
||||
isMoveCamera = false
|
||||
}
|
||||
mHomeMapCommon.startRefreshUserLocation()
|
||||
mHomeMapCommon.updateOtherPetLatLng(otherPets)
|
||||
|
||||
if (isShowFence) {
|
||||
fences?.let { fences ->
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.abbidot.tracker.ui.fragment.map.baidumap
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.graphics.Point
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.MotionEvent
|
||||
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.PetBean
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.databinding.LayoutPetLocationInfoBinding
|
||||
import com.abbidot.tracker.util.Util
|
||||
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.CircleOptions
|
||||
import com.baidu.mapapi.map.MapStatus
|
||||
import com.baidu.mapapi.map.Marker
|
||||
import com.baidu.mapapi.map.MarkerOptions
|
||||
import com.baidu.mapapi.map.Overlay
|
||||
import com.baidu.mapapi.map.PolylineDottedLineType
|
||||
@@ -399,6 +402,10 @@ class HomeMapBaiduMapFragment : BaseBaiduMapFragment() {
|
||||
val newLatLng = getBaiduMapLatLng(pet.latitude, pet.longitude)
|
||||
val markerOptions = MarkerOptions().position(newLatLng)
|
||||
markerOptions.icon(bitmapDescriptor as BitmapDescriptor)
|
||||
val bundle = Bundle().apply {
|
||||
putString(ConstantString.PetId, pet.petId)
|
||||
}
|
||||
markerOptions.extraInfo(bundle)
|
||||
mBaiduMap?.apply {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -389,7 +389,28 @@ class HomeMapGoogleMapFragmentV3 : BaseGoogleMapFragment() {
|
||||
val markerOptions = MarkerOptions().position(newLatLng)
|
||||
markerOptions.icon(bitmapDescriptor)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user