[3.2.0][Opt]全览模式所有绘制逻辑切换到子线程
This commit is contained in:
@@ -212,7 +212,6 @@ class OverMapView @JvmOverloads constructor(
|
||||
* bitmap: Marker对应的图片
|
||||
* (anchorX,anchorY)为锚点坐标,各自取值范围为[0,1],默认值为(0.5,1)
|
||||
*/
|
||||
@MainThread
|
||||
fun drawSiteMarkers(
|
||||
siteLatLngs: List<LatLng>?,
|
||||
bitmap: Bitmap,
|
||||
@@ -231,10 +230,11 @@ class OverMapView @JvmOverloads constructor(
|
||||
)
|
||||
markerOptionsList.add(markerOption)
|
||||
}
|
||||
siteMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
singlePool.execute {
|
||||
siteMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun drawSiteMarkers(
|
||||
siteMarkers: List<SiteMarkerBean>?
|
||||
) {
|
||||
@@ -250,16 +250,19 @@ class OverMapView @JvmOverloads constructor(
|
||||
)
|
||||
markerOptionsList.add(markerOption)
|
||||
}
|
||||
siteMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
singlePool.execute {
|
||||
siteMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun clearSiteMarkers() {
|
||||
if (siteMarkerList != null) {
|
||||
for (marker in siteMarkerList!!) {
|
||||
marker.destroy()
|
||||
singlePool.execute {
|
||||
if (siteMarkerList != null) {
|
||||
for (marker in siteMarkerList!!) {
|
||||
marker.destroy()
|
||||
}
|
||||
siteMarkerList = null
|
||||
}
|
||||
siteMarkerList = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,17 +282,21 @@ class OverMapView @JvmOverloads constructor(
|
||||
)
|
||||
markerOptionsList.add(markerOption)
|
||||
}
|
||||
siteNameList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
singlePool.execute {
|
||||
siteNameList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新站点信息Bitmap展示
|
||||
*/
|
||||
fun updateSiteNameView(index: Int, bitmap: Bitmap) {
|
||||
if (siteNameList != null && index in 0 until siteNameList!!.size) {
|
||||
val siteNameMarker = siteNameList!![index]
|
||||
siteNameMarker.options.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
|
||||
siteNameMarker.position = siteNameMarker.position
|
||||
singlePool.execute {
|
||||
if (siteNameList != null && index in 0 until siteNameList!!.size) {
|
||||
val siteNameMarker = siteNameList!![index]
|
||||
siteNameMarker.options.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
|
||||
siteNameMarker.position = siteNameMarker.position
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,11 +320,13 @@ class OverMapView @JvmOverloads constructor(
|
||||
* 清除站点名
|
||||
*/
|
||||
fun clearSiteNameViews() {
|
||||
if (siteNameList != null) {
|
||||
for (marker in siteNameList!!) {
|
||||
marker.destroy()
|
||||
singlePool.execute {
|
||||
if (siteNameList != null) {
|
||||
for (marker in siteNameList!!) {
|
||||
marker.destroy()
|
||||
}
|
||||
siteNameList = null
|
||||
}
|
||||
siteNameList = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,14 +334,17 @@ class OverMapView @JvmOverloads constructor(
|
||||
* 清空线路并隐藏起、终点
|
||||
*/
|
||||
fun clearCustomPolyline() {
|
||||
if (mBottomPolyline != null) {
|
||||
mBottomPolyline!!.remove()
|
||||
singlePool.execute {
|
||||
if (mBottomPolyline != null) {
|
||||
mBottomPolyline!!.remove()
|
||||
}
|
||||
if (mCoveredPolyline != null) {
|
||||
mCoveredPolyline!!.remove()
|
||||
}
|
||||
mStartMarker?.isVisible = false
|
||||
mEndMarker?.isVisible = false
|
||||
}
|
||||
if (mCoveredPolyline != null) {
|
||||
mCoveredPolyline!!.remove()
|
||||
}
|
||||
mStartMarker?.isVisible = false
|
||||
mEndMarker?.isVisible = false
|
||||
|
||||
MarkerDrawerManager.stopLoopCalCarLocation()
|
||||
ThreadUtils.getIoPool().execute {
|
||||
MarkerDrawerManager.resetStatus()
|
||||
@@ -471,9 +483,12 @@ class OverMapView @JvmOverloads constructor(
|
||||
Log.d(TAG, "全局路径规划轨迹为空")
|
||||
return
|
||||
}
|
||||
Log.d(TAG, "全局路径规划轨迹下发,起点为:(${locationList[0].longitude},${locationList[0].latitude}),终点为:(${locationList.last().longitude},${locationList.last().latitude})")
|
||||
Log.d(
|
||||
TAG,
|
||||
"全局路径规划轨迹下发,起点为:(${locationList[0].longitude},${locationList[0].latitude}),终点为:(${locationList.last().longitude},${locationList.last().latitude})"
|
||||
)
|
||||
isFirst = true
|
||||
MarkerDrawerManager.resetStatus()
|
||||
MarkerDrawerManager.lastArrivedIndex = -1
|
||||
val list: List<MessagePad.Location> = locationList
|
||||
// 转成高德定位对象并存储
|
||||
val planningPointList = change2GDPoints(list, mContext!!)
|
||||
@@ -557,7 +572,9 @@ class OverMapView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun drawV2XMarkers(markerOptionsList: ArrayList<MarkerOptions>?) {
|
||||
currMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
singlePool.execute {
|
||||
currMarkerList = mAMap!!.addMarkers(markerOptionsList, false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getV2XBitmap(poiType: String?): Bitmap {
|
||||
@@ -573,11 +590,13 @@ class OverMapView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun clearV2XMarkers() {
|
||||
if (currMarkerList != null) {
|
||||
for (marker in currMarkerList!!) {
|
||||
marker.destroy()
|
||||
singlePool.execute {
|
||||
if (currMarkerList != null) {
|
||||
for (marker in currMarkerList!!) {
|
||||
marker.destroy()
|
||||
}
|
||||
currMarkerList = null
|
||||
}
|
||||
currMarkerList = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,7 +802,10 @@ class OverMapView @JvmOverloads constructor(
|
||||
texIndexList.add(i - 1)
|
||||
}
|
||||
if (mAMap != null && coordinates.size > 2) {
|
||||
Log.d(TAG, "绘制时轨迹点数为:${coordinates.size},车辆index为:$locIndex,起点为:(${coordinates[0].longitude},${coordinates[0].latitude}),终点为:(${coordinates.last().longitude},${coordinates.last().latitude})")
|
||||
Log.d(
|
||||
TAG,
|
||||
"绘制时轨迹点数为:${coordinates.size},车辆index为:$locIndex,起点为:(${coordinates[0].longitude},${coordinates[0].latitude}),终点为:(${coordinates.last().longitude},${coordinates.last().latitude})"
|
||||
)
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions()
|
||||
polylineOptions.addAll(coordinates)
|
||||
@@ -804,30 +826,31 @@ class OverMapView @JvmOverloads constructor(
|
||||
/**
|
||||
* 绘制站点轨迹线
|
||||
*/
|
||||
@MainThread
|
||||
fun drawSitePolyline(coordinates: List<LatLng>?, bitmap: Bitmap) {
|
||||
if (coordinates.isNullOrEmpty()) return
|
||||
if (mSitePolyline != null) {
|
||||
mSitePolyline!!.remove()
|
||||
}
|
||||
val textureList = arrayListOf<BitmapDescriptor>()
|
||||
val texIndexList = arrayListOf<Int>()
|
||||
for (i in coordinates.indices) {
|
||||
// 线段数比点数少一个
|
||||
if (i == 0) continue
|
||||
textureList.add(BitmapDescriptorFactory.fromBitmap(bitmap))
|
||||
texIndexList.add(i - 1)
|
||||
}
|
||||
if (mAMap != null) {
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions()
|
||||
polylineOptions.addAll(coordinates)
|
||||
polylineOptions.width(14f) //线段宽度
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
polylineOptions.customTextureList = textureList
|
||||
polylineOptions.customTextureIndex = texIndexList
|
||||
// 绘制线
|
||||
mSitePolyline = mAMap!!.addPolyline(polylineOptions)
|
||||
singlePool.execute {
|
||||
if (mSitePolyline != null) {
|
||||
mSitePolyline!!.remove()
|
||||
}
|
||||
val textureList = arrayListOf<BitmapDescriptor>()
|
||||
val texIndexList = arrayListOf<Int>()
|
||||
for (i in coordinates.indices) {
|
||||
// 线段数比点数少一个
|
||||
if (i == 0) continue
|
||||
textureList.add(BitmapDescriptorFactory.fromBitmap(bitmap))
|
||||
texIndexList.add(i - 1)
|
||||
}
|
||||
if (mAMap != null) {
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions()
|
||||
polylineOptions.addAll(coordinates)
|
||||
polylineOptions.width(14f) //线段宽度
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
polylineOptions.customTextureList = textureList
|
||||
polylineOptions.customTextureIndex = texIndexList
|
||||
// 绘制线
|
||||
mSitePolyline = mAMap!!.addPolyline(polylineOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,8 +858,10 @@ class OverMapView @JvmOverloads constructor(
|
||||
* 清除已选站点的轨迹线
|
||||
*/
|
||||
fun clearSitePolyline() {
|
||||
if (mSitePolyline != null) {
|
||||
mSitePolyline!!.remove()
|
||||
singlePool.execute {
|
||||
if (mSitePolyline != null) {
|
||||
mSitePolyline!!.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user