Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HTAnticollision
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马乐
HTAnticollision
Commits
baa0be8d
Commit
baa0be8d
authored
May 24, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加地图annotation
parent
caa4d969
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
256 additions
and
191 deletions
+256
-191
SplashActivity.kt
...src/main/java/com/waytous/anticollision/SplashActivity.kt
+11
-0
BaseFragment.kt
...rc/main/java/com/waytous/anticollision/ui/BaseFragment.kt
+68
-65
HomeFragment.kt
...in/java/com/waytous/anticollision/ui/home/HomeFragment.kt
+32
-40
Extensions.kt
...c/main/java/com/waytous/anticollision/utils/Extensions.kt
+136
-79
layout_map_box.xml
app/src/main/res/layout/layout_map_box.xml
+9
-7
No files found.
app/src/main/java/com/waytous/anticollision/SplashActivity.kt
View file @
baa0be8d
...
@@ -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
app/src/main/java/com/waytous/anticollision/ui/BaseFragment.kt
View file @
baa0be8d
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
>){
others
.
forEach
{
vehicle
->
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
val
pointAnnotationOptions
:
PointAnnotationOptions
=
PointAnnotationOptions
()
.
withPoint
(
otherAnnotation
.
point
)
.
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
app/src/main/java/com/waytous/anticollision/ui/home/HomeFragment.kt
View file @
baa0be8d
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}"
)
...
...
app/src/main/java/com/waytous/anticollision/utils/Extensions.kt
View file @
baa0be8d
...
@@ -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,13 +90,16 @@ fun Context.getBitmapFromVectorDrawable(drawableId:Int,scale:Int = 2): Bitmap? {
...
@@ -85,13 +90,16 @@ 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
(
}
fun
Style
.
addRunnableAreaLayer
():
FillLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addRunnableAreaLayer"
)
return
fillLayer
(
MainViewModel
.
RUNNABLE_AREA_LAYER
,
MainViewModel
.
RUNNABLE_AREA_LAYER
,
MainViewModel
.
RUNNABLE_AREA_SOURCE
MainViewModel
.
RUNNABLE_AREA_SOURCE
){
){
...
@@ -100,16 +108,18 @@ fun Style.addRunnableAreaSource(source: String){
...
@@ -100,16 +108,18 @@ fun Style.addRunnableAreaSource(source: String){
fillOutlineColor
(
"#FFFF00"
)
fillOutlineColor
(
"#FFFF00"
)
visibility
(
Visibility
.
VISIBLE
)
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
(
}
fun
Style
.
addLaneLayer
():
LineLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneLayer"
)
return
lineLayer
(
MainViewModel
.
LANE_LAYER
,
MainViewModel
.
LANE_LAYER
,
MainViewModel
.
LANE_SOURCE
MainViewModel
.
LANE_SOURCE
){
){
...
@@ -119,16 +129,18 @@ fun Style.addLaneSource(source: String){
...
@@ -119,16 +129,18 @@ fun Style.addLaneSource(source: String){
lineCap
(
LineCap
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
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
(
}
fun
Style
.
addStaticObjectsFillLayer
():
FillLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStaticObjectsFillLayer"
)
return
fillLayer
(
MainViewModel
.
STATIC_OBJECTS_LAYER
,
MainViewModel
.
STATIC_OBJECTS_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
){
...
@@ -137,7 +149,11 @@ fun Style.addStaticObjectsSource(source: String){
...
@@ -137,7 +149,11 @@ fun Style.addStaticObjectsSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
STATIC_OBJECTS_TEXT_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
}
fun
Style
.
addStaticObjectsSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStaticObjectsSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
STATIC_OBJECTS_TEXT_LAYER
,
MainViewModel
.
STATIC_OBJECTS_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -150,16 +166,18 @@ fun Style.addStaticObjectsSource(source: String){
...
@@ -150,16 +166,18 @@ fun Style.addStaticObjectsSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addDiggingWorkAreaSource
(
source
:
String
){
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
(
}
fun
Style
.
addDiggingWorkAreaFillLayer
():
FillLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStaticObjectsFillLayer"
)
return
fillLayer
(
MainViewModel
.
DIGGING_WORK_AREA_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
){
...
@@ -168,7 +186,11 @@ fun Style.addDiggingWorkAreaSource(source: String){
...
@@ -168,7 +186,11 @@ fun Style.addDiggingWorkAreaSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
DIGGING_WORK_AREA_TEXT_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
}
fun
Style
.
addDiggingWorkAreaSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addDiggingWorkAreaSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
DIGGING_WORK_AREA_TEXT_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -181,16 +203,18 @@ fun Style.addDiggingWorkAreaSource(source: String){
...
@@ -181,16 +203,18 @@ fun Style.addDiggingWorkAreaSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addBarricadeSource
(
source
:
String
){
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
(
}
fun
Style
.
addBarricadeLineLayer
():
LineLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneLayer"
)
return
lineLayer
(
MainViewModel
.
BARRICADE_LAYER
,
MainViewModel
.
BARRICADE_LAYER
,
MainViewModel
.
BARRICADE_SOURCE
MainViewModel
.
BARRICADE_SOURCE
){
){
...
@@ -200,16 +224,18 @@ fun Style.addBarricadeSource(source: String){
...
@@ -200,16 +224,18 @@ fun Style.addBarricadeSource(source: String){
lineCap
(
LineCap
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
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
(
}
fun
Style
.
addObstaclesFillLayer
():
FillLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addObstaclesFillLayer"
)
return
fillLayer
(
MainViewModel
.
OBSTACLES_LAYER
,
MainViewModel
.
OBSTACLES_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
MainViewModel
.
OBSTACLES_SOURCE
){
){
...
@@ -217,7 +243,10 @@ fun Style.addObstaclesSource(source: String){
...
@@ -217,7 +243,10 @@ fun Style.addObstaclesSource(source: String){
fillOpacity
(
0.8
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
OBSTACLES_TEXT_LAYER
,
MainViewModel
.
OBSTACLES_SOURCE
){
}
fun
Style
.
addObstaclesSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addObstaclesSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
DIGGING_WORK_AREA_TEXT_LAYER
,
MainViewModel
.
DIGGING_WORK_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -230,16 +259,16 @@ fun Style.addObstaclesSource(source: String){
...
@@ -230,16 +259,16 @@ fun Style.addObstaclesSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addStationAreaSource
(
source
:
String
):
GeoJsonSource
{
fun
Style
.
addStationAreaSource
(
source
:
String
){
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
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStationAreaFillLayer"
)
return
fillLayer
(
MainViewModel
.
STATION_AREA_LAYER
,
MainViewModel
.
STATION_AREA_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
MainViewModel
.
STATION_AREA_SOURCE
){
){
...
@@ -247,7 +276,11 @@ fun Style.addStationAreaSource(source: String){
...
@@ -247,7 +276,11 @@ fun Style.addStationAreaSource(source: String){
fillOpacity
(
0.8
)
fillOpacity
(
0.8
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
STATION_AREA_TEXT_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
}
fun
Style
.
addStationAreaSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addStationAreaSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
STATION_AREA_TEXT_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -259,16 +292,18 @@ fun Style.addStationAreaSource(source: String){
...
@@ -259,16 +292,18 @@ fun Style.addStationAreaSource(source: String){
textSize
(
16.0
)
textSize
(
16.0
)
textMaxWidth
(
10.0
)
textMaxWidth
(
10.0
)
}
}
}
}
}
fun
Style
.
addLaneNodeSource
(
source
:
String
){
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
(
}
fun
Style
.
addLaneNodeCircleLayer
():
CircleLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneNodeCircleLayer"
)
return
circleLayer
(
MainViewModel
.
LANE_NODE_LAYER
,
MainViewModel
.
LANE_NODE_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
MainViewModel
.
LANE_NODE_SOURCE
){
){
...
@@ -276,7 +311,11 @@ fun Style.addLaneNodeSource(source: String){
...
@@ -276,7 +311,11 @@ fun Style.addLaneNodeSource(source: String){
circleRadius
(
6.0
)
circleRadius
(
6.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
LANE_TEXT_LAYER
,
MainViewModel
.
LANE_NODE_SOURCE
){
}
fun
Style
.
addLaneNodeSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addLaneNodeSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
STATION_AREA_TEXT_LAYER
,
MainViewModel
.
STATION_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -285,20 +324,19 @@ fun Style.addLaneNodeSource(source: String){
...
@@ -285,20 +324,19 @@ fun Style.addLaneNodeSource(source: String){
textOffset
(
listOf
(
0.5
,-
0.5
))
textOffset
(
listOf
(
0.5
,-
0.5
))
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textRotationAlignment
(
TextRotationAlignment
.
MAP
)
textAnchor
(
TextAnchor
.
TOP
)
textAnchor
(
TextAnchor
.
TOP
)
textSize
(
9.0
)
textSize
(
16.0
)
textMaxAngle
(
10.0
)
textMaxWidth
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addParkSpotSource
(
source
:
String
):
GeoJsonSource
{
fun
Style
.
addParkSpotSource
(
source
:
String
){
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
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addParkSpotFillLayer"
)
return
fillLayer
(
MainViewModel
.
PARK_SPOT_LAYER
,
MainViewModel
.
PARK_SPOT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
MainViewModel
.
PARK_SPOT_SOURCE
){
){
...
@@ -307,7 +345,11 @@ fun Style.addParkSpotSource(source: String){
...
@@ -307,7 +345,11 @@ fun Style.addParkSpotSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
PARK_SPOT_TEXT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
}
fun
Style
.
addParkSpotSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addParkSpotSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
PARK_SPOT_TEXT_LAYER
,
MainViewModel
.
PARK_SPOT_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -320,16 +362,17 @@ fun Style.addParkSpotSource(source: String){
...
@@ -320,16 +362,17 @@ fun Style.addParkSpotSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addElectronicFenceSource
(
source
:
String
){
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
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addElectronicFenceFillLayer"
)
return
fillLayer
(
MainViewModel
.
ELECTRONIC_FENCE_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
){
...
@@ -338,7 +381,11 @@ fun Style.addElectronicFenceSource(source: String){
...
@@ -338,7 +381,11 @@ fun Style.addElectronicFenceSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
ELECTRONIC_FENCE_TEXT_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
}
fun
Style
.
addElectronicFenceSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addElectronicFenceSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
ELECTRONIC_FENCE_TEXT_LAYER
,
MainViewModel
.
ELECTRONIC_FENCE_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -351,16 +398,17 @@ fun Style.addElectronicFenceSource(source: String){
...
@@ -351,16 +398,17 @@ fun Style.addElectronicFenceSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addWetAreaSource
(
source
:
String
){
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
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addWetAreaFillLayer"
)
return
fillLayer
(
MainViewModel
.
WET_AREA_LAYER
,
MainViewModel
.
WET_AREA_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
MainViewModel
.
WET_AREA_SOURCE
){
){
...
@@ -369,7 +417,11 @@ fun Style.addWetAreaSource(source: String){
...
@@ -369,7 +417,11 @@ fun Style.addWetAreaSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
WET_AREA_TEXT_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
}
fun
Style
.
addWetAreaSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addWetAreaSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
WET_AREA_TEXT_LAYER
,
MainViewModel
.
WET_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -382,16 +434,17 @@ fun Style.addWetAreaSource(source: String){
...
@@ -382,16 +434,17 @@ fun Style.addWetAreaSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addDumpAreaSource
(
source
:
String
){
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
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addDumpAreaFillLayer"
)
return
fillLayer
(
MainViewModel
.
DUMP_AREA_LAYER
,
MainViewModel
.
DUMP_AREA_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
MainViewModel
.
DUMP_AREA_SOURCE
){
){
...
@@ -400,7 +453,11 @@ fun Style.addDumpAreaSource(source: String){
...
@@ -400,7 +453,11 @@ fun Style.addDumpAreaSource(source: String){
fillAntialias
(
false
)
fillAntialias
(
false
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
symbolLayer
(
MainViewModel
.
DUMP_AREA_TEXT_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
}
fun
Style
.
addDumpAreaSymbolLayer
():
SymbolLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addDumpAreaSymbolLayer"
)
return
symbolLayer
(
MainViewModel
.
DUMP_AREA_TEXT_LAYER
,
MainViewModel
.
DUMP_AREA_SOURCE
){
textColor
(
Color
.
BLACK
)
textColor
(
Color
.
BLACK
)
textField
(
get
(
"name"
))
textField
(
get
(
"name"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
textFont
(
listOf
(
"DIN Offc Pro Italic"
,
"Arial Unicode MS Regular"
))
...
@@ -413,16 +470,17 @@ fun Style.addDumpAreaSource(source: String){
...
@@ -413,16 +470,17 @@ fun Style.addDumpAreaSource(source: String){
textMaxAngle
(
10.0
)
textMaxAngle
(
10.0
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
Style
.
addTruckPathSource
(){
fun
Style
.
addTruckPathSource
()
:
GeoJsonSource
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addTruckPathSource"
)
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addTruckPathSource"
)
addSource
{
return
geoJsonSource
(
"truckPathSource"
)
{
geoJsonSource
(
"truckPathSource"
)
{
data
(
"{ \"type\": \"FeatureCollection\", \"features\":[]}"
)
data
(
"{ \"type\": \"FeatureCollection\", \"features\":[]}"
)
}
}
lineLayer
(
}
fun
Style
.
addTruckPathLineLayer
():
LineLayer
{
LogUtils
.
dTag
(
"MapBoxLayout"
,
"addTruckPathSource"
)
return
lineLayer
(
"truckPathLayer"
,
"truckPathLayer"
,
"truckPathSource"
"truckPathSource"
){
){
...
@@ -433,7 +491,6 @@ fun Style.addTruckPathSource(){
...
@@ -433,7 +491,6 @@ fun Style.addTruckPathSource(){
lineCap
(
LineCap
.
ROUND
)
lineCap
(
LineCap
.
ROUND
)
visibility
(
Visibility
.
VISIBLE
)
visibility
(
Visibility
.
VISIBLE
)
}
}
}
}
}
fun
AppCompatActivity
.
checkSelfPermissionCompat
(
permission
:
String
)
=
fun
AppCompatActivity
.
checkSelfPermissionCompat
(
permission
:
String
)
=
...
...
app/src/main/res/layout/layout_map_box.xml
View file @
baa0be8d
...
@@ -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_scaleBar
Gravity=
"bottom|end
"
app:mapbox_scaleBar
Height=
"5dp
"
app:mapbox_scaleBar
Height=
"@dimen/dp_6
"
app:mapbox_scaleBar
Gravity=
"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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment