DrivingRouteManager.kt
2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package cn.feewee.amap3d.map_view.route
import cn.feewee.amap3d.toLatLngList
import cn.feewee.amap3d.toLatLonPoint
import cn.feewee.amap3d.toPx
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.annotations.ReactProp
@Suppress("unused")
class DrivingRouteManager : SimpleViewManager<DrivingRoute>() {
override fun getName(): String {
return "DrivingRoute"
}
override fun createViewInstance(reactContext: ThemedReactContext): DrivingRoute {
return DrivingRoute(reactContext)
}
companion object {
const val searchRoute = 1
}
override fun getCommandsMap(): Map<String, Int> {
return mapOf("searchRoute" to searchRoute)
}
override fun receiveCommand(route: DrivingRoute, commandId: Int, args: ReadableArray?) {
when (commandId) {
searchRoute -> route.searchRoute(args)
}
}
@ReactProp(name = "startPoint")
fun setStart(route: DrivingRoute, startPoint: ReadableMap) {
route.setStartPoint(startPoint.toLatLonPoint())
}
@ReactProp(name = "endPoint")
fun setEnd(route: DrivingRoute, endPoint: ReadableMap) {
route.setEndPoint(endPoint.toLatLonPoint())
}
@ReactProp(name = "width")
fun setWidth(route: DrivingRoute, width: Float) {
route.setRouteWidth(width.toPx().toFloat())
}
@ReactProp(name = "lineColor", customType = "Color")
fun setColor(route: DrivingRoute, lineColor: Int) {
route.setRoadColor(lineColor)
}
@ReactProp(name = "throughPointVisible")
fun setThroughPointVisible(route: DrivingRoute, throughPointVisible: Boolean) {
route.setThroughPointMarkerVisible(throughPointVisible)
}
@ReactProp(name = "colorFulLine")
fun setColorFulLine(route: DrivingRoute, colorFulLine: Boolean) {
route.setIsColorfulline(colorFulLine)
}
@ReactProp(name = "throughPointList")
fun setThroughPointList(route: DrivingRoute, position: ReadableArray) {
route.setThroughPointList(position.toLatLngList())
}
@ReactProp(name = "driveIcon")
fun setDriveIcon(route: DrivingRoute, driveIcon: ReadableMap?) {
driveIcon?.let { route.setDriveBit(it) }
}
@ReactProp(name = "startIcon")
fun setStartIcon(route: DrivingRoute, startIcon: ReadableMap?) {
startIcon?.let { route.setStartBit(it) }
}
@ReactProp(name = "endIcon")
fun setEndIcon(route: DrivingRoute, endIcon: ReadableMap?) {
endIcon?.let { route.setEndBit(it) }
}
@ReactProp(name = "throughPointIcon")
fun setThroughPointIcon(route: DrivingRoute, throughPoint: ReadableMap?) {
throughPoint?.let { route.setThroughBit(it) }
}
@ReactProp(name = "roadLine")
fun setRoadLine(route: DrivingRoute, roadLine: ReadableMap?) {
roadLine?.let { route.setRoadLine(it) }
}
}