DrivingRouteManager.kt
3.05 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
96
97
98
99
100
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 RoutePlanManager : SimpleViewManager<RoutePlan>() {
override fun getName(): String {
return "RoutePlan"
}
override fun createViewInstance(reactContext: ThemedReactContext): RoutePlan {
return RoutePlan(reactContext)
}
companion object {
const val searchRoute = 1
}
override fun getCommandsMap(): Map<String, Int> {
return mapOf("searchRoute" to searchRoute)
}
override fun receiveCommand(route: RoutePlan, commandId: Int, args: ReadableArray?) {
when (commandId) {
searchRoute -> route.searchRoute(args)
}
}
@ReactProp(name = "startPoint")
fun setStart(route: RoutePlan, startPoint: ReadableMap) {
route.setStartPoint(startPoint.toLatLonPoint())
}
@ReactProp(name = "endPoint")
fun setEnd(route: RoutePlan, endPoint: ReadableMap) {
route.setEndPoint(endPoint.toLatLonPoint())
}
@ReactProp(name = "routeType")
fun setMapType(route: RoutePlan, routeType: Int = 0) {
route.setRouteType(routeType + 1)
}
@ReactProp(name = "width")
fun setWidth(route: RoutePlan, width: Float) {
route.setRouteWidth(width.toPx().toFloat())
}
@ReactProp(name = "lineColor", customType = "Color")
fun setColor(route: RoutePlan, lineColor: Int) {
route.setRoadColor(lineColor)
}
@ReactProp(name = "throughPointVisible")
fun setThroughPointVisible(route: RoutePlan, throughPointVisible: Boolean) {
route.setThroughPointMarkerVisible(throughPointVisible)
}
@ReactProp(name = "colorFulLine")
fun setColorFulLine(route: RoutePlan, colorFulLine: Boolean) {
route.setIsColorfulline(colorFulLine)
}
@ReactProp(name = "throughPointList")
fun setThroughPointList(route: RoutePlan, position: ReadableArray) {
route.setThroughPointList(position.toLatLngList())
}
@ReactProp(name = "driveIcon")
fun setDriveIcon(route: RoutePlan, driveIcon: ReadableMap?) {
driveIcon?.let { route.setDriveBit(it) }
}
@ReactProp(name = "startIcon")
fun setStartIcon(route: RoutePlan, startIcon: ReadableMap?) {
startIcon?.let { route.setStartBit(it) }
}
@ReactProp(name = "endIcon")
fun setEndIcon(route: RoutePlan, endIcon: ReadableMap?) {
endIcon?.let { route.setEndBit(it) }
}
@ReactProp(name = "throughPointIcon")
fun setThroughPointIcon(route: RoutePlan, throughPoint: ReadableMap?) {
throughPoint?.let { route.setThroughBit(it) }
}
@ReactProp(name = "roadLine")
fun setRoadLine(route: RoutePlan, roadLine: ReadableMap?) {
roadLine?.let { route.setRoadLine(it) }
}
}