[6.5.0][Feat]新增事件显示的回调接口
This commit is contained in:
@@ -15,6 +15,7 @@ data class EventBean(
|
||||
*/
|
||||
var orientation: Int = 0
|
||||
var title: String? = ""
|
||||
var resId: Int = 0
|
||||
}
|
||||
|
||||
data class GeoCoord(var lon: Double, var lat: Double)
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.mogo.eagle.core.function.business.travelreality
|
||||
|
||||
data class EventDrawBean(var resId: Int, var title: String)
|
||||
@@ -34,6 +34,7 @@ import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkM
|
||||
import com.mogo.eagle.core.function.business.travelreality.CrossDeviceBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.DeviceInfoBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.EventBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.EventDrawBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.EventReqEntity
|
||||
import com.mogo.eagle.core.function.business.travelreality.Point
|
||||
import com.mogo.eagle.core.function.business.travelreality.TravelRealityModel.Companion.travelNetWorkModel
|
||||
@@ -201,6 +202,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
|
||||
private var testTime = 0L
|
||||
|
||||
private var listener: OnDrawListener? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TravelRealityView)
|
||||
@@ -253,6 +256,10 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
// =================必须通知高德地图生命周期的变化=================
|
||||
|
||||
fun setOnDrawListener(listener: OnDrawListener) {
|
||||
this.listener = listener
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
mContext = context
|
||||
val mapView =
|
||||
@@ -440,7 +447,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
val globalList = reqData
|
||||
if (eventList.isEmpty() || globalList.isNullOrEmpty()) return
|
||||
testTime = System.currentTimeMillis()
|
||||
|
||||
val eventDrawMap = HashMap<String, EventDrawBean>()
|
||||
val eventOptionsList = ArrayList<MarkerOptions>()
|
||||
globalList.forEachIndexed { index, globalPoint ->
|
||||
if (index >= 0 && index < globalList.size - 1) {
|
||||
@@ -458,7 +465,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
eventBean.orientation = travelNetWorkModel.calculateOrientation(eventBean.lon, eventBean.lat, globalPoint.lon,
|
||||
globalPoint.lat, globalList[index + 1].lon, globalList[index + 1].lat,)
|
||||
filterEventWithType(eventBean, eventOptionsList)
|
||||
filterEventWithType(eventBean, eventOptionsList, eventDrawMap)
|
||||
listener?.onDraw(eventDrawMap.values.toList(), true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,7 +508,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
|
||||
private fun filterEventWithType(
|
||||
eventBean: EventBean,
|
||||
eventOptionsList: ArrayList<MarkerOptions>
|
||||
eventOptionsList: ArrayList<MarkerOptions>,
|
||||
eventDrawMap: HashMap<String, EventDrawBean>
|
||||
) {
|
||||
roadEventList.clear()
|
||||
when (eventBean.poiType) {
|
||||
@@ -511,8 +520,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
zIndex(0.8f)
|
||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigu_nor))
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_shigu_nor
|
||||
eventBean.title = "交通事故"
|
||||
roadEventList.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800003")) {
|
||||
eventDrawMap["800003"] = EventDrawBean(R.drawable.mogo_shigu_nor, "交通事故")
|
||||
}
|
||||
}
|
||||
|
||||
"800002" -> {// 施工
|
||||
@@ -522,8 +535,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
zIndex(0.8f)
|
||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigong_image))
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_shigong_image
|
||||
eventBean.title = "道路施工"
|
||||
roadEventList.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800002")) {
|
||||
eventDrawMap["800002"] = EventDrawBean(R.drawable.mogo_shigong_image, "道路施工")
|
||||
}
|
||||
}
|
||||
|
||||
"800006" -> {// 拥堵
|
||||
@@ -542,19 +559,16 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
zIndex(0.8f)
|
||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor))
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_jingzhi_nor
|
||||
eventBean.title = "静止事件"
|
||||
roadEventList.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800004")) {
|
||||
eventDrawMap["800004"] = EventDrawBean(R.drawable.mogo_jingzhi_nor, "静止事件")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
eventOptionsList.add(MarkerOptions().apply {
|
||||
position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon))
|
||||
anchor(0.5f, 0.5f)
|
||||
zIndex(0.8f)
|
||||
icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor))
|
||||
})
|
||||
eventBean.title = "未知事件"
|
||||
roadEventList.add(eventBean)
|
||||
Log.d(TAG, "请求到未知事件!")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -694,6 +708,9 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (deviceInPaths.isNotEmpty()) {
|
||||
listener?.onDraw(arrayListOf(EventDrawBean(R.drawable.mogo_quanxi_lukou, "全息路口")), false)
|
||||
}
|
||||
deviceInPathList = arrayListOf(CrossDeviceBean("", 0.0, "", 0.0, deviceInPaths))
|
||||
// 绘制路口设备
|
||||
drawMarkers(DRAW_CROSS_DEVICE, crossOptionsList)
|
||||
@@ -1016,6 +1033,11 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface OnDrawListener {
|
||||
// isEvent为true表示是事件,反之则表示全息路口
|
||||
fun onDraw(eventList: List<EventDrawBean>, isEvent: Boolean)
|
||||
}
|
||||
|
||||
private inner class NonFrequentHandler(looper: Looper) : Handler(looper) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
Reference in New Issue
Block a user