|
|
@@ -28,12 +28,6 @@ class CustomMarkLayer @JvmOverloads constructor(
|
|
|
private var btnIndex: Int
|
|
|
private var currentZoom = 0f
|
|
|
private var currentDegree = 0f
|
|
|
- private lateinit var icon: Bitmap
|
|
|
- private lateinit var iconRepair: Bitmap
|
|
|
- private lateinit var iconPreMaintenance: Bitmap
|
|
|
- private lateinit var iconChangeShifts: Bitmap
|
|
|
- private lateinit var iconClean: Bitmap
|
|
|
- private lateinit var iconSwitchProduct: Bitmap
|
|
|
|
|
|
init {
|
|
|
num = -1
|
|
|
@@ -43,12 +37,6 @@ class CustomMarkLayer @JvmOverloads constructor(
|
|
|
|
|
|
private fun initLayer() {
|
|
|
radiusMark = setValue(10.0f)
|
|
|
- icon = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_repair)
|
|
|
- iconRepair = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_repair)
|
|
|
- iconPreMaintenance = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_pre_maintenance)
|
|
|
- iconChangeShifts = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_change_shifts)
|
|
|
- iconClean = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_clean)
|
|
|
- iconSwitchProduct = BitmapFactory.decodeResource(mapView.resources, R.mipmap.map_switch_product)
|
|
|
paint = Paint()
|
|
|
paint.isAntiAlias = true
|
|
|
paint.style = Paint.Style.FILL_AND_STROKE
|
|
|
@@ -81,20 +69,20 @@ class CustomMarkLayer @JvmOverloads constructor(
|
|
|
for (j in list.indices) {
|
|
|
val ticketX = if (list.size % 2 == 0) { // 偶数个
|
|
|
if (j + 1 <= list.size / 2) {
|
|
|
- pointList[i].pos.x - icon.width * (list.size / 2 - j - 0.5f) / currentZoom
|
|
|
+ pointList[i].pos.x - list[j].bitmap!!.width * (list.size / 2 - j - 0.5f) / currentZoom
|
|
|
} else {
|
|
|
- pointList[i].pos.x + icon.width * (j - list.size / 2 + 0.5f) / currentZoom
|
|
|
+ pointList[i].pos.x + list[j].bitmap!!.width * (j - list.size / 2 + 0.5f) / currentZoom
|
|
|
}
|
|
|
} else { // 奇数个
|
|
|
if (j + 1 <= list.size / 2) {
|
|
|
- pointList[i].pos.x - icon.width * (list.size / 2 - j) / currentZoom
|
|
|
+ pointList[i].pos.x - list[j].bitmap!!.width * (list.size / 2 - j) / currentZoom
|
|
|
} else {
|
|
|
- pointList[i].pos.x + icon.width * (j - list.size / 2) / currentZoom
|
|
|
+ pointList[i].pos.x + list[j].bitmap!!.width * (j - list.size / 2) / currentZoom
|
|
|
}
|
|
|
}
|
|
|
val rotatedPoint = rotatePoint(
|
|
|
ticketX,
|
|
|
- pointList[i].pos.y - icon.height / currentZoom,
|
|
|
+ pointList[i].pos.y - list[j].bitmap!!.height / currentZoom,
|
|
|
pointList[i].pos.x,
|
|
|
pointList[i].pos.y,
|
|
|
currentDegree
|
|
|
@@ -106,7 +94,7 @@ class CustomMarkLayer @JvmOverloads constructor(
|
|
|
rotatedPoint.second
|
|
|
)
|
|
|
|
|
|
- if (distance <= icon.width / 2 / currentZoom) {
|
|
|
+ if (distance <= list[j].bitmap!!.width / 2 / currentZoom) {
|
|
|
num = i
|
|
|
btnIndex = j
|
|
|
isClickMark = true
|
|
|
@@ -178,29 +166,22 @@ class CustomMarkLayer @JvmOverloads constructor(
|
|
|
if (list.isNotEmpty()) {
|
|
|
for (j in list.indices) {
|
|
|
canvas.drawBitmap(
|
|
|
- when(list[j].ticketType) {
|
|
|
- "0" -> iconRepair
|
|
|
- "1" -> iconPreMaintenance
|
|
|
- "2" -> iconChangeShifts
|
|
|
- "3" -> iconClean
|
|
|
- "4" -> iconSwitchProduct
|
|
|
- else -> iconRepair
|
|
|
- },
|
|
|
+ list[j].bitmap!!,
|
|
|
// 偶数个
|
|
|
if (list.size % 2 == 0) {
|
|
|
if (j + 1 <= list.size / 2) {
|
|
|
- goal[0] - icon.width * (list.size / 2 - j)
|
|
|
+ goal[0] - list[j].bitmap!!.width * (list.size / 2 - j)
|
|
|
} else {
|
|
|
- goal[0] + icon.width * (j - list.size / 2)
|
|
|
+ goal[0] + list[j].bitmap!!.width * (j - list.size / 2)
|
|
|
}
|
|
|
} else { // 奇数个
|
|
|
if (j + 1 <= list.size / 2) {
|
|
|
- goal[0] - icon.width * (list.size / 2 - j + 0.5f)
|
|
|
+ goal[0] - list[j].bitmap!!.width * (list.size / 2 - j + 0.5f)
|
|
|
} else {
|
|
|
- goal[0] + icon.width * (j - list.size / 2 - 0.5f)
|
|
|
+ goal[0] + list[j].bitmap!!.width * (j - list.size / 2 - 0.5f)
|
|
|
}
|
|
|
},
|
|
|
- goal[1] - icon.height / 2 * 3,
|
|
|
+ goal[1] - list[j].bitmap!!.height / 2 * 3,
|
|
|
paint
|
|
|
)
|
|
|
}
|