From 15b5258d2da8912287661b22bda5d2e77c55df73 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Mon, 13 Mar 2023 21:53:36 +0800 Subject: [PATCH] =?UTF-8?q?[sweeper]=20[=E5=9C=B0=E5=9B=BE=E5=9C=88?= =?UTF-8?q?=E9=80=89=E8=8C=83=E5=9B=B4]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/och/sweeper/view/WeltMapOverView.kt | 21 +++---------------- .../mogo/och/sweeper/view/WeltSmallMapView.kt | 4 ++++ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt index b76830ada4..0bcd0f5d1b 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltMapOverView.kt @@ -37,8 +37,6 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { private var mRoutePolylines: Polyline?=null // private val mLineMarkers: MutableList = mutableListOf() private var mEndStationMarker: Marker? = null - private var mogoDistanceLocationMax: LatLng?=null - private var aPointDistanceMax = 0.0F private var mFirst: Boolean = false //清扫车任务地图 @@ -58,6 +56,7 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { initAMapView() // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) + CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,5) } private fun initAMapView() { @@ -156,24 +155,10 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { for (i in mTaskCoordinatesLatLng.indices) { val latLng = mTaskCoordinatesLatLng[i] boundsBuilder.include(latLng) - try { - val calculateLineDistance = CoordinateUtils.calculateLineDistance( - latLng.longitude, - latLng.latitude, - currentLatLng.latitude, - currentLatLng.longitude - ) - if(calculateLineDistance>aPointDistanceMax){ - aPointDistanceMax = calculateLineDistance - mogoDistanceLocationMax = currentLatLng - } - }catch (e:Exception){ - CallerLogger.e(TAG,e.stackTrace) - } } } - mogoDistanceLocationMax?.let { - boundsBuilder.include(it) + mRoutePolylines?.points?.forEach {latLng-> + boundsBuilder.include(latLng) } boundsBuilder.include(currentLatLng) mAMap?.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)) diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt index 0e0d2b7cc2..fccf64bcc5 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/WeltSmallMapView.kt @@ -55,6 +55,7 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { initAMapView() // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) + CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,5) } override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { @@ -71,6 +72,9 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener { boundsBuilder.include(mTaskCoordinatesLatLng[i]) } } + mRoutePolylines?.points?.forEach {latLng-> + boundsBuilder.include(latLng) + } boundsBuilder.include(currentLatLng) mAMap!!.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)) }