From 45a7aa768a0823b9d6494fdae617c080bd0c3124 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 5 May 2023 17:18:45 +0800 Subject: [PATCH] =?UTF-8?q?[3.2.0][feat]=E6=94=AF=E6=8C=81=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=B9=B6=E6=9B=B4=E6=96=B0=E7=AB=99=E7=82=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/core/function/view/OverMapView.kt | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt index 2864399312..174c5f3494 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt @@ -112,6 +112,7 @@ class OverMapView @JvmOverloads constructor( var mCustomMapStyleOptions: CustomMapStyleOptions? = null var currMarkerList: ArrayList? = null var siteMarkerList: ArrayList? = null + var siteNameList: ArrayList? = null companion object { const val TAG = "OverMapView" @@ -218,7 +219,7 @@ class OverMapView @JvmOverloads constructor( @MainThread fun drawSiteMarkers( - siteMarkers: List?, + siteMarkers: List? ) { if (siteMarkers.isNullOrEmpty()) return clearSiteMarkers() @@ -245,6 +246,64 @@ class OverMapView @JvmOverloads constructor( } } + /** + * 绘制站点名 + */ + fun drawSiteNameViews(siteMarkers: List?) { + if (siteMarkers.isNullOrEmpty()) return + clearSiteMarkers() + val markerOptionsList = ArrayList() + 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, locIndex: Int) { + @MainThread + fun drawPolyline(coordinates: List, locIndex: Int) { if (textureList.size > 0) { textureList.clear() }