diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt index 105345e6..8e7dae95 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt @@ -270,21 +270,10 @@ class MainViewModel @Inject constructor( */ @RequiresApi(Build.VERSION_CODES.N) private fun initLocation() { + //用于定位点存储到数据库 viewModelScope.launch(Dispatchers.Default) { //用于定位点捕捉道路 - mapController.locationLayerHandler.niLocationFlow.collectLatest { location -> - if (!isSelectRoad() && !GeometryTools.isCheckError( - location.longitude, location.latitude - ) - ) { - captureLink( - GeoPoint( - location.latitude, location.longitude - ) - ) - } - } mapController.locationLayerHandler.niLocationFlow.collect { location -> //过滤掉无效点 @@ -335,23 +324,23 @@ class MainViewModel @Inject constructor( } } } + } - //用于定位点捕捉道路 viewModelScope.launch(Dispatchers.Default) { + //用于定位点捕捉道路 mapController.locationLayerHandler.niLocationFlow.collectLatest { location -> if (!isSelectRoad() && !GeometryTools.isCheckError( - location.longitude, - location.latitude + location.longitude, location.latitude ) - ) captureLink( - GeoPoint( - location.latitude, - location.longitude + ) { + captureLink( + GeoPoint( + location.latitude, location.longitude + ) ) - ) + } } } - //显示轨迹图层 mapController.layerManagerHandler.showNiLocationLayer() diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt index 0743a60d..749b2d58 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt @@ -30,7 +30,7 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : // // } - val niLocationFlow = MutableSharedFlow(3) + val niLocationFlow = MutableSharedFlow(5) init { ///添加定位图层到地图,[NIMapView.LAYER_GROUPS.NAVIGATION] 是最上层layer组 @@ -67,18 +67,12 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) : val errorCode = it.locType mCurrentLocation = it mLocationLayer.setPosition(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) { getCurrentNiLocation()?.let { it1 -> - mContext.lifecycleScope.launch(Dispatchers.Default) { + mContext.lifecycleScope.launch { niLocationFlow.emit(it1) } - -// }// niLocationListener.call(it1) } } //第一次定位成功显示当前位置 if (this.bFirst) { diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt index c114af4a..0c4bb225 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt @@ -504,7 +504,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) : 0 -> { //角度不为0时需要预先设置marker样式并进行角度设置,否则使用图层默认的sym即可 //角度不为0时需要预先设置marker样式并进行角度设置,否则使用图层默认的sym即可 - if (direction != 0.0) { + if (direction > 0.0) { val symbolGpsTemp = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER, false) geoMarkerItem.marker = symbolGpsTemp @@ -519,7 +519,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) : 1 -> { //角度不为0时需要预先设置marker样式并进行角度设置,否则使用图层默认的sym即可 //角度不为0时需要预先设置marker样式并进行角度设置,否则使用图层默认的sym即可 - if (direction != 0.0) { + if (direction > 0.0) { val symbolLidarTemp = MarkerSymbol(niLocationBitmap1, MarkerSymbol.HotspotPlace.CENTER, false) geoMarkerItem.marker = symbolLidarTemp