merge code
This commit is contained in:
parent
895fa63691
commit
e4e8866ad6
@ -47,7 +47,8 @@ class MainActivity : BaseActivity() {
|
|||||||
this,
|
this,
|
||||||
binding.mainActivityMap,
|
binding.mainActivityMap,
|
||||||
null,
|
null,
|
||||||
Constant.MAP_PATH
|
Constant.MAP_PATH,
|
||||||
|
Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite"
|
||||||
)
|
)
|
||||||
//关联生命周期
|
//关联生命周期
|
||||||
binding.lifecycleOwner = this
|
binding.lifecycleOwner = this
|
||||||
@ -69,8 +70,7 @@ class MainActivity : BaseActivity() {
|
|||||||
binding!!.viewModel!!.addSaveTrace(it)
|
binding!!.viewModel!!.addSaveTrace(it)
|
||||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||||
})
|
})
|
||||||
//显示轨迹图层
|
mapController.layerManagerHandler.showNiLocationLayer()
|
||||||
mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -100,7 +100,8 @@ class MainActivity : BaseActivity() {
|
|||||||
* 打开相机预览
|
* 打开相机预览
|
||||||
*/
|
*/
|
||||||
fun openCamera() {
|
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 com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.realm.RealmSet
|
import io.realm.RealmSet
|
||||||
|
import org.oscim.core.GeoPoint
|
||||||
import org.videolan.libvlc.LibVlcUtil
|
import org.videolan.libvlc.LibVlcUtil
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -84,10 +85,7 @@ class MainViewModel @Inject constructor(
|
|||||||
if(niLocationList!=null&&niLocationList.size>0){
|
if(niLocationList!=null&&niLocationList.size>0){
|
||||||
|
|
||||||
var niLocation = niLocationList[0]
|
var niLocation = niLocationList[0]
|
||||||
var doubleArray = doubleArrayOf()
|
val geometry = GeometryTools.createGeometry(GeoPoint(niLocation.latitude,niLocation.longitude))
|
||||||
doubleArray[0] = niLocation.longitude
|
|
||||||
doubleArray[1] = niLocation.latitude
|
|
||||||
val geometry = GeometryTools.createGeometry(doubleArray)
|
|
||||||
val tileX = RealmSet<Int>()
|
val tileX = RealmSet<Int>()
|
||||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||||
val tileY = RealmSet<Int>()
|
val tileY = RealmSet<Int>()
|
||||||
|
@ -25,9 +25,9 @@ class NIMapController {
|
|||||||
lateinit var viewportHandler: ViewportHandler
|
lateinit var viewportHandler: ViewportHandler
|
||||||
lateinit var measureLayerHandler: MeasureLayerHandler
|
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
|
Constant.MAP_PATH = mapPath
|
||||||
layerManagerHandler = LayerManagerHandler(context, mapView)
|
layerManagerHandler = LayerManagerHandler(context, mapView, tracePath)
|
||||||
locationLayerHandler = LocationLayerHandler(context, mapView)
|
locationLayerHandler = LocationLayerHandler(context, mapView)
|
||||||
animationHandler = AnimationHandler(context, mapView)
|
animationHandler = AnimationHandler(context, mapView)
|
||||||
markerHandle = MarkHandler(context, mapView)
|
markerHandle = MarkHandler(context, mapView)
|
||||||
|
@ -45,11 +45,10 @@ import java.util.*
|
|||||||
/**
|
/**
|
||||||
* Layer 操作
|
* Layer 操作
|
||||||
*/
|
*/
|
||||||
open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePath: String) : BaseHandler(context, mapView) {
|
||||||
BaseHandler(context, mapView) {
|
|
||||||
private var baseGroupLayer // 用于盛放所有基础底图的图层组,便于统一管理
|
private var baseGroupLayer // 用于盛放所有基础底图的图层组,便于统一管理
|
||||||
: GroupLayer? = null
|
: GroupLayer? = null
|
||||||
|
protected val mTracePath:String = tracePath
|
||||||
/**
|
/**
|
||||||
* 默认文字颜色
|
* 默认文字颜色
|
||||||
*/
|
*/
|
||||||
@ -101,6 +100,13 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
//初始化之间数据图层
|
//初始化之间数据图层
|
||||||
initQsRecordDataLayer()
|
initQsRecordDataLayer()
|
||||||
mMapView.vtmMap.updateMap()
|
mMapView.vtmMap.updateMap()
|
||||||
|
|
||||||
|
mapLifeNiLocationTileSource = MapLifeNiLocationTileSource(mContext, mTracePath)
|
||||||
|
|
||||||
|
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
|
||||||
|
|
||||||
|
labelNiLocationLayer = LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook(), 15)
|
||||||
|
|
||||||
// initMapLifeSource()
|
// initMapLifeSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +212,7 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
var list = mutableListOf<QsRecordBean>()
|
var list = mutableListOf<QsRecordBean>()
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
val objects =realm.where<QsRecordBean>().findAll()
|
val objects = realm.where<QsRecordBean>().findAll()
|
||||||
list = realm.copyFromRealm(objects)
|
list = realm.copyFromRealm(objects)
|
||||||
}
|
}
|
||||||
realm.close()
|
realm.close()
|
||||||
@ -515,19 +521,11 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
//显示轨迹图层
|
//显示轨迹图层
|
||||||
fun showNiLocationLayer(dbName: String?) {
|
fun showNiLocationLayer() {
|
||||||
if (mapLifeNiLocationTileSource == null) {
|
if(labelNiLocationLayer!=null){
|
||||||
mapLifeNiLocationTileSource = MapLifeNiLocationTileSource(mContext, dbName)
|
|
||||||
}
|
|
||||||
if (vectorNiLocationTileLayer == null) {
|
|
||||||
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
|
|
||||||
}
|
|
||||||
if (labelNiLocationLayer == null) {
|
|
||||||
labelNiLocationLayer =
|
|
||||||
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook(), 15)
|
|
||||||
}
|
|
||||||
addLayer(labelNiLocationLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
addLayer(labelNiLocationLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//隐藏轨迹图层
|
//隐藏轨迹图层
|
||||||
fun hideNiLocationLayer() {
|
fun hideNiLocationLayer() {
|
||||||
|
@ -57,9 +57,7 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : Bas
|
|||||||
//获取定位类型、定位错误返回码,具体信息可参照类参考中BDLocation类中的说明
|
//获取定位类型、定位错误返回码,具体信息可参照类参考中BDLocation类中的说明
|
||||||
val errorCode = it.locType
|
val errorCode = it.locType
|
||||||
mCurrentLocation = it
|
mCurrentLocation = it
|
||||||
mLocationLayer.setPosition(
|
mLocationLayer.setPosition(it.latitude, it.longitude, it.radius)
|
||||||
it.latitude, it.longitude, it.radius
|
|
||||||
)
|
|
||||||
Log.e("qj","location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
|
Log.e("qj","location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
|
||||||
if(niLocationListener!=null){
|
if(niLocationListener!=null){
|
||||||
getCurrentNiLocation()?.let { it1 -> niLocationListener.call(it1) }
|
getCurrentNiLocation()?.let { it1 -> niLocationListener.call(it1) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user