Merge remote-tracking branch 'origin/dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0' into dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0
This commit is contained in:
@@ -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
|
||||
@@ -71,7 +72,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网格
|
||||
@@ -99,6 +100,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
private var isFirstLocation = true
|
||||
var mCustomMapStyleOptions: CustomMapStyleOptions? = null
|
||||
var currMarkerList: ArrayList<Marker>? = null
|
||||
var siteMarkerList: ArrayList<Marker>? = null
|
||||
|
||||
companion object {
|
||||
const val TAG = "OverMapView"
|
||||
@@ -155,18 +157,56 @@ class OverMapView @JvmOverloads constructor(
|
||||
}
|
||||
// =================必须通知高德地图生命周期的变化=================
|
||||
|
||||
/**
|
||||
* 隐藏右下角的重置View
|
||||
*/
|
||||
fun hideResetView() {
|
||||
overLayerView?.visibility = View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* siteLatLngs: 高德坐标集合
|
||||
* bitmap: Marker对应的图片
|
||||
* (anchorX,anchorY)为锚点坐标,各自取值范围为[0,1],默认值为(0.5,1)
|
||||
*/
|
||||
@MainThread
|
||||
fun drawSiteMarkers(siteLatLngs: List<LatLng>?, bitmap: Bitmap, anchorX: Float, anchorY: Float) {
|
||||
if (siteLatLngs.isNullOrEmpty()) return
|
||||
clearSiteMarkers()
|
||||
val markerOptionsList = ArrayList<MarkerOptions>()
|
||||
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) {
|
||||
mContext = context
|
||||
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)
|
||||
// 注册定位监听
|
||||
@@ -177,6 +217,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 +238,8 @@ class OverMapView @JvmOverloads constructor(
|
||||
}
|
||||
// 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效
|
||||
mAMap?.isTrafficEnabled = false
|
||||
mAMap?.showBuildings(true)
|
||||
mAMap?.animateCamera(CameraUpdateFactory.changeTilt(mTilt))
|
||||
}
|
||||
setUpMap()
|
||||
customOptions()
|
||||
@@ -350,7 +393,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun clearV2XMarkers() {
|
||||
private fun clearV2XMarkers() {
|
||||
if (currMarkerList != null) {
|
||||
for (marker in currMarkerList!!) {
|
||||
marker.destroy()
|
||||
@@ -428,6 +471,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
bitmap
|
||||
)
|
||||
)
|
||||
markerOption.anchor(0.18f, 0.98f)
|
||||
markerOption.zIndex(2f)
|
||||
posInfMap[latLng] = structureList
|
||||
markerOptionsList.add(markerOption)
|
||||
@@ -448,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)
|
||||
@@ -486,7 +530,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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user