[3.2.0][feat]支持绘制并更新站点名
This commit is contained in:
@@ -112,6 +112,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"
|
||||
@@ -218,7 +219,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
|
||||
@MainThread
|
||||
fun drawSiteMarkers(
|
||||
siteMarkers: List<SiteMarkerBean>?,
|
||||
siteMarkers: List<SiteMarkerBean>?
|
||||
) {
|
||||
if (siteMarkers.isNullOrEmpty()) return
|
||||
clearSiteMarkers()
|
||||
@@ -245,6 +246,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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空线路并隐藏起、终点
|
||||
*/
|
||||
@@ -578,7 +637,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
/**
|
||||
* 进入自定义全览模式
|
||||
*/
|
||||
private fun displayCustomOverView() {
|
||||
fun displayCustomOverView() {
|
||||
val linePointsLatLng = planningPoints
|
||||
if (linePointsLatLng.size > 1 && mLocation != null) {
|
||||
//圈定地图显示范围
|
||||
@@ -651,7 +710,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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user