Commit baa0be8d authored by 马乐's avatar 马乐

1.增加地图annotation

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