[2.15.0_merge_3.2.0]

This commit is contained in:
zhongchao
2023-05-08 11:21:15 +08:00
523 changed files with 6717 additions and 4571 deletions

View File

@@ -107,6 +107,8 @@ class OverMapView @JvmOverloads constructor(
private var mBottomPolyline: Polyline? = null
private var mCoveredPolyline: Polyline? = null
private var mSitePolyline: Polyline? = null
// 计算索引并设置对应的Bitmap
var arrivedBitmap: BitmapDescriptor? = null
var unArrivedBitmap: BitmapDescriptor? = null
@@ -120,6 +122,7 @@ class OverMapView @JvmOverloads constructor(
var mCustomMapStyleOptions: CustomMapStyleOptions? = null
var currMarkerList: ArrayList<Marker>? = null
var siteMarkerList: ArrayList<Marker>? = null
var siteNameList: ArrayList<Marker>? = null
companion object {
const val TAG = "OverMapView"
@@ -226,7 +229,7 @@ class OverMapView @JvmOverloads constructor(
@MainThread
fun drawSiteMarkers(
siteMarkers: List<SiteMarkerBean>?,
siteMarkers: List<SiteMarkerBean>?
) {
if (siteMarkers.isNullOrEmpty()) return
clearSiteMarkers()
@@ -253,6 +256,64 @@ class OverMapView @JvmOverloads constructor(
}
}
/**
* 绘制站点名
*/
fun drawSiteNameViews(siteMarkers: List<SiteMarkerBean>?) {
if (siteMarkers.isNullOrEmpty()) return
clearSiteMarkers()
val markerOptionsList = ArrayList<MarkerOptions>()
for (siteMarkerBean in siteMarkers) {
val markerOption = MarkerOptions()
markerOption.position(siteMarkerBean.latLng)
markerOption.anchor(siteMarkerBean.anchorX, siteMarkerBean.anchorY)
markerOption.icon(
BitmapDescriptorFactory.fromBitmap(siteMarkerBean.bitmap)
)
markerOptionsList.add(markerOption)
}
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
}
}
/**
* 更新站点信息
*/
fun updateSiteNameView(index: Int, siteMarkerBean: SiteMarkerBean) {
if (siteNameList != null && index in 0 until siteNameList!!.size) {
val siteNameMarker = siteNameList!![index]
val markerOption = MarkerOptions()
markerOption.position(siteMarkerBean.latLng)
markerOption.anchor(siteMarkerBean.anchorX, siteMarkerBean.anchorY)
markerOption.icon(
BitmapDescriptorFactory.fromBitmap(siteMarkerBean.bitmap)
)
siteNameMarker.setMarkerOptions(markerOption)
}
}
/**
* 清除站点名
*/
fun clearSiteNameViews() {
if (siteNameList != null) {
for (marker in siteNameList!!) {
marker.destroy()
}
siteNameList = null
}
}
/**
* 清空线路并隐藏起、终点
*/
@@ -588,7 +649,7 @@ class OverMapView @JvmOverloads constructor(
/**
* 进入自定义全览模式
*/
private fun displayCustomOverView() {
fun displayCustomOverView() {
val linePointsLatLng = planningPoints
if (linePointsLatLng.size > 1 && mLocation != null) {
//圈定地图显示范围
@@ -661,7 +722,8 @@ class OverMapView @JvmOverloads constructor(
* @param coordinates
* @param locIndex
*/
private fun drawPolyline(coordinates: List<LatLng>, locIndex: Int) {
@MainThread
fun drawPolyline(coordinates: List<LatLng>, locIndex: Int) {
if (textureList.size > 0) {
textureList.clear()
}
@@ -702,6 +764,95 @@ 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)
}
}
/**
* 清除已选站点的轨迹线
*/
fun clearSitePolyline() {
if (mSitePolyline != null) {
mSitePolyline!!.remove()
}
}
/**
* 站点轨迹集合被包含在地图显示范围内
*/
fun includeSitePointsAndUpdateCamera(coordinates: List<LatLng>?) {
val linePointsLatLng = planningPoints
val boundsBuilder = LatLngBounds.Builder()
var isOnlyCarLocation = true
if (linePointsLatLng.size > 1) {
// 圈定地图显示范围(自动驾驶轨迹)
for (i in linePointsLatLng.indices) {
boundsBuilder.include(linePointsLatLng[i])
}
isOnlyCarLocation = false
}
if (mLocation != null) {
// 自车坐标
boundsBuilder.include(LatLng(mLocation!!.latitude, mLocation!!.longitude))
}
coordinates?.let {
// 站点轨迹被包含在地图显示范围内
for (i in it.indices) {
boundsBuilder.include(it[i])
}
isOnlyCarLocation = false
}
if (!isOnlyCarLocation) {
val cameraPosition = CameraPosition.Builder().tilt(mTilt).build()
//第二个参数为四周留空宽度
mAMap!!.moveCamera(
CameraUpdateFactory.newLatLngBoundsRect(
boundsBuilder.build(),
AutoSizeUtils.dp2px(context, leftPadding.toFloat()),
AutoSizeUtils.dp2px(context, rightPadding.toFloat()),
AutoSizeUtils.dp2px(context, topPadding.toFloat()),
AutoSizeUtils.dp2px(context, bottomPadding.toFloat())
)
)
mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
} else {
//设置希望展示的地图缩放级别
val cameraPosition = CameraPosition.Builder()
.target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build()
mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
}
}
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) {
gnssInfo?.let {
mLocation = it