[mPolyline 置null]
This commit is contained in:
yangyakun
2023-06-27 18:42:13 +08:00
parent 58140cf852
commit 42b4285008
3 changed files with 22 additions and 13 deletions

View File

@@ -41,7 +41,7 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
companion object {
//小地图名称
const val TAG = "TPMapDirectionView"
const val TAG = "BusPassengerMapDirectionView"
}
private lateinit var mAMapNaviView: TextureMapView
@@ -116,7 +116,7 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
// 设置地图的样式
mAMap.uiSettings.apply {
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
setAllGesturesEnabled(false) // 所有手势
setAllGesturesEnabled(true) // 所有手势
isMyLocationButtonEnabled = false // 显示默认的定位按钮
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
}
@@ -148,9 +148,9 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
mAMap.setOnCameraChangeListener(this)
}
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
return true
}
// override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
// return true
// }
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (mogoLocation == null) {
@@ -212,8 +212,10 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
mPolyline!!.options.customTextureIndex = texIndexList
return
}
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
if(textureList.isEmpty()) {
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
}
//设置线段纹理
val polylineOptions = PolylineOptions().apply {
addAll(allPoints)
@@ -231,6 +233,7 @@ class BusPassengerMapDirectionView @JvmOverloads constructor(
override fun clearPolyline() {
if (mPolyline != null) {
mPolyline!!.remove()
mPolyline = null
}
}

View File

@@ -42,7 +42,7 @@ class TaxiPassengerMapDirectionView @JvmOverloads constructor(
companion object {
//小地图名称
const val TAG = "TPMapDirectionView"
const val TAG = "TaxiPassengerMapDirectionView"
private const val zoomLevel = 13.0f
}
@@ -212,8 +212,10 @@ class TaxiPassengerMapDirectionView @JvmOverloads constructor(
mPolyline!!.options.customTextureIndex = texIndexList
return
}
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
if(textureList.isEmpty()) {
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
}
//设置线段纹理
val polylineOptions = PolylineOptions().apply {
addAll(allPoints)
@@ -231,6 +233,7 @@ class TaxiPassengerMapDirectionView @JvmOverloads constructor(
override fun clearPolyline() {
if (mPolyline != null) {
mPolyline!!.remove()
mPolyline = null
}
mStartMarker.isVisible = false
mEndMarker.isVisible = false

View File

@@ -219,8 +219,10 @@ class TaxiMapDirectionView @JvmOverloads constructor(
mPolyline!!.options.customTextureIndex = texIndexList
return
}
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
if(textureList.isEmpty()) {
textureList.add(mArrivedRes)
textureList.add(mUnArrivedRes)
}
//设置线段纹理
val polylineOptions = PolylineOptions().apply {
addAll(allPoints)
@@ -238,6 +240,7 @@ class TaxiMapDirectionView @JvmOverloads constructor(
override fun clearPolyline() {
if (mPolyline != null) {
mPolyline!!.remove()
mPolyline = null
}
mStartMarker.isVisible = false
mEndMarker.isVisible = false
@@ -281,6 +284,6 @@ class TaxiMapDirectionView @JvmOverloads constructor(
companion object {
//小地图名称
const val TAG = "TPMapDirectionView"
const val TAG = "TaxiMapDirectionView"
}
}