Commit baa0be8d authored by 马乐's avatar 马乐

1.增加地图annotation

parent caa4d969
...@@ -2,14 +2,22 @@ package com.waytous.anticollision ...@@ -2,14 +2,22 @@ package com.waytous.anticollision
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.viewModels
import com.blankj.utilcode.util.BarUtils import com.blankj.utilcode.util.BarUtils
import com.blankj.utilcode.util.ColorUtils import com.blankj.utilcode.util.ColorUtils
import com.waytous.anticollision.databinding.ActivitySplashBinding import com.waytous.anticollision.databinding.ActivitySplashBinding
import com.waytous.anticollision.repository.MainRepository
import com.waytous.anticollision.ui.MainActivity import com.waytous.anticollision.ui.MainActivity
import com.waytous.anticollision.ui.MainViewModel
class SplashActivity : AppCompatActivity() { class SplashActivity : AppCompatActivity() {
private val mapModel: MainViewModel by viewModels{
MainViewModel.MainViewModelFactory(MainRepository(this))
}
private lateinit var binding:ActivitySplashBinding private lateinit var binding:ActivitySplashBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -29,4 +37,6 @@ class SplashActivity : AppCompatActivity() { ...@@ -29,4 +37,6 @@ class SplashActivity : AppCompatActivity() {
},2000) },2000)
} }
} }
\ No newline at end of file
package com.waytous.anticollision.ui package com.waytous.anticollision.ui
import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater
import android.view.View import android.view.View
import androidx.appcompat.widget.AppCompatTextView import android.view.ViewGroup
import androidx.asynclayoutinflater.view.AsyncLayoutInflater
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
...@@ -19,20 +19,29 @@ import com.mapbox.maps.extension.style.layers.generated.circleLayer ...@@ -19,20 +19,29 @@ import com.mapbox.maps.extension.style.layers.generated.circleLayer
import com.mapbox.maps.extension.style.layers.generated.fillLayer import com.mapbox.maps.extension.style.layers.generated.fillLayer
import com.mapbox.maps.extension.style.layers.generated.lineLayer import com.mapbox.maps.extension.style.layers.generated.lineLayer
import com.mapbox.maps.extension.style.layers.generated.symbolLayer import com.mapbox.maps.extension.style.layers.generated.symbolLayer
import com.mapbox.maps.extension.style.layers.properties.generated.* import com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor
import com.mapbox.maps.extension.style.layers.properties.generated.LineCap
import com.mapbox.maps.extension.style.layers.properties.generated.LineJoin
import com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
import com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import com.mapbox.maps.extension.style.style import com.mapbox.maps.extension.style.style
import com.mapbox.maps.plugin.annotation.AnnotationPlugin
import com.mapbox.maps.plugin.annotation.annotations import com.mapbox.maps.plugin.annotation.annotations
import com.mapbox.maps.plugin.annotation.generated.PointAnnotation import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
import com.mapbox.maps.plugin.scalebar.scalebar import com.mapbox.maps.plugin.attribution.attribution
import com.mapbox.maps.plugin.compass.compass
import com.mapbox.maps.plugin.logo.logo
import com.mapbox.maps.viewannotation.ViewAnnotationManager import com.mapbox.maps.viewannotation.ViewAnnotationManager
import com.mapbox.maps.viewannotation.viewAnnotationOptions import com.mapbox.maps.viewannotation.viewAnnotationOptions
import com.waytous.anticollision.R import com.waytous.anticollision.R
import com.waytous.anticollision.api.ApiService import com.waytous.anticollision.api.ApiService
import com.waytous.anticollision.databinding.CurrentVehicleViewAnnotationLayoutBinding import com.waytous.anticollision.databinding.CurrentVehicleViewAnnotationLayoutBinding
import com.waytous.anticollision.databinding.LayoutMapBoxBinding
import com.waytous.anticollision.databinding.OtherVehicleViewAnnotationLayoutBinding import com.waytous.anticollision.databinding.OtherVehicleViewAnnotationLayoutBinding
import com.waytous.anticollision.repository.MainRepository import com.waytous.anticollision.repository.MainRepository
import com.waytous.anticollision.utils.BitmapUtils import com.waytous.anticollision.utils.BitmapUtils
...@@ -55,36 +64,60 @@ open class BaseFragment : Fragment() { ...@@ -55,36 +64,60 @@ open class BaseFragment : Fragment() {
BitmapUtils.bitmapFromDrawableRes(requireContext(),R.drawable.other_vehicle_normal) BitmapUtils.bitmapFromDrawableRes(requireContext(),R.drawable.other_vehicle_normal)
} }
private val asyncInflater by lazy {
AsyncLayoutInflater(requireContext())
}
private lateinit var layoutMapBoxBinding: LayoutMapBoxBinding
private lateinit var viewAnnotation: View private lateinit var viewAnnotation: View
private lateinit var annotationPlugin: AnnotationPlugin
private lateinit var viewAnnotationManager: ViewAnnotationManager private lateinit var viewAnnotationManager: ViewAnnotationManager
private lateinit var pointAnnotationManager: PointAnnotationManager private lateinit var pointAnnotationManager: PointAnnotationManager
private lateinit var pointAnnotation: PointAnnotation private lateinit var pointAnnotation: PointAnnotation
private val cameraOptions:CameraOptions by lazy {
CameraOptions.Builder().center(
Point.fromLngLat(
MainViewModel.LONGITUDE,
MainViewModel.LATITUDE
)).zoom(14.0).build()
}
companion object{ companion object{
private val scaleLengths = listOf(5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000) private val scaleLengths = listOf(5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000)
private const val MINIMUM_ZOOM_LEVEL = 11.0 const val MINIMUM_ZOOM_LEVEL = 11.0
private const val MAXIMUM_ZOOM_LEVEL = 26.0 const val MAXIMUM_ZOOM_LEVEL = 26.0
const val DEFAULT_ZOOM_LEVEL = 14.0
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreateView(
super.onCreate(savedInstanceState) inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
layoutMapBoxBinding = LayoutMapBoxBinding.inflate(LayoutInflater.from(requireContext()))
layoutMapBoxBinding.mapView.run {
logo.enabled = false
compass.enabled = false
attribution.enabled = false
}
return super.onCreateView(inflater, container, savedInstanceState)
} }
fun initAnnotationManager(mapView:MapView){ private fun initAnnotationManager(mapView:MapView){
annotationPlugin = mapView.annotations
viewAnnotationManager = mapView.viewAnnotationManager viewAnnotationManager = mapView.viewAnnotationManager
pointAnnotationManager = mapView.annotations.createPointAnnotationManager() pointAnnotationManager = annotationPlugin.createPointAnnotationManager()
} }
fun updateMapBox(mapView:MapView){ fun updateMapBox(mapView:MapView){
mapView.getMapboxMap().setCamera( mapView.getMapboxMap().setCamera(
CameraOptions.Builder().center( cameraOptions
Point.fromLngLat(
MainViewModel.LONGITUDE,
MainViewModel.LATITUDE
)).zoom(14.0).build()
) )
lifecycleScope.launch{ lifecycleScope.launch{
withContext(Dispatchers.IO){ withContext(Dispatchers.IO){
...@@ -379,52 +412,22 @@ open class BaseFragment : Fragment() { ...@@ -379,52 +412,22 @@ open class BaseFragment : Fragment() {
} }
} }
){ ){
// prepareAnnotationMarker(mapView,iconCurrentNormalVehicleBitmap!!) initAnnotationManager(mapView)
// prepareViewAnnotation()
val otherAnnotation = VehicleAnnotation("KK-01",36,25, val otherAnnotation = VehicleAnnotation("KK-01",36,25,
Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE),true) Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE),true)
addCurrentVehicleAnnotation(otherAnnotation) updateCurrentVehicleAnnotation(otherAnnotation)
val otherAnnotation1 = VehicleAnnotation("KK-02",24,25,Point.fromLngLat(119.76019,49.37932),true) val otherAnnotation1 = VehicleAnnotation("KK-02",24,25,Point.fromLngLat(119.76739,49.37722),true)
addOtherVehicleAnnotation(otherAnnotation1)
val otherAnnotation2 = VehicleAnnotation("KK-03",36,20,Point.fromLngLat(119.75694,49.38632),true) val otherAnnotation2 = VehicleAnnotation("KK-03",36,20,Point.fromLngLat(119.75694,49.38632),true)
addOtherVehicleAnnotation(otherAnnotation2) val others = listOf(otherAnnotation1,otherAnnotation2)
addOtherVehicleAnnotations(others)
} }
} }
} }
} }
} }
fun updateCurrentVehicleAnnotation(otherAnnotation: VehicleAnnotation){
@SuppressLint("SetTextI18n")
fun prepareViewAnnotation() {
viewAnnotation = viewAnnotationManager.addViewAnnotation(
resId = R.layout.current_vehicle_view_annotation_layout,
options = viewAnnotationOptions {
geometry(Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE))
associatedFeatureId(pointAnnotation.featureIdentifier)
anchor(ViewAnnotationAnchor.BOTTOM)
offsetY((pointAnnotation.iconImageBitmap?.height!!*0.25).toInt())
}
)
val binding = CurrentVehicleViewAnnotationLayoutBinding.bind(viewAnnotation)
binding.annotationCurrentVehicleNo.text = context?.getString(R.string.annotation_vehicle_no,"KK-001")
binding.annotationCurrentVehicleSpeed.text = context?.getString(R.string.annotation_vehicle_speed,36)
}
fun prepareAnnotationMarker(mapView: MapView, iconBitmap: Bitmap) {
val annotationPlugin = mapView.annotations
val pointAnnotationOptions: PointAnnotationOptions = PointAnnotationOptions()
.withPoint(Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE))
.withIconImage(iconBitmap)
.withIconSize(0.25)
.withIconAnchor(IconAnchor.BOTTOM)
.withDraggable(false)
pointAnnotationManager = annotationPlugin.createPointAnnotationManager()
pointAnnotation = pointAnnotationManager.create(pointAnnotationOptions)
}
fun addCurrentVehicleAnnotation(otherAnnotation: VehicleAnnotation){
val pointAnnotationOptions: PointAnnotationOptions = PointAnnotationOptions() val pointAnnotationOptions: PointAnnotationOptions = PointAnnotationOptions()
.withPoint(Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE)) .withPoint(otherAnnotation.point)
.withIconImage(iconCurrentNormalVehicleBitmap!!) .withIconImage(iconCurrentNormalVehicleBitmap!!)
.withIconSize(0.25) .withIconSize(0.25)
.withIconAnchor(IconAnchor.BOTTOM) .withIconAnchor(IconAnchor.BOTTOM)
...@@ -433,19 +436,21 @@ open class BaseFragment : Fragment() { ...@@ -433,19 +436,21 @@ open class BaseFragment : Fragment() {
val viewAnnotation = viewAnnotationManager.addViewAnnotation( val viewAnnotation = viewAnnotationManager.addViewAnnotation(
resId = R.layout.current_vehicle_view_annotation_layout, resId = R.layout.current_vehicle_view_annotation_layout,
options = viewAnnotationOptions { options = viewAnnotationOptions {
geometry(Point.fromLngLat(MainViewModel.LONGITUDE,MainViewModel.LATITUDE)) geometry(otherAnnotation.point)
associatedFeatureId(pointAnnotation.featureIdentifier) associatedFeatureId(pointAnnotation.featureIdentifier)
anchor(ViewAnnotationAnchor.BOTTOM) anchor(ViewAnnotationAnchor.BOTTOM)
offsetY((pointAnnotation.iconImageBitmap?.height!!*0.25).toInt()) offsetY((pointAnnotation.iconImageBitmap?.height!!*0.25).toInt())
allowOverlap(true)
} }
) )
val binding = CurrentVehicleViewAnnotationLayoutBinding.bind(viewAnnotation) val binding = CurrentVehicleViewAnnotationLayoutBinding.bind(viewAnnotation)
binding.annotationCurrentVehicleNo.text = context?.getString(R.string.annotation_vehicle_no,"KK-001") binding.annotationCurrentVehicleNo.text = context?.getString(R.string.annotation_vehicle_no,"KK-001")
binding.annotationCurrentVehicleSpeed.text = context?.getString(R.string.annotation_vehicle_speed,36) binding.annotationCurrentVehicleSpeed.text = context?.getString(R.string.annotation_vehicle_speed,36)
} }
fun addOtherVehicleAnnotation(otherAnnotation: VehicleAnnotation){ fun addOtherVehicleAnnotations(others: List<VehicleAnnotation>){
val pointAnnotationOptions: PointAnnotationOptions = PointAnnotationOptions() others.forEach {vehicle->
.withPoint(otherAnnotation.point) val pointAnnotationOptions: PointAnnotationOptions = PointAnnotationOptions()
.withPoint(vehicle.point)
.withIconImage(iconOtherAlarmVehicleBitmap!!) .withIconImage(iconOtherAlarmVehicleBitmap!!)
.withIconSize(0.25) .withIconSize(0.25)
.withIconAnchor(IconAnchor.BOTTOM) .withIconAnchor(IconAnchor.BOTTOM)
...@@ -454,18 +459,17 @@ open class BaseFragment : Fragment() { ...@@ -454,18 +459,17 @@ open class BaseFragment : Fragment() {
val viewAnnotation = viewAnnotationManager.addViewAnnotation( val viewAnnotation = viewAnnotationManager.addViewAnnotation(
resId = R.layout.other_vehicle_view_annotation_layout, resId = R.layout.other_vehicle_view_annotation_layout,
options = viewAnnotationOptions { options = viewAnnotationOptions {
geometry(otherAnnotation.point) geometry(vehicle.point)
associatedFeatureId(otherAnnotation.vehicleNo) // associatedFeatureId(pointAnnotation.featureIdentifier)
anchor(ViewAnnotationAnchor.BOTTOM) anchor(ViewAnnotationAnchor.BOTTOM)
offsetY((pointAnnotation.iconImageBitmap?.height!!*0.25).toInt()) offsetY((pointAnnotation.iconImageBitmap?.height!!*0.25).toInt())
allowOverlap(true)
} }
) )
val binding = OtherVehicleViewAnnotationLayoutBinding.bind(viewAnnotation) val binding = OtherVehicleViewAnnotationLayoutBinding.bind(viewAnnotation)
binding.annotationOtherVehicleNo.text = context?.getString(R.string.annotation_vehicle_no,otherAnnotation.vehicleNo) binding.annotationOtherVehicleNo.text = context?.getString(R.string.annotation_vehicle_no,vehicle.vehicleNo)
binding.annotationOtherVehicleSpeed.text = 24.toString() binding.annotationOtherVehicleSpeed.text = vehicle.speed.toString()
binding.annotationOtherVehicleDistance.text = 25.toString() binding.annotationOtherVehicleDistance.text = vehicle.distance.toString()
}
} }
} }
\ No newline at end of file
package com.waytous.anticollision.ui.home package com.waytous.anticollision.ui.home
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.text.SpannableString import android.text.SpannableString
import android.util.Log
import android.view.Gravity import android.view.Gravity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout import androidx.databinding.adapters.ZoomControlsBindingAdapter
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.lifecycle.* import androidx.lifecycle.ViewModelProvider
import com.blankj.utilcode.util.LogUtils import com.blankj.utilcode.util.LogUtils
import com.mapbox.geojson.Point
import com.mapbox.maps.CameraOptions import com.mapbox.maps.CameraOptions
import com.mapbox.maps.MapView import com.mapbox.maps.MapView
import com.mapbox.maps.MapboxMap import com.mapbox.maps.extension.style.expressions.dsl.generated.image
import com.mapbox.maps.extension.style.expressions.dsl.generated.get import com.mapbox.maps.extension.style.layers.generated.backgroundLayer
import com.mapbox.maps.extension.style.layers.generated.circleLayer import com.mapbox.maps.plugin.animation.camera
import com.mapbox.maps.extension.style.layers.generated.fillLayer
import com.mapbox.maps.extension.style.layers.generated.lineLayer
import com.mapbox.maps.extension.style.layers.generated.symbolLayer
import com.mapbox.maps.extension.style.layers.properties.generated.LineCap
import com.mapbox.maps.extension.style.layers.properties.generated.LineJoin
import com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
import com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import com.mapbox.maps.extension.style.style
import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import com.mapbox.maps.plugin.attribution.attribution import com.mapbox.maps.plugin.attribution.attribution
import com.mapbox.maps.plugin.compass.compass import com.mapbox.maps.plugin.compass.compass
import com.mapbox.maps.plugin.logo.logo import com.mapbox.maps.plugin.logo.logo
import com.mapbox.maps.plugin.scalebar.scalebar import com.mapbox.maps.plugin.scalebar.scalebar
import com.mapbox.maps.viewannotation.ViewAnnotationManager
import com.waytous.anticollision.R import com.waytous.anticollision.R
import com.waytous.anticollision.databinding.FragmentHomeBinding import com.waytous.anticollision.databinding.FragmentHomeBinding
import com.waytous.anticollision.repository.MainRepository import com.waytous.anticollision.repository.MainRepository
...@@ -44,22 +26,8 @@ import com.waytous.anticollision.ui.BaseFragment ...@@ -44,22 +26,8 @@ import com.waytous.anticollision.ui.BaseFragment
import com.waytous.anticollision.ui.MainViewModel import com.waytous.anticollision.ui.MainViewModel
import com.waytous.anticollision.ui.view.MoreFeaturesPopup import com.waytous.anticollision.ui.view.MoreFeaturesPopup
import com.waytous.anticollision.ui.view.WorkStatusEditPopup import com.waytous.anticollision.ui.view.WorkStatusEditPopup
import com.waytous.anticollision.utils.addBarricadeSource
import com.waytous.anticollision.utils.addDiggingWorkAreaSource
import com.waytous.anticollision.utils.addDumpAreaSource
import com.waytous.anticollision.utils.addElectronicFenceSource
import com.waytous.anticollision.utils.addLaneNodeSource
import com.waytous.anticollision.utils.addLaneSource
import com.waytous.anticollision.utils.addObstaclesSource
import com.waytous.anticollision.utils.addParkSpotSource
import com.waytous.anticollision.utils.addRunnableAreaSource
import com.waytous.anticollision.utils.addStaticObjectsSource
import com.waytous.anticollision.utils.addStationAreaSource
import com.waytous.anticollision.utils.addTruckPathSource
import com.waytous.anticollision.utils.addWetAreaSource
import com.waytous.anticollision.utils.setTextSize import com.waytous.anticollision.utils.setTextSize
import kotlinx.coroutines.flow.collect import java.math.BigDecimal
import kotlinx.coroutines.launch
class HomeFragment : BaseFragment() { class HomeFragment : BaseFragment() {
...@@ -75,6 +43,8 @@ class HomeFragment : BaseFragment() { ...@@ -75,6 +43,8 @@ class HomeFragment : BaseFragment() {
private lateinit var workStatusEditPopup: WorkStatusEditPopup private lateinit var workStatusEditPopup: WorkStatusEditPopup
private val mapModel: MainViewModel by viewModels { private val mapModel: MainViewModel by viewModels {
MainViewModel.MainViewModelFactory(MainRepository(requireContext())) MainViewModel.MainViewModelFactory(MainRepository(requireContext()))
} }
...@@ -103,9 +73,31 @@ class HomeFragment : BaseFragment() { ...@@ -103,9 +73,31 @@ class HomeFragment : BaseFragment() {
it.logo.enabled = false it.logo.enabled = false
it.compass.enabled = false it.compass.enabled = false
it.attribution.enabled = false it.attribution.enabled = false
it.scalebar.enabled = false
} }
initAnnotationManager(mapView) binding.defaultMapLayout.zoomIn.setOnClickListener {
LogUtils.d("zoomIn level = ${mapView.getMapboxMap().cameraState.zoom}")
val zoomLevel = BigDecimal(mapView.getMapboxMap().cameraState.zoom).minus(BigDecimal(0.1.toString()))
when(BigDecimal(MINIMUM_ZOOM_LEVEL.toString()).compareTo(zoomLevel)){
-1->{
mapView.getMapboxMap().setCamera(CameraOptions.Builder().zoom(zoomLevel.toDouble()).build())
}
else ->{
mapView.getMapboxMap().setCamera(CameraOptions.Builder().zoom(DEFAULT_ZOOM_LEVEL).build())
}
}
}
binding.defaultMapLayout.zoomOut.setOnClickListener {
LogUtils.d("zoomOut level = ${mapView.getMapboxMap().cameraState.zoom}")
val zoomLevel = BigDecimal(mapView.getMapboxMap().cameraState.zoom).add(BigDecimal(0.1.toString()))
when(BigDecimal(MAXIMUM_ZOOM_LEVEL.toString()).compareTo(zoomLevel)){
-1->{
mapView.getMapboxMap().setCamera(CameraOptions.Builder().zoom(DEFAULT_ZOOM_LEVEL).build())
}
else ->{
mapView.getMapboxMap().setCamera(CameraOptions.Builder().zoom(zoomLevel.toDouble()).build())
}
}
}
updateMapBox(mapView) updateMapBox(mapView)
mapView.addRendererSetupErrorListener { error -> mapView.addRendererSetupErrorListener { error ->
LogUtils.e("RendererSetupErrorListener:${error}") LogUtils.e("RendererSetupErrorListener:${error}")
......
...@@ -17,6 +17,10 @@ import androidx.core.graphics.drawable.DrawableCompat ...@@ -17,6 +17,10 @@ import androidx.core.graphics.drawable.DrawableCompat
import com.blankj.utilcode.util.LogUtils import com.blankj.utilcode.util.LogUtils
import com.mapbox.maps.Style import com.mapbox.maps.Style
import com.mapbox.maps.extension.style.expressions.dsl.generated.get import com.mapbox.maps.extension.style.expressions.dsl.generated.get
import com.mapbox.maps.extension.style.layers.generated.CircleLayer
import com.mapbox.maps.extension.style.layers.generated.FillLayer
import com.mapbox.maps.extension.style.layers.generated.LineLayer
import com.mapbox.maps.extension.style.layers.generated.SymbolLayer
import com.mapbox.maps.extension.style.layers.generated.circleLayer import com.mapbox.maps.extension.style.layers.generated.circleLayer
import com.mapbox.maps.extension.style.layers.generated.fillLayer import com.mapbox.maps.extension.style.layers.generated.fillLayer
import com.mapbox.maps.extension.style.layers.generated.lineLayer import com.mapbox.maps.extension.style.layers.generated.lineLayer
...@@ -27,6 +31,7 @@ import com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor ...@@ -27,6 +31,7 @@ import com.mapbox.maps.extension.style.layers.properties.generated.TextAnchor
import com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment import com.mapbox.maps.extension.style.layers.properties.generated.TextRotationAlignment
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import com.mapbox.maps.extension.style.sources.addSource import com.mapbox.maps.extension.style.sources.addSource
import com.mapbox.maps.extension.style.sources.generated.GeoJsonSource
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import com.waytous.anticollision.ui.MainViewModel import com.waytous.anticollision.ui.MainViewModel
...@@ -85,354 +90,406 @@ fun Context.getBitmapFromVectorDrawable(drawableId:Int,scale:Int = 2): Bitmap? { ...@@ -85,354 +90,406 @@ fun Context.getBitmapFromVectorDrawable(drawableId:Int,scale:Int = 2): Bitmap? {
return bitmap return bitmap
} }
fun Style.addRunnableAreaSource(source: String){ fun Style.addRunnableAreaSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addRunnableAreaSource") LogUtils.dTag("MapBoxLayout","addRunnableAreaSource")
addSource{ return geoJsonSource(MainViewModel.RUNNABLE_AREA_SOURCE){
geoJsonSource(MainViewModel.RUNNABLE_AREA_SOURCE) { data(source)
data(source) }
} }
fillLayer(
MainViewModel.RUNNABLE_AREA_LAYER, fun Style.addRunnableAreaLayer():FillLayer{
MainViewModel.RUNNABLE_AREA_SOURCE LogUtils.dTag("MapBoxLayout","addRunnableAreaLayer")
){ return fillLayer(
fillColor("#98a0a0") MainViewModel.RUNNABLE_AREA_LAYER,
fillOpacity(0.85) MainViewModel.RUNNABLE_AREA_SOURCE
fillOutlineColor("#FFFF00") ){
visibility(Visibility.VISIBLE) fillColor("#98a0a0")
} fillOpacity(0.85)
} fillOutlineColor("#FFFF00")
} visibility(Visibility.VISIBLE)
}
fun Style.addLaneSource(source: String){ }
fun Style.addLaneSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addLaneSource") LogUtils.dTag("MapBoxLayout","addLaneSource")
addSource{ return geoJsonSource(MainViewModel.RUNNABLE_AREA_SOURCE){
geoJsonSource(MainViewModel.LANE_SOURCE) { data(source)
data(source) }
} }
lineLayer(
MainViewModel.LANE_LAYER, fun Style.addLaneLayer():LineLayer{
MainViewModel.LANE_SOURCE LogUtils.dTag("MapBoxLayout","addLaneLayer")
){ return lineLayer(
lineColor("white") MainViewModel.LANE_LAYER,
lineWidth(3.0) MainViewModel.LANE_SOURCE
lineJoin(LineJoin.ROUND) ){
lineCap(LineCap.ROUND) lineColor("white")
visibility(Visibility.VISIBLE) lineWidth(3.0)
} lineJoin(LineJoin.ROUND)
} lineCap(LineCap.ROUND)
} visibility(Visibility.VISIBLE)
}
fun Style.addStaticObjectsSource(source: String){ }
fun Style.addStaticObjectsSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addStaticObjectsSource") LogUtils.dTag("MapBoxLayout","addStaticObjectsSource")
addSource{ return geoJsonSource(MainViewModel.STATIC_OBJECTS_SOURCE) {
geoJsonSource(MainViewModel.STATIC_OBJECTS_SOURCE) { data(source)
data(source) }
} }
fillLayer(
MainViewModel.STATIC_OBJECTS_LAYER, fun Style.addStaticObjectsFillLayer():FillLayer{
MainViewModel.STATIC_OBJECTS_SOURCE LogUtils.dTag("MapBoxLayout","addStaticObjectsFillLayer")
){ return fillLayer(
fillColor("#98a0a0") MainViewModel.STATIC_OBJECTS_LAYER,
fillOpacity(0.85) MainViewModel.STATIC_OBJECTS_SOURCE
fillAntialias(false) ){
visibility(Visibility.VISIBLE) fillColor("#98a0a0")
} fillOpacity(0.85)
symbolLayer(MainViewModel.STATIC_OBJECTS_TEXT_LAYER, MainViewModel.STATIC_OBJECTS_SOURCE){ fillAntialias(false)
textColor(Color.BLACK) visibility(Visibility.VISIBLE)
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular")) }
textLineHeight(1.0)
textPadding(1.0) fun Style.addStaticObjectsSymbolLayer():SymbolLayer{
textOffset(listOf(0.5,-0.5)) LogUtils.dTag("MapBoxLayout","addStaticObjectsSymbolLayer")
textRotationAlignment(TextRotationAlignment.MAP) return symbolLayer(MainViewModel.STATIC_OBJECTS_TEXT_LAYER, MainViewModel.STATIC_OBJECTS_SOURCE){
textAnchor(TextAnchor.TOP) textColor(Color.BLACK)
textSize(16.0) textField(get("name"))
textMaxAngle(10.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
visibility(Visibility.VISIBLE) textLineHeight(1.0)
} textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
textAnchor(TextAnchor.TOP)
fun Style.addDiggingWorkAreaSource(source: String){ textSize(16.0)
textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addDiggingWorkAreaSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addDiggingWorkAreaSource") LogUtils.dTag("MapBoxLayout","addDiggingWorkAreaSource")
addSource{ return geoJsonSource(MainViewModel.DIGGING_WORK_AREA_SOURCE) {
geoJsonSource(MainViewModel.DIGGING_WORK_AREA_SOURCE) { data(source)
data(source) }
} }
fillLayer(
MainViewModel.DIGGING_WORK_AREA_LAYER, fun Style.addDiggingWorkAreaFillLayer():FillLayer{
MainViewModel.DIGGING_WORK_AREA_SOURCE LogUtils.dTag("MapBoxLayout","addStaticObjectsFillLayer")
){ return fillLayer(
fillColor("#886e26") MainViewModel.DIGGING_WORK_AREA_LAYER,
fillOpacity(0.85) MainViewModel.DIGGING_WORK_AREA_SOURCE
fillAntialias(false) ){
visibility(Visibility.VISIBLE) fillColor("#886e26")
} fillOpacity(0.85)
symbolLayer(MainViewModel.DIGGING_WORK_AREA_TEXT_LAYER, MainViewModel.DIGGING_WORK_AREA_SOURCE){ fillAntialias(false)
textColor(Color.BLACK) visibility(Visibility.VISIBLE)
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular")) }
textLineHeight(1.0)
textPadding(1.0) fun Style.addDiggingWorkAreaSymbolLayer():SymbolLayer{
textOffset(listOf(0.5,-0.5)) LogUtils.dTag("MapBoxLayout","addDiggingWorkAreaSymbolLayer")
textRotationAlignment(TextRotationAlignment.MAP) return symbolLayer(MainViewModel.DIGGING_WORK_AREA_TEXT_LAYER, MainViewModel.DIGGING_WORK_AREA_SOURCE){
textAnchor(TextAnchor.TOP) textColor(Color.BLACK)
textSize(16.0) textField(get("name"))
textMaxAngle(10.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
visibility(Visibility.VISIBLE) textLineHeight(1.0)
} textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
textAnchor(TextAnchor.TOP)
fun Style.addBarricadeSource(source: String){ textSize(16.0)
textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addBarricadeSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addBarricadeSource") LogUtils.dTag("MapBoxLayout","addBarricadeSource")
addSource{ return geoJsonSource(MainViewModel.BARRICADE_SOURCE) {
geoJsonSource(MainViewModel.BARRICADE_SOURCE) { data(source)
data(source) }
} }
lineLayer(
MainViewModel.BARRICADE_LAYER, fun Style.addBarricadeLineLayer():LineLayer{
MainViewModel.BARRICADE_SOURCE LogUtils.dTag("MapBoxLayout","addLaneLayer")
){ return lineLayer(
lineColor("blue") MainViewModel.BARRICADE_LAYER,
lineWidth(4.0) MainViewModel.BARRICADE_SOURCE
lineJoin(LineJoin.ROUND) ){
lineCap(LineCap.ROUND) lineColor("blue")
visibility(Visibility.VISIBLE) lineWidth(4.0)
} lineJoin(LineJoin.ROUND)
} lineCap(LineCap.ROUND)
} visibility(Visibility.VISIBLE)
}
fun Style.addObstaclesSource(source: String){ }
fun Style.addObstaclesSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addObstaclesSource") LogUtils.dTag("MapBoxLayout","addObstaclesSource")
addSource{ return geoJsonSource(MainViewModel.OBSTACLES_SOURCE) {
geoJsonSource(MainViewModel.OBSTACLES_SOURCE) { url(source)
url(source) }
} }
fillLayer(
MainViewModel.OBSTACLES_LAYER, fun Style.addObstaclesFillLayer():FillLayer{
MainViewModel.OBSTACLES_SOURCE LogUtils.dTag("MapBoxLayout","addObstaclesFillLayer")
){ return fillLayer(
fillColor("#6f9bdd") MainViewModel.OBSTACLES_LAYER,
fillOpacity(0.8) MainViewModel.OBSTACLES_SOURCE
visibility(Visibility.VISIBLE) ){
} fillColor("#6f9bdd")
symbolLayer(MainViewModel.OBSTACLES_TEXT_LAYER, MainViewModel.OBSTACLES_SOURCE){ fillOpacity(0.8)
textColor(Color.BLACK) visibility(Visibility.VISIBLE)
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular")) }
textLineHeight(1.0) fun Style.addObstaclesSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addObstaclesSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.DIGGING_WORK_AREA_TEXT_LAYER, MainViewModel.DIGGING_WORK_AREA_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(16.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxAngle(10.0) textLineHeight(1.0)
visibility(Visibility.VISIBLE) textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
} textAnchor(TextAnchor.TOP)
textSize(16.0)
fun Style.addStationAreaSource(source: String){ textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addStationAreaSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addStationAreaSource") LogUtils.dTag("MapBoxLayout","addStationAreaSource")
addSource{ return geoJsonSource(MainViewModel.STATION_AREA_SOURCE) {
geoJsonSource(MainViewModel.STATION_AREA_SOURCE) { data(source)
data(source) }
} }
fillLayer( fun Style.addStationAreaFillLayer():FillLayer{
MainViewModel.STATION_AREA_LAYER, LogUtils.dTag("MapBoxLayout","addStationAreaFillLayer")
MainViewModel.STATION_AREA_SOURCE return fillLayer(
){ MainViewModel.STATION_AREA_LAYER,
fillColor("lightgreen") MainViewModel.STATION_AREA_SOURCE
fillOpacity(0.8) ){
visibility(Visibility.VISIBLE) fillColor("lightgreen")
} fillOpacity(0.8)
symbolLayer(MainViewModel.STATION_AREA_TEXT_LAYER, MainViewModel.STATION_AREA_SOURCE){ visibility(Visibility.VISIBLE)
textColor(Color.BLACK) }
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textLineHeight(1.0) fun Style.addStationAreaSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addStationAreaSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.STATION_AREA_TEXT_LAYER, MainViewModel.STATION_AREA_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(16.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxWidth(10.0) textLineHeight(1.0)
} textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
textAnchor(TextAnchor.TOP)
fun Style.addLaneNodeSource(source: String){ textSize(16.0)
textMaxWidth(10.0)
}
}
fun Style.addLaneNodeSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addLaneNodeSource") LogUtils.dTag("MapBoxLayout","addLaneNodeSource")
addSource{ return geoJsonSource(MainViewModel.LANE_NODE_SOURCE) {
geoJsonSource(MainViewModel.LANE_NODE_SOURCE) { data(source)
data(source) }
} }
circleLayer(
MainViewModel.LANE_NODE_LAYER, fun Style.addLaneNodeCircleLayer():CircleLayer{
MainViewModel.LANE_NODE_SOURCE LogUtils.dTag("MapBoxLayout","addLaneNodeCircleLayer")
){ return circleLayer(
circleColor("red") MainViewModel.LANE_NODE_LAYER,
circleRadius(6.0) MainViewModel.LANE_NODE_SOURCE
visibility(Visibility.VISIBLE) ){
} circleColor("red")
symbolLayer(MainViewModel.LANE_TEXT_LAYER, MainViewModel.LANE_NODE_SOURCE){ circleRadius(6.0)
textColor(Color.BLACK) visibility(Visibility.VISIBLE)
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular")) }
textLineHeight(1.0)
textPadding(1.0) fun Style.addLaneNodeSymbolLayer():SymbolLayer{
textOffset(listOf(0.5,-0.5)) LogUtils.dTag("MapBoxLayout","addLaneNodeSymbolLayer")
textRotationAlignment(TextRotationAlignment.MAP) return symbolLayer(MainViewModel.STATION_AREA_TEXT_LAYER, MainViewModel.STATION_AREA_SOURCE){
textAnchor(TextAnchor.TOP) textColor(Color.BLACK)
textSize(9.0) textField(get("name"))
textMaxAngle(10.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
visibility(Visibility.VISIBLE) textLineHeight(1.0)
} textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
textAnchor(TextAnchor.TOP)
fun Style.addParkSpotSource(source: String){ textSize(16.0)
textMaxWidth(10.0)
}
}
fun Style.addParkSpotSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addParkSpotSource") LogUtils.dTag("MapBoxLayout","addParkSpotSource")
addSource{ return geoJsonSource(MainViewModel.PARK_SPOT_SOURCE) {
geoJsonSource(MainViewModel.PARK_SPOT_SOURCE) { data(source)
data(source) }
} }
fillLayer( fun Style.addParkSpotFillLayer():FillLayer{
MainViewModel.PARK_SPOT_LAYER, LogUtils.dTag("MapBoxLayout","addParkSpotFillLayer")
MainViewModel.PARK_SPOT_SOURCE return fillLayer(
){ MainViewModel.PARK_SPOT_LAYER,
fillColor(get("#7e8185")) MainViewModel.PARK_SPOT_SOURCE
fillOpacity(0.8) ){
fillAntialias(false) fillColor(get("#7e8185"))
visibility(Visibility.VISIBLE) fillOpacity(0.8)
} fillAntialias(false)
symbolLayer(MainViewModel.PARK_SPOT_TEXT_LAYER, MainViewModel.PARK_SPOT_SOURCE){ visibility(Visibility.VISIBLE)
textColor(Color.BLACK) }
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textLineHeight(1.0) fun Style.addParkSpotSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addParkSpotSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.PARK_SPOT_TEXT_LAYER, MainViewModel.PARK_SPOT_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(9.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxAngle(10.0) textLineHeight(1.0)
visibility(Visibility.VISIBLE) textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
} textAnchor(TextAnchor.TOP)
textSize(9.0)
fun Style.addElectronicFenceSource(source: String){ textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addElectronicFenceSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addElectronicFenceSource") LogUtils.dTag("MapBoxLayout","addElectronicFenceSource")
addSource{ return geoJsonSource(MainViewModel.ELECTRONIC_FENCE_SOURCE) {
geoJsonSource(MainViewModel.ELECTRONIC_FENCE_SOURCE) { data(source)
data(source) }
} }
fillLayer( fun Style.addElectronicFenceFillLayer():FillLayer{
MainViewModel.ELECTRONIC_FENCE_LAYER, LogUtils.dTag("MapBoxLayout","addElectronicFenceFillLayer")
MainViewModel.ELECTRONIC_FENCE_SOURCE return fillLayer(
){ MainViewModel.ELECTRONIC_FENCE_LAYER,
fillColor(get("color")) MainViewModel.ELECTRONIC_FENCE_SOURCE
fillOpacity(0.85) ){
fillAntialias(false) fillColor(get("color"))
visibility(Visibility.VISIBLE) fillOpacity(0.85)
} fillAntialias(false)
symbolLayer(MainViewModel.ELECTRONIC_FENCE_TEXT_LAYER, MainViewModel.ELECTRONIC_FENCE_SOURCE){ visibility(Visibility.VISIBLE)
textColor(Color.BLACK) }
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textLineHeight(1.0) fun Style.addElectronicFenceSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addElectronicFenceSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.ELECTRONIC_FENCE_TEXT_LAYER, MainViewModel.ELECTRONIC_FENCE_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(16.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxAngle(10.0) textLineHeight(1.0)
visibility(Visibility.VISIBLE) textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
} textAnchor(TextAnchor.TOP)
textSize(16.0)
fun Style.addWetAreaSource(source: String){ textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addWetAreaSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addWetAreaSource") LogUtils.dTag("MapBoxLayout","addWetAreaSource")
addSource{ return geoJsonSource(MainViewModel.WET_AREA_SOURCE) {
geoJsonSource(MainViewModel.WET_AREA_SOURCE) { data(source)
data(source) }
} }
fillLayer( fun Style.addWetAreaFillLayer():FillLayer{
MainViewModel.WET_AREA_LAYER, LogUtils.dTag("MapBoxLayout","addWetAreaFillLayer")
MainViewModel.WET_AREA_SOURCE return fillLayer(
){ MainViewModel.WET_AREA_LAYER,
fillColor(get("color")) MainViewModel.WET_AREA_SOURCE
fillOpacity(0.8) ){
fillAntialias(false) fillColor(get("color"))
visibility(Visibility.VISIBLE) fillOpacity(0.8)
} fillAntialias(false)
symbolLayer(MainViewModel.WET_AREA_TEXT_LAYER, MainViewModel.WET_AREA_SOURCE){ visibility(Visibility.VISIBLE)
textColor(Color.BLACK) }
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textLineHeight(1.0) fun Style.addWetAreaSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addWetAreaSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.WET_AREA_TEXT_LAYER, MainViewModel.WET_AREA_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(16.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxAngle(10.0) textLineHeight(1.0)
visibility(Visibility.VISIBLE) textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
} textAnchor(TextAnchor.TOP)
textSize(16.0)
fun Style.addDumpAreaSource(source: String){ textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addDumpAreaSource(source: String):GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addDumpAreaSource") LogUtils.dTag("MapBoxLayout","addDumpAreaSource")
addSource{ return geoJsonSource(MainViewModel.DUMP_AREA_SOURCE) {
geoJsonSource(MainViewModel.DUMP_AREA_SOURCE) { data(source)
data(source) }
} }
fillLayer( fun Style.addDumpAreaFillLayer():FillLayer{
MainViewModel.DUMP_AREA_LAYER, LogUtils.dTag("MapBoxLayout","addDumpAreaFillLayer")
MainViewModel.DUMP_AREA_SOURCE return fillLayer(
){ MainViewModel.DUMP_AREA_LAYER,
fillColor("#886e26") MainViewModel.DUMP_AREA_SOURCE
fillOpacity(0.85) ){
fillAntialias(false) fillColor("#886e26")
visibility(Visibility.VISIBLE) fillOpacity(0.85)
} fillAntialias(false)
symbolLayer(MainViewModel.DUMP_AREA_TEXT_LAYER, MainViewModel.DUMP_AREA_SOURCE){ visibility(Visibility.VISIBLE)
textColor(Color.BLACK) }
textField(get("name")) }
textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textLineHeight(1.0) fun Style.addDumpAreaSymbolLayer():SymbolLayer{
textPadding(1.0) LogUtils.dTag("MapBoxLayout","addDumpAreaSymbolLayer")
textOffset(listOf(0.5,-0.5)) return symbolLayer(MainViewModel.DUMP_AREA_TEXT_LAYER, MainViewModel.DUMP_AREA_SOURCE){
textRotationAlignment(TextRotationAlignment.MAP) textColor(Color.BLACK)
textAnchor(TextAnchor.TOP) textField(get("name"))
textSize(16.0) textFont(listOf("DIN Offc Pro Italic", "Arial Unicode MS Regular"))
textMaxAngle(10.0) textLineHeight(1.0)
visibility(Visibility.VISIBLE) textPadding(1.0)
} textOffset(listOf(0.5,-0.5))
} textRotationAlignment(TextRotationAlignment.MAP)
} textAnchor(TextAnchor.TOP)
textSize(16.0)
fun Style.addTruckPathSource(){ textMaxAngle(10.0)
visibility(Visibility.VISIBLE)
}
}
fun Style.addTruckPathSource():GeoJsonSource{
LogUtils.dTag("MapBoxLayout","addTruckPathSource")
return geoJsonSource("truckPathSource") {
data("{ \"type\": \"FeatureCollection\", \"features\":[]}")
}
}
fun Style.addTruckPathLineLayer():LineLayer{
LogUtils.dTag("MapBoxLayout","addTruckPathSource") LogUtils.dTag("MapBoxLayout","addTruckPathSource")
addSource{ return lineLayer(
geoJsonSource("truckPathSource") { "truckPathLayer",
data("{ \"type\": \"FeatureCollection\", \"features\":[]}") "truckPathSource"
} ){
lineLayer( lineColor("green")
"truckPathLayer", lineWidth(8.0)
"truckPathSource" lineOpacity(0.8)
){ lineJoin(LineJoin.ROUND)
lineColor("green") lineCap(LineCap.ROUND)
lineWidth(8.0) visibility(Visibility.VISIBLE)
lineOpacity(0.8)
lineJoin(LineJoin.ROUND)
lineCap(LineCap.ROUND)
visibility(Visibility.VISIBLE)
}
} }
} }
......
...@@ -26,15 +26,17 @@ ...@@ -26,15 +26,17 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:mapbox_resourcesAccessToken="@string/map_box_public_key" app:mapbox_resourcesAccessToken="@string/map_box_public_key"
app:mapbox_scaleBarBorderWidth="0dp" app:mapbox_scaleBarBorderWidth="0dp"
app:mapbox_scaleBarGravity="bottom|end" app:mapbox_scaleBarHeight="5dp"
app:mapbox_scaleBarHeight="@dimen/dp_6" app:mapbox_scaleBarGravity="bottom|right"
app:mapbox_scaleBarIsMetricUnits="true" app:mapbox_scaleBarIsMetricUnits="true"
app:mapbox_scaleBarMarginBottom="15dp" app:mapbox_scaleBarMarginBottom="38dp"
app:mapbox_scaleBarMarginRight="24dp" app:mapbox_scaleBarMarginRight="0dp"
app:mapbox_scaleBarPrimaryColor="@color/black"
app:mapbox_scaleBarSecondaryColor="@android:color/transparent"
app:mapbox_scaleBarShowTextBorder="false"
app:mapbox_scaleBarTextBarMargin="10dp" app:mapbox_scaleBarTextBarMargin="10dp"
app:mapbox_scaleBarTextBorderWidth="5dp" app:mapbox_scaleBarTextColor="@android:color/black"
app:mapbox_scaleBarTextColor="@color/home_text_color" app:mapbox_scaleBarTextSize="10dp" />
app:mapbox_scaleBarTextSize="@dimen/dp_18" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/sos" android:id="@+id/sos"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment