merge code

This commit is contained in:
qiji4215
2023-04-21 15:06:19 +08:00
parent 895fa63691
commit e4e8866ad6
5 changed files with 23 additions and 28 deletions

View File

@@ -25,9 +25,9 @@ class NIMapController {
lateinit var viewportHandler: ViewportHandler
lateinit var measureLayerHandler: MeasureLayerHandler
fun init(context: AppCompatActivity, mapView: NIMapView, options: NIMapOptions? = null, mapPath: String) {
fun init(context: AppCompatActivity, mapView: NIMapView, options: NIMapOptions? = null, mapPath: String, tracePath: String) {
Constant.MAP_PATH = mapPath
layerManagerHandler = LayerManagerHandler(context, mapView)
layerManagerHandler = LayerManagerHandler(context, mapView, tracePath)
locationLayerHandler = LocationLayerHandler(context, mapView)
animationHandler = AnimationHandler(context, mapView)
markerHandle = MarkHandler(context, mapView)

View File

@@ -45,11 +45,10 @@ import java.util.*
/**
* Layer 操作
*/
open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
BaseHandler(context, mapView) {
open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePath: String) : BaseHandler(context, mapView) {
private var baseGroupLayer // 用于盛放所有基础底图的图层组,便于统一管理
: GroupLayer? = null
protected val mTracePath:String = tracePath
/**
* 默认文字颜色
*/
@@ -101,6 +100,13 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
//初始化之间数据图层
initQsRecordDataLayer()
mMapView.vtmMap.updateMap()
mapLifeNiLocationTileSource = MapLifeNiLocationTileSource(mContext, mTracePath)
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
labelNiLocationLayer = LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook(), 15)
// initMapLifeSource()
}
@@ -206,7 +212,7 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
var list = mutableListOf<QsRecordBean>()
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
val objects =realm.where<QsRecordBean>().findAll()
val objects = realm.where<QsRecordBean>().findAll()
list = realm.copyFromRealm(objects)
}
realm.close()
@@ -515,18 +521,10 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
}
//显示轨迹图层
fun showNiLocationLayer(dbName: String?) {
if (mapLifeNiLocationTileSource == null) {
mapLifeNiLocationTileSource = MapLifeNiLocationTileSource(mContext, dbName)
fun showNiLocationLayer() {
if(labelNiLocationLayer!=null){
addLayer(labelNiLocationLayer, NIMapView.LAYER_GROUPS.VECTOR)
}
if (vectorNiLocationTileLayer == null) {
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
}
if (labelNiLocationLayer == null) {
labelNiLocationLayer =
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook(), 15)
}
addLayer(labelNiLocationLayer, NIMapView.LAYER_GROUPS.VECTOR)
}
//隐藏轨迹图层

View File

@@ -57,9 +57,7 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
//获取定位类型、定位错误返回码具体信息可参照类参考中BDLocation类中的说明
val errorCode = it.locType
mCurrentLocation = it
mLocationLayer.setPosition(
it.latitude, it.longitude, it.radius
)
mLocationLayer.setPosition(it.latitude, it.longitude, it.radius)
Log.e("qj","location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
if(niLocationListener!=null){
getCurrentNiLocation()?.let { it1 -> niLocationListener.call(it1) }