地图模块适配

This commit is contained in:
jiaguofeng
2023-08-11 14:51:19 +08:00
parent 661816af8f
commit 74c0a81e68
30 changed files with 452 additions and 674 deletions

View File

@@ -1,6 +1,5 @@
package com.autonavi.nge;
import static com.amap.api.navi.AmapNaviPage.TAG;
import android.util.Log;
@@ -8,6 +7,7 @@ import com.zhidaoauto.map.sdk.inner.CompileConfig;
import com.zhidaoauto.map.sdk.inner.road.RoadResultController;
public class MapBox {
private static final String TAG = "MapBox";
static {
System.loadLibrary("map");
}

View File

@@ -1,58 +1,58 @@
package com.autonavi.nge.guidance
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zhidaoauto.map.sdk.R
import com.zhidaoauto.map.sdk.inner.CompileConfig
import java.text.DecimalFormat
class RouteBookAdapter : BaseQuickAdapter<RouteBookItem, BaseViewHolder>(R.layout.routebook_child_item) {
private val TAG = javaClass.simpleName
override fun getDefItemCount(): Int {
return super.getDefItemCount()
}
override fun convert(helper: BaseViewHolder, item: RouteBookItem) {
if (CompileConfig.DEBUG) {
Log.i(TAG, "routebookop--helper.adapterPosition:${helper.adapterPosition}")
}
when (helper.adapterPosition) {
0 -> {
helper.getView<LinearLayout>(R.id.routebook_child_item_info_ll).visibility = View.VISIBLE
helper.getView<ImageView>(R.id.imgView).setImageResource(NaviDirRes.getResID(501))
helper.getView<TextView>(R.id.orientation).text = "${item.routeName?:"起点"}出发"
helper.getView<TextView>(R.id.length).visibility = View.GONE
}
else -> {
helper.getView<TextView>(R.id.orientation).text = item.routeName
helper.getView<ImageView>(R.id.imgView).setImageResource(NaviDirRes.getResID(item.turnID))
if (item.routeName == "目的地") {
helper.getView<TextView>(R.id.length).visibility = View.GONE
} else {
helper.getView<TextView>(R.id.length).visibility = View.VISIBLE
val i = item.routelength
if (i > 1000) {
val df = DecimalFormat("#.0")
val string = df.format(i.toDouble() / 1000)
val strs = string.split(".")
if (strs.size >= 2 && strs[1] == "0") {
helper.getView<TextView>(R.id.length).text = """继续前行${strs[0]}km${item.routeSpeech}""".trimIndent()
} else {
helper.getView<TextView>(R.id.length).text = """继续前行${string}km${item.routeSpeech}""".trimIndent()
}
} else {
helper.getView<TextView>(R.id.length).text = """继续前行${i}m${item.routeSpeech}""".trimIndent()
}
}
}
}
}
}
//package com.autonavi.nge.guidance
//
//import android.util.Log
//import android.view.View
//import android.widget.ImageView
//import android.widget.LinearLayout
//import android.widget.TextView
//import com.chad.library.adapter.base.BaseQuickAdapter
//import com.chad.library.adapter.base.viewholder.BaseViewHolder
//import com.zhidaoauto.map.sdk.R
//import com.zhidaoauto.map.sdk.inner.CompileConfig
//import java.text.DecimalFormat
//
//class RouteBookAdapter : BaseQuickAdapter<RouteBookItem, BaseViewHolder>(R.layout.routebook_child_item) {
//
// private val TAG = javaClass.simpleName
//
//
// override fun getDefItemCount(): Int {
// return super.getDefItemCount()
// }
//
// override fun convert(helper: BaseViewHolder, item: RouteBookItem) {
// if (CompileConfig.DEBUG) {
// Log.i(TAG, "routebookop--helper.adapterPosition:${helper.adapterPosition}")
// }
// when (helper.adapterPosition) {
// 0 -> {
// helper.getView<LinearLayout>(R.id.routebook_child_item_info_ll).visibility = View.VISIBLE
// helper.getView<ImageView>(R.id.imgView).setImageResource(NaviDirRes.getResID(501))
// helper.getView<TextView>(R.id.orientation).text = "从${item.routeName?:"起点"}出发"
// helper.getView<TextView>(R.id.length).visibility = View.GONE
// }
// else -> {
// helper.getView<TextView>(R.id.orientation).text = item.routeName
// helper.getView<ImageView>(R.id.imgView).setImageResource(NaviDirRes.getResID(item.turnID))
// if (item.routeName == "目的地") {
// helper.getView<TextView>(R.id.length).visibility = View.GONE
// } else {
// helper.getView<TextView>(R.id.length).visibility = View.VISIBLE
// val i = item.routelength
// if (i > 1000) {
// val df = DecimalFormat("#.0")
// val string = df.format(i.toDouble() / 1000)
// val strs = string.split(".")
// if (strs.size >= 2 && strs[1] == "0") {
// helper.getView<TextView>(R.id.length).text = """继续前行${strs[0]}km${item.routeSpeech}""".trimIndent()
// } else {
// helper.getView<TextView>(R.id.length).text = """继续前行${string}km${item.routeSpeech}""".trimIndent()
// }
// } else {
// helper.getView<TextView>(R.id.length).text = """继续前行${i}m${item.routeSpeech}""".trimIndent()
// }
// }
// }
// }
// }
//}

View File

@@ -113,8 +113,8 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
// 地图POI是否允许点击。
private var mPoiTouchEnable = true
private var viewWidth = 1920
private var viewHeight = 1040
private var mViewWidth = 1920
private var mViewHeight = 1040
var mLonLat: LonLat? = null
private val ZOOM_CHANGE = 0x7F
private val FOCUS_CHANGE = 0x9F
@@ -123,6 +123,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
private val RENDER_COMPLETE = 0x15F
private val LOAD_COMPLETE = 0x17F
private val RENDER_CHANGE = 0x19F
private val INIT_COMPLETE = 0x21F
private val LISTENER_TYPE_SCREEN = 0x5F
private val DELAY_TIME: Long = 500
private val VELOCITY_MEASURE: Float = 3000f
@@ -183,6 +184,13 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
// CommonController.instance.naviAutoView?.mNaviViewListener?.onNaviViewLoaded()
}
INIT_COMPLETE -> {
if (DEBUG) {
Log.i(TAG, "mapop--init complete-start")
}
mEventController?.dispatchMapLoadedInitListener()
}
else -> {
}
}
@@ -628,7 +636,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if(mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR) {
mMapController?.setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
}
mEventController?.dispatchMapLoadedInitListener()
mHandler.sendEmptyMessage(INIT_COMPLETE)
if(DEBUG){
Log.i(TAG, "mapop-surfaceop--onDrawFramethreadop:${Thread.currentThread().id}")
}
@@ -658,14 +666,14 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if (DEBUG) {
Log.i(TAG, "mapop--surfaceop--resize:${width},${height}")
}
if (width == 0 || height == 0 || (viewWidth == width && viewHeight == height)) {
if (width == 0 || height == 0 || (mViewWidth == width && mViewHeight == height)) {
return
}
// gl.glViewport(0, 0, width, height)
viewWidth = width
viewHeight = height
MapTools.viewHeight = viewWidth
MapTools.viewWidth = viewHeight
mViewWidth = width
mViewHeight = height
MapTools.viewHeight = mViewWidth
MapTools.viewWidth = mViewHeight
if (DEBUG) {
Log.i(TAG, "mapop--surfaceop--resize:${width},${height}")
}
@@ -1129,6 +1137,14 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
return isTouchingFlag
}
override fun getViewWidth(): Int{
return mViewWidth
}
override fun getViewHeight(): Int{
return mViewHeight
}
override fun isCanZoom(): Boolean {
return isCanZoom
}
@@ -1232,10 +1248,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
mStylePath = path
}
override fun resizeP(w: Int, h: Int) {
mMapEngine.resize(w, h)
}
override fun renderP() {
mMapEngine.render()
}
@@ -1324,7 +1336,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
init {
System.loadLibrary("map")
System.loadLibrary("common")
}
init {