From 0077627871a1dc604a458e167a053034cfca6788 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 15 Feb 2023 14:44:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[Opt]=E5=85=A8=E8=A7=88=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=BF=9B=E5=85=A53D=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/eagle/core/function/view/OverMapView.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 b32b7b3793..bcb0963f92 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 @@ -71,7 +71,7 @@ class OverMapView @JvmOverloads constructor( private val zoomLevel = 15 private var mCameraUpdate: CameraUpdate? = null private var mContext: Context? = null - private val mTilt = 60f + private var mTilt = 0f private var overLayerView: TextView? = null // 全局路径规划中的GeoHash网格 @@ -159,6 +159,10 @@ class OverMapView @JvmOverloads constructor( overLayerView?.visibility = View.GONE } + fun showSiteMarkers() { + + } + private fun initView(context: Context) { mContext = context val smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this) @@ -177,6 +181,7 @@ class OverMapView @JvmOverloads constructor( private fun initAMapView(context: Context) { Log.d(TAG, "initAMapView") + mTilt = 30f mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel.toFloat()) mAMap = mMapView!!.map mCustomMapStyleOptions = CustomMapStyleOptions() @@ -197,6 +202,8 @@ class OverMapView @JvmOverloads constructor( } // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 mAMap?.isTrafficEnabled = false + mAMap?.showBuildings(true) + mAMap?.animateCamera(CameraUpdateFactory.changeTilt(mTilt)) } setUpMap() customOptions() @@ -486,7 +493,7 @@ class OverMapView @JvmOverloads constructor( } else { //设置希望展示的地图缩放级别 val cameraPosition = CameraPosition.Builder() - .target(mCarMarker!!.position).tilt(0f).zoom(zoomLevel.toFloat()).build() + .target(mCarMarker!!.position).tilt(mTilt).zoom(zoomLevel.toFloat()).build() mAMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) } } From 06d526d3dd7630c52e743f52857350ad9efc9b32 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 15 Feb 2023 15:16:29 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[Feat]=E6=94=AF=E6=8C=81=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E7=AB=99=E7=82=B9Marker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/core/function/view/OverMapView.kt | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 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 bcb0963f92..bae436e83e 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 @@ -11,6 +11,7 @@ import android.view.MotionEvent import android.view.View import android.widget.RelativeLayout import android.widget.TextView +import androidx.annotation.MainThread import ch.hsr.geohash.GeoHash import com.amap.api.maps.AMap import com.amap.api.maps.CameraUpdate @@ -99,6 +100,7 @@ class OverMapView @JvmOverloads constructor( private var isFirstLocation = true var mCustomMapStyleOptions: CustomMapStyleOptions? = null var currMarkerList: ArrayList? = null + var siteMarkerList: ArrayList? = null companion object { const val TAG = "OverMapView" @@ -155,12 +157,43 @@ class OverMapView @JvmOverloads constructor( } // =================必须通知高德地图生命周期的变化================= + /** + * 隐藏右下角的重置View + */ fun hideResetView() { overLayerView?.visibility = View.GONE } - fun showSiteMarkers() { + /** + * siteLatLngs: 高德坐标集合 + * bitmap: Marker对应的图片 + * (anchorX,anchorY)为锚点坐标,各自取值范围为[0,1],默认值为(0.5,1) + */ + @MainThread + fun drawSiteMarkers(siteLatLngs: List?, bitmap: Bitmap, anchorX: Float, anchorY: Float) { + if (siteLatLngs.isNullOrEmpty()) return + clearSiteMarkers() + val markerOptionsList = ArrayList() + for (latLng in siteLatLngs) { + val markerOption = MarkerOptions() + markerOption.position(latLng) + markerOption.anchor(anchorX, anchorY) + markerOption.icon( + BitmapDescriptorFactory.fromBitmap(bitmap) + ) + markerOptionsList.add(markerOption) + } + siteMarkerList = mAMap!!.addMarkers(markerOptionsList, false) + } + @MainThread + fun clearSiteMarkers() { + if (siteMarkerList != null) { + for (marker in siteMarkerList!!) { + marker.destroy() + } + siteMarkerList = null + } } private fun initView(context: Context) { @@ -168,9 +201,12 @@ class OverMapView @JvmOverloads constructor( val smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this) mMapView = smpView.findViewById(R.id.aMapView) overLayerView = findViewById(R.id.overLayer) - overLayerView?.background = resources.getDrawable(if (resetDrawable != -1) resetDrawable else R.drawable.amap_reset) - arrivedBitmap = BitmapDescriptorFactory.fromResource(if (arrivedDrawable != -1) arrivedDrawable else R.drawable.taxi_map_arrow_arrived) - unArrivedBitmap = BitmapDescriptorFactory.fromResource(if (unArrivedDrawable != -1) unArrivedDrawable else R.drawable.taxi_map_arrow_un_arrive) + overLayerView?.background = + resources.getDrawable(if (resetDrawable != -1) resetDrawable else R.drawable.amap_reset) + arrivedBitmap = + BitmapDescriptorFactory.fromResource(if (arrivedDrawable != -1) arrivedDrawable else R.drawable.taxi_map_arrow_arrived) + unArrivedBitmap = + BitmapDescriptorFactory.fromResource(if (unArrivedDrawable != -1) unArrivedDrawable else R.drawable.taxi_map_arrow_un_arrive) CallerPlanningRottingListenerManager.addListener(TAG, this) initAMapView(context) // 注册定位监听 @@ -357,7 +393,7 @@ class OverMapView @JvmOverloads constructor( return bitmap } - fun clearV2XMarkers() { + private fun clearV2XMarkers() { if (currMarkerList != null) { for (marker in currMarkerList!!) { marker.destroy() From 06635097b53f61347ba30137bff9db68f72e90a3 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 15 Feb 2023 15:30:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8D=E5=85=A8=E8=A7=88?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=91=84=E5=83=8F=E5=A4=B4=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E7=9C=8B=E8=B5=B7=E6=9D=A5=E4=B8=8D=E5=87=86=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mogo/eagle/core/function/view/OverMapView.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 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 bae436e83e..8891300245 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 @@ -471,6 +471,7 @@ class OverMapView @JvmOverloads constructor( bitmap ) ) + markerOption.anchor(0.18f, 0.98f) markerOption.zIndex(2f) posInfMap[latLng] = structureList markerOptionsList.add(markerOption) @@ -491,8 +492,8 @@ class OverMapView @JvmOverloads constructor( val marker = MakerWithCount(context) marker.setCount(count) marker.measure( - MeasureSpec.makeMeasureSpec(116, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(116, MeasureSpec.EXACTLY) + MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 116f), MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 116f), MeasureSpec.EXACTLY) ) marker.layout(0, 0, marker.measuredWidth, marker.measuredHeight) val bitmap = Bitmap.createBitmap(marker.width, marker.height, Bitmap.Config.ARGB_8888)