merge code
This commit is contained in:
parent
895fa63691
commit
e4e8866ad6
@ -47,7 +47,8 @@ class MainActivity : BaseActivity() {
|
||||
this,
|
||||
binding.mainActivityMap,
|
||||
null,
|
||||
Constant.MAP_PATH
|
||||
Constant.MAP_PATH,
|
||||
Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite"
|
||||
)
|
||||
//关联生命周期
|
||||
binding.lifecycleOwner = this
|
||||
@ -69,8 +70,7 @@ class MainActivity : BaseActivity() {
|
||||
binding!!.viewModel!!.addSaveTrace(it)
|
||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||
})
|
||||
//显示轨迹图层
|
||||
mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -100,7 +100,8 @@ class MainActivity : BaseActivity() {
|
||||
* 打开相机预览
|
||||
*/
|
||||
fun openCamera() {
|
||||
binding!!.viewModel!!.onClickCameraButton(this)
|
||||
//显示轨迹图层
|
||||
//binding!!.viewModel!!.onClickCameraButton(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.RealmSet
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.videolan.libvlc.LibVlcUtil
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
@ -84,10 +85,7 @@ class MainViewModel @Inject constructor(
|
||||
if(niLocationList!=null&&niLocationList.size>0){
|
||||
|
||||
var niLocation = niLocationList[0]
|
||||
var doubleArray = doubleArrayOf()
|
||||
doubleArray[0] = niLocation.longitude
|
||||
doubleArray[1] = niLocation.latitude
|
||||
val geometry = GeometryTools.createGeometry(doubleArray)
|
||||
val geometry = GeometryTools.createGeometry(GeoPoint(niLocation.latitude,niLocation.longitude))
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
//隐藏轨迹图层
|
||||
|
@ -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) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user