[3.3.0] fix bug of request global path
This commit is contained in:
@@ -48,6 +48,7 @@ class SmallMapView @JvmOverloads constructor(
|
||||
private var mCameraUpdate: CameraUpdate? = null
|
||||
private var mContext: Context? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
private var globalPathResp: MessagePad.GlobalPathResp? = null
|
||||
|
||||
companion object {
|
||||
const val TAG = "SmallMapView"
|
||||
@@ -121,12 +122,7 @@ class SmallMapView @JvmOverloads constructor(
|
||||
)
|
||||
)
|
||||
// 绘制线
|
||||
mPolyline = mAMap!!.addPolyline(
|
||||
PolylineOptions()
|
||||
.addAll(mCoordinatesLatLng)
|
||||
.color(Color.argb(255, 31, 127, 255))
|
||||
.width(12f)
|
||||
)
|
||||
mPolyline?.points = mCoordinatesLatLng
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView drawPolyline size is = ${mCoordinatesLatLng.size} ")
|
||||
}
|
||||
@@ -136,8 +132,7 @@ class SmallMapView @JvmOverloads constructor(
|
||||
@UiThread
|
||||
fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
mPolyline = null
|
||||
mPolyline!!.points = null
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker!!.isVisible = false
|
||||
@@ -157,6 +152,12 @@ class SmallMapView @JvmOverloads constructor(
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, this)
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
mPolyline = mAMap!!.addPolyline(
|
||||
PolylineOptions()
|
||||
.color(Color.argb(255, 31, 127, 255))
|
||||
.width(12f)
|
||||
)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
@@ -311,43 +312,53 @@ class SmallMapView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
if (state != 2) {
|
||||
if(state == 2){
|
||||
drawRotting()
|
||||
}else{
|
||||
UiThreadHandler.post {
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRouteLineId(lineId: Long) {
|
||||
super.onAutopilotRouteLineId(lineId)
|
||||
if(lineId == 0L){
|
||||
this.globalPathResp = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawRotting(){
|
||||
globalPathResp?.let {
|
||||
val latLngList: MutableList<MogoLatLng> = ArrayList()
|
||||
for (routeModel in globalPathResp!!.wayPointsList) {
|
||||
latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude))
|
||||
}
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView latLngList.size = ${latLngList.size}")
|
||||
if (latLngList.size > 0) {
|
||||
UiThreadHandler.post {
|
||||
convert(latLngList)
|
||||
drawablePolyline()
|
||||
}
|
||||
} else {
|
||||
UiThreadHandler.post {
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView latLngList.size = ${latLngList.size} clearPolyline ---->")
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView globalPathResp = $globalPathResp")
|
||||
if (globalPathResp == null || globalPathResp.wayPointsList.size == 0) {
|
||||
return
|
||||
}
|
||||
if(CallerAutoPilotStatusListenerManager.getState() != 2){
|
||||
UiThreadHandler.post {
|
||||
clearPolyline()
|
||||
}
|
||||
return
|
||||
}
|
||||
val latLngList: MutableList<MogoLatLng> = ArrayList()
|
||||
for (routeModel in globalPathResp.wayPointsList) {
|
||||
latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude))
|
||||
}
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView latLngList.size = ${latLngList.size}")
|
||||
if (latLngList.size > 0) {
|
||||
UiThreadHandler.post {
|
||||
convert(latLngList)
|
||||
drawablePolyline()
|
||||
}
|
||||
} else {
|
||||
UiThreadHandler.post {
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG, "SmallMapView latLngList.size = ${latLngList.size} clearPolyline ---->")
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
this.globalPathResp = globalPathResp
|
||||
drawRotting()
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user