@evnydd0sf/react-native-amap3d-fix 3.2.4-fix.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android/build.gradle +34 -0
- package/lib/android/src/main/AndroidManifest.xml +10 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/AMap3DPackage.kt +28 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/Utils.kt +114 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Circle.kt +65 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/CircleManager.kt +49 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/HeatMap.kt +32 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/HeatMapManager.kt +33 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MapView.kt +174 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MapViewManager.kt +153 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Marker.kt +102 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MarkerManager.kt +78 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MultiPoint.kt +53 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/MultiPointManager.kt +33 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Overlay.kt +8 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Polygon.kt +58 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/PolygonManager.kt +44 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/Polyline.kt +69 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/map_view/PolylineManager.kt +64 -0
- package/lib/android/src/main/java/qiuxiang/amap3d/modules/SdkModule.kt +31 -0
- package/lib/ios/.swiftformat +2 -0
- package/lib/ios/Bridging-Header.h +4 -0
- package/lib/ios/MapView/CircleManager.m +11 -0
- package/lib/ios/MapView/CircleManager.swift +30 -0
- package/lib/ios/MapView/HeatMapManager.m +9 -0
- package/lib/ios/MapView/HeatMapManager.swift +29 -0
- package/lib/ios/MapView/MapViewManager.m +35 -0
- package/lib/ios/MapView/MapViewManager.swift +159 -0
- package/lib/ios/MapView/MarkerManager.m +18 -0
- package/lib/ios/MapView/MarkerManager.swift +100 -0
- package/lib/ios/MapView/MultiPointManager.m +9 -0
- package/lib/ios/MapView/MultiPointManager.swift +47 -0
- package/lib/ios/MapView/Overlay.swift +4 -0
- package/lib/ios/MapView/PolygonManager.m +10 -0
- package/lib/ios/MapView/PolygonManager.swift +30 -0
- package/lib/ios/MapView/PolylineManager.m +12 -0
- package/lib/ios/MapView/PolylineManager.swift +41 -0
- package/lib/ios/Modules/SdkModule.m +8 -0
- package/lib/ios/Modules/SdkModule.swift +16 -0
- package/lib/ios/Utils.swift +104 -0
- package/lib/ios/react-native-amap3d.podspec +20 -0
- package/lib/src/circle.tsx +36 -0
- package/lib/src/cluster/cluster-view.tsx +47 -0
- package/lib/src/cluster/index.tsx +159 -0
- package/lib/src/component.ts +31 -0
- package/lib/src/heat-map.tsx +21 -0
- package/lib/src/index.ts +11 -0
- package/lib/src/map-view.tsx +230 -0
- package/lib/src/marker.tsx +128 -0
- package/lib/src/multi-point.tsx +28 -0
- package/lib/src/polygon.tsx +31 -0
- package/lib/src/polyline.tsx +65 -0
- package/lib/src/sdk.ts +11 -0
- package/lib/src/types.ts +137 -0
- package/license +21 -0
- package/package.json +56 -0
- package/react-native-amap3d.podspec +20 -0
- package/react-native.config.js +20 -0
- package/readme.md +186 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import android.content.Context
|
4
|
+
import android.graphics.Bitmap
|
5
|
+
import android.graphics.Canvas
|
6
|
+
import android.os.Handler
|
7
|
+
import android.os.Looper
|
8
|
+
import android.view.View
|
9
|
+
import com.amap.api.maps.AMap
|
10
|
+
import com.amap.api.maps.model.*
|
11
|
+
import com.amap.api.maps.model.Marker
|
12
|
+
import com.facebook.react.bridge.ReadableMap
|
13
|
+
import com.facebook.react.views.view.ReactViewGroup
|
14
|
+
import qiuxiang.amap3d.fetchImage
|
15
|
+
|
16
|
+
class Marker(context: Context) : ReactViewGroup(context), Overlay {
|
17
|
+
private var view: View? = null
|
18
|
+
private var icon: BitmapDescriptor? = null
|
19
|
+
private var anchorX: Float = 0.5f
|
20
|
+
private var anchorY: Float = 1f
|
21
|
+
var marker: Marker? = null
|
22
|
+
|
23
|
+
var position: LatLng? = null
|
24
|
+
set(value) {
|
25
|
+
field = value
|
26
|
+
marker?.position = value
|
27
|
+
}
|
28
|
+
|
29
|
+
var zIndex: Float = 0.0f
|
30
|
+
set(value) {
|
31
|
+
field = value
|
32
|
+
marker?.zIndex = value
|
33
|
+
}
|
34
|
+
|
35
|
+
var flat: Boolean = false
|
36
|
+
set(value) {
|
37
|
+
field = value
|
38
|
+
marker?.isFlat = value
|
39
|
+
}
|
40
|
+
|
41
|
+
var opacity: Float = 1f
|
42
|
+
set(value) {
|
43
|
+
field = value
|
44
|
+
marker?.alpha = value
|
45
|
+
}
|
46
|
+
|
47
|
+
var draggable: Boolean = false
|
48
|
+
set(value) {
|
49
|
+
field = value
|
50
|
+
marker?.isDraggable = value
|
51
|
+
}
|
52
|
+
|
53
|
+
fun updateIcon() {
|
54
|
+
view?.let {
|
55
|
+
if (it.width != 0 && it.height != 0) {
|
56
|
+
val bitmap = Bitmap.createBitmap(it.width, it.height, Bitmap.Config.ARGB_8888)
|
57
|
+
it.draw(Canvas(bitmap))
|
58
|
+
icon = BitmapDescriptorFactory.fromBitmap(bitmap)
|
59
|
+
marker?.setIcon(icon)
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
fun setAnchor(x: Double, y: Double) {
|
65
|
+
anchorX = x.toFloat()
|
66
|
+
anchorY = y.toFloat()
|
67
|
+
marker?.setAnchor(anchorX, anchorY)
|
68
|
+
}
|
69
|
+
|
70
|
+
override fun addView(child: View, index: Int) {
|
71
|
+
super.addView(child, index)
|
72
|
+
view = child
|
73
|
+
view?.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> updateIcon() }
|
74
|
+
}
|
75
|
+
|
76
|
+
fun setIcon(source: ReadableMap) {
|
77
|
+
fetchImage(source) {
|
78
|
+
icon = it
|
79
|
+
Handler(Looper.getMainLooper()).post {
|
80
|
+
marker?.setIcon(it)
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
override fun add(map: AMap) {
|
86
|
+
marker = map.addMarker(
|
87
|
+
MarkerOptions()
|
88
|
+
.setFlat(flat)
|
89
|
+
.icon(icon)
|
90
|
+
.alpha(opacity)
|
91
|
+
.draggable(draggable)
|
92
|
+
.position(position)
|
93
|
+
.anchor(anchorX, anchorY)
|
94
|
+
.zIndex(zIndex)
|
95
|
+
.infoWindowEnable(false)
|
96
|
+
)
|
97
|
+
}
|
98
|
+
|
99
|
+
override fun remove() {
|
100
|
+
marker?.destroy()
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import android.view.View
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
7
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
9
|
+
import qiuxiang.amap3d.getEventTypeConstants
|
10
|
+
import qiuxiang.amap3d.toLatLng
|
11
|
+
|
12
|
+
@Suppress("unused")
|
13
|
+
internal class MarkerManager : ViewGroupManager<Marker>() {
|
14
|
+
override fun getName(): String {
|
15
|
+
return "AMapMarker"
|
16
|
+
}
|
17
|
+
|
18
|
+
override fun createViewInstance(reactContext: ThemedReactContext): Marker {
|
19
|
+
return Marker(reactContext)
|
20
|
+
}
|
21
|
+
|
22
|
+
override fun addView(marker: Marker, view: View, index: Int) {
|
23
|
+
super.addView(marker, view, index)
|
24
|
+
}
|
25
|
+
|
26
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
27
|
+
return getEventTypeConstants("onPress", "onDrag", "onDragStart", "onDragEnd")
|
28
|
+
}
|
29
|
+
|
30
|
+
companion object {
|
31
|
+
const val update = 1
|
32
|
+
}
|
33
|
+
|
34
|
+
override fun getCommandsMap(): Map<String, Int> {
|
35
|
+
return mapOf("update" to update)
|
36
|
+
}
|
37
|
+
|
38
|
+
override fun receiveCommand(marker: Marker, commandId: Int, args: ReadableArray?) {
|
39
|
+
when (commandId) {
|
40
|
+
update -> marker.updateIcon()
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
@ReactProp(name = "latLng")
|
45
|
+
fun setLatLng(view: Marker, position: ReadableMap) {
|
46
|
+
view.position = position.toLatLng()
|
47
|
+
}
|
48
|
+
|
49
|
+
@ReactProp(name = "flat")
|
50
|
+
fun setFlat(marker: Marker, flat: Boolean) {
|
51
|
+
marker.flat = flat
|
52
|
+
}
|
53
|
+
|
54
|
+
@ReactProp(name = "opacity")
|
55
|
+
override fun setOpacity(marker: Marker, opacity: Float) {
|
56
|
+
marker.opacity = opacity
|
57
|
+
}
|
58
|
+
|
59
|
+
@ReactProp(name = "draggable")
|
60
|
+
fun setDraggable(marker: Marker, draggable: Boolean) {
|
61
|
+
marker.draggable = draggable
|
62
|
+
}
|
63
|
+
|
64
|
+
@ReactProp(name = "zIndex")
|
65
|
+
fun setIndex(marker: Marker, zIndex: Float) {
|
66
|
+
marker.zIndex = zIndex
|
67
|
+
}
|
68
|
+
|
69
|
+
@ReactProp(name = "anchor")
|
70
|
+
fun setAnchor(view: Marker, anchor: ReadableMap) {
|
71
|
+
view.setAnchor(anchor.getDouble("x"), anchor.getDouble("y"))
|
72
|
+
}
|
73
|
+
|
74
|
+
@ReactProp(name = "icon")
|
75
|
+
fun setIcon(view: Marker, icon: ReadableMap?) {
|
76
|
+
icon?.let { view.setIcon(it) }
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import android.content.Context
|
4
|
+
import com.amap.api.maps.AMap
|
5
|
+
import com.amap.api.maps.model.BitmapDescriptor
|
6
|
+
import com.amap.api.maps.model.MultiPointItem
|
7
|
+
import com.amap.api.maps.model.MultiPointOverlay
|
8
|
+
import com.amap.api.maps.model.MultiPointOverlayOptions
|
9
|
+
import com.facebook.react.bridge.ReadableArray
|
10
|
+
import com.facebook.react.bridge.ReadableMap
|
11
|
+
import com.facebook.react.views.view.ReactViewGroup
|
12
|
+
import qiuxiang.amap3d.fetchImage
|
13
|
+
import qiuxiang.amap3d.toLatLng
|
14
|
+
|
15
|
+
class MultiPoint(context: Context) : ReactViewGroup(context), Overlay {
|
16
|
+
private lateinit var map: AMap
|
17
|
+
private var overlay: MultiPointOverlay? = null
|
18
|
+
private var items: List<MultiPointItem> = emptyList()
|
19
|
+
private var icon: BitmapDescriptor? = null
|
20
|
+
|
21
|
+
override fun add(map: AMap) {
|
22
|
+
this.map = map
|
23
|
+
addToMap()
|
24
|
+
}
|
25
|
+
|
26
|
+
override fun remove() {
|
27
|
+
overlay?.destroy()
|
28
|
+
}
|
29
|
+
|
30
|
+
private fun addToMap() {
|
31
|
+
if (overlay != null) return
|
32
|
+
if (icon != null) {
|
33
|
+
overlay = map.addMultiPointOverlay(MultiPointOverlayOptions().icon(icon))
|
34
|
+
overlay?.items = items
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
fun setItems(points: ReadableArray) {
|
39
|
+
items = (0 until points.size())
|
40
|
+
.map { item ->
|
41
|
+
// 兼容 0.63
|
42
|
+
MultiPointItem(points.getMap(item)!!.toLatLng()).apply { customerId = "${id}_$item" }
|
43
|
+
}
|
44
|
+
overlay?.items = items
|
45
|
+
}
|
46
|
+
|
47
|
+
fun setIcon(source: ReadableMap) {
|
48
|
+
fetchImage(source) {
|
49
|
+
icon = it
|
50
|
+
addToMap()
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
5
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
6
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
7
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
8
|
+
import qiuxiang.amap3d.getEventTypeConstants
|
9
|
+
|
10
|
+
@Suppress("unused")
|
11
|
+
internal class MultiPointManager : SimpleViewManager<MultiPoint>() {
|
12
|
+
override fun getName(): String {
|
13
|
+
return "AMapMultiPoint"
|
14
|
+
}
|
15
|
+
|
16
|
+
override fun createViewInstance(reactContext: ThemedReactContext): MultiPoint {
|
17
|
+
return MultiPoint(reactContext)
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
21
|
+
return getEventTypeConstants("onPress")
|
22
|
+
}
|
23
|
+
|
24
|
+
@ReactProp(name = "items")
|
25
|
+
fun setPoints(multiPoint: MultiPoint, items: ReadableArray) {
|
26
|
+
multiPoint.setItems(items)
|
27
|
+
}
|
28
|
+
|
29
|
+
@ReactProp(name = "icon")
|
30
|
+
fun setIcon(multiPoint: MultiPoint, icon: ReadableMap?) {
|
31
|
+
icon?.let { multiPoint.setIcon(it) }
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import android.content.Context
|
4
|
+
import android.graphics.Color
|
5
|
+
import com.amap.api.maps.AMap
|
6
|
+
import com.amap.api.maps.model.LatLng
|
7
|
+
import com.amap.api.maps.model.Polygon
|
8
|
+
import com.amap.api.maps.model.PolygonOptions
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
10
|
+
|
11
|
+
class Polygon(context: Context) : ReactViewGroup(context), Overlay {
|
12
|
+
private var polygon: Polygon? = null
|
13
|
+
|
14
|
+
var points: List<LatLng> = emptyList()
|
15
|
+
set(value) {
|
16
|
+
field = value
|
17
|
+
polygon?.points = value
|
18
|
+
}
|
19
|
+
|
20
|
+
var strokeWidth: Float = 1f
|
21
|
+
set(value) {
|
22
|
+
field = value
|
23
|
+
polygon?.strokeWidth = value
|
24
|
+
}
|
25
|
+
|
26
|
+
var strokeColor: Int = Color.BLACK
|
27
|
+
set(value) {
|
28
|
+
field = value
|
29
|
+
polygon?.strokeColor = value
|
30
|
+
}
|
31
|
+
|
32
|
+
var fillColor: Int = Color.BLACK
|
33
|
+
set(value) {
|
34
|
+
field = value
|
35
|
+
polygon?.fillColor = value
|
36
|
+
}
|
37
|
+
|
38
|
+
var zIndex: Float = 0f
|
39
|
+
set(value) {
|
40
|
+
field = value
|
41
|
+
polygon?.zIndex = value
|
42
|
+
}
|
43
|
+
|
44
|
+
override fun add(map: AMap) {
|
45
|
+
polygon = map.addPolygon(
|
46
|
+
PolygonOptions()
|
47
|
+
.addAll(points)
|
48
|
+
.strokeColor(strokeColor)
|
49
|
+
.strokeWidth(strokeWidth)
|
50
|
+
.fillColor(fillColor)
|
51
|
+
.zIndex(zIndex)
|
52
|
+
)
|
53
|
+
}
|
54
|
+
|
55
|
+
override fun remove() {
|
56
|
+
polygon?.remove()
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
7
|
+
import qiuxiang.amap3d.toLatLngList
|
8
|
+
import qiuxiang.amap3d.toPx
|
9
|
+
|
10
|
+
@Suppress("unused")
|
11
|
+
internal class PolygonManager : SimpleViewManager<Polygon>() {
|
12
|
+
override fun getName(): String {
|
13
|
+
return "AMapPolygon"
|
14
|
+
}
|
15
|
+
|
16
|
+
override fun createViewInstance(reactContext: ThemedReactContext): Polygon {
|
17
|
+
return Polygon(reactContext)
|
18
|
+
}
|
19
|
+
|
20
|
+
@ReactProp(name = "points")
|
21
|
+
fun setPoints(polygon: Polygon, points: ReadableArray) {
|
22
|
+
polygon.points = points.toLatLngList()
|
23
|
+
}
|
24
|
+
|
25
|
+
@ReactProp(name = "fillColor", customType = "Color")
|
26
|
+
fun setFillColor(polygon: Polygon, fillColor: Int) {
|
27
|
+
polygon.fillColor = fillColor
|
28
|
+
}
|
29
|
+
|
30
|
+
@ReactProp(name = "strokeColor", customType = "Color")
|
31
|
+
fun setStrokeColor(polygon: Polygon, strokeColor: Int) {
|
32
|
+
polygon.strokeColor = strokeColor
|
33
|
+
}
|
34
|
+
|
35
|
+
@ReactProp(name = "strokeWidth")
|
36
|
+
fun setStrokeWidth(polygon: Polygon, strokeWidth: Float) {
|
37
|
+
polygon.strokeWidth = strokeWidth.toPx().toFloat()
|
38
|
+
}
|
39
|
+
|
40
|
+
@ReactProp(name = "zIndex")
|
41
|
+
fun setIndex(polygon: Polygon, zIndex: Float) {
|
42
|
+
polygon.zIndex = zIndex
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import android.content.Context
|
4
|
+
import android.graphics.Color
|
5
|
+
import com.amap.api.maps.AMap
|
6
|
+
import com.amap.api.maps.model.LatLng
|
7
|
+
import com.amap.api.maps.model.Polyline
|
8
|
+
import com.amap.api.maps.model.PolylineOptions
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
10
|
+
|
11
|
+
class Polyline(context: Context) : ReactViewGroup(context), Overlay {
|
12
|
+
var polyline: Polyline? = null
|
13
|
+
var gradient: Boolean = false
|
14
|
+
var colors: List<Int> = emptyList()
|
15
|
+
|
16
|
+
var points: List<LatLng> = emptyList()
|
17
|
+
set(value) {
|
18
|
+
field = value
|
19
|
+
polyline?.points = value
|
20
|
+
}
|
21
|
+
|
22
|
+
var width: Float = 1f
|
23
|
+
set(value) {
|
24
|
+
field = value
|
25
|
+
polyline?.width = value
|
26
|
+
}
|
27
|
+
|
28
|
+
var color: Int = Color.BLACK
|
29
|
+
set(value) {
|
30
|
+
field = value
|
31
|
+
polyline?.color = value
|
32
|
+
}
|
33
|
+
|
34
|
+
var zIndex: Float = 0f
|
35
|
+
set(value) {
|
36
|
+
field = value
|
37
|
+
polyline?.zIndex = value
|
38
|
+
}
|
39
|
+
|
40
|
+
var geodesic: Boolean = false
|
41
|
+
set(value) {
|
42
|
+
field = value
|
43
|
+
polyline?.isGeodesic = value
|
44
|
+
}
|
45
|
+
|
46
|
+
var dashed: Boolean = false
|
47
|
+
set(value) {
|
48
|
+
field = value
|
49
|
+
polyline?.isDottedLine = value
|
50
|
+
}
|
51
|
+
|
52
|
+
override fun add(map: AMap) {
|
53
|
+
polyline = map.addPolyline(
|
54
|
+
PolylineOptions()
|
55
|
+
.addAll(points)
|
56
|
+
.color(color)
|
57
|
+
.colorValues(colors)
|
58
|
+
.width(width)
|
59
|
+
.useGradient(gradient)
|
60
|
+
.geodesic(geodesic)
|
61
|
+
.setDottedLine(dashed)
|
62
|
+
.zIndex(zIndex)
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
override fun remove() {
|
67
|
+
polyline?.remove()
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
package qiuxiang.amap3d.map_view
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
7
|
+
import qiuxiang.amap3d.getEventTypeConstants
|
8
|
+
import qiuxiang.amap3d.toLatLngList
|
9
|
+
import qiuxiang.amap3d.toPx
|
10
|
+
|
11
|
+
@Suppress("unused")
|
12
|
+
internal class PolylineManager : SimpleViewManager<Polyline>() {
|
13
|
+
override fun getName(): String {
|
14
|
+
return "AMapPolyline"
|
15
|
+
}
|
16
|
+
|
17
|
+
override fun createViewInstance(context: ThemedReactContext): Polyline {
|
18
|
+
return Polyline(context)
|
19
|
+
}
|
20
|
+
|
21
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
22
|
+
return getEventTypeConstants("onPress")
|
23
|
+
}
|
24
|
+
|
25
|
+
@ReactProp(name = "points")
|
26
|
+
fun setPoints(polyline: Polyline, points: ReadableArray) {
|
27
|
+
polyline.points = points.toLatLngList()
|
28
|
+
}
|
29
|
+
|
30
|
+
@ReactProp(name = "colors")
|
31
|
+
fun setColors(polyline: Polyline, colors: ReadableArray) {
|
32
|
+
polyline.colors = (0 until colors.size()).map { colors.getInt(it) }
|
33
|
+
}
|
34
|
+
|
35
|
+
@ReactProp(name = "color", customType = "Color")
|
36
|
+
fun setColor(polyline: Polyline, color: Int) {
|
37
|
+
polyline.color = color
|
38
|
+
}
|
39
|
+
|
40
|
+
@ReactProp(name = "width")
|
41
|
+
fun setWidth(polyline: Polyline, width: Float) {
|
42
|
+
polyline.width = width.toPx().toFloat()
|
43
|
+
}
|
44
|
+
|
45
|
+
@ReactProp(name = "zIndex")
|
46
|
+
fun setIndex(polyline: Polyline, zIndex: Float) {
|
47
|
+
polyline.zIndex = zIndex
|
48
|
+
}
|
49
|
+
|
50
|
+
@ReactProp(name = "geodesic")
|
51
|
+
fun setGeodesic(polyline: Polyline, geodesic: Boolean) {
|
52
|
+
polyline.geodesic = geodesic
|
53
|
+
}
|
54
|
+
|
55
|
+
@ReactProp(name = "dashed")
|
56
|
+
fun setDashed(polyline: Polyline, dashed: Boolean) {
|
57
|
+
polyline.dashed = dashed
|
58
|
+
}
|
59
|
+
|
60
|
+
@ReactProp(name = "gradient")
|
61
|
+
fun setGradient(polyline: Polyline, gradient: Boolean) {
|
62
|
+
polyline.gradient = gradient
|
63
|
+
}
|
64
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
package qiuxiang.amap3d.modules
|
2
|
+
|
3
|
+
import com.amap.api.location.AMapLocationClient
|
4
|
+
import com.amap.api.maps.MapsInitializer
|
5
|
+
import com.facebook.react.bridge.Promise
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
9
|
+
|
10
|
+
@Suppress("unused")
|
11
|
+
class SdkModule(val context: ReactApplicationContext) : ReactContextBaseJavaModule() {
|
12
|
+
override fun getName(): String {
|
13
|
+
return "AMapSdk"
|
14
|
+
}
|
15
|
+
|
16
|
+
@ReactMethod
|
17
|
+
fun initSDK(apiKey: String?) {
|
18
|
+
apiKey?.let {
|
19
|
+
MapsInitializer.setApiKey(it)
|
20
|
+
MapsInitializer.updatePrivacyAgree(context, true)
|
21
|
+
MapsInitializer.updatePrivacyShow(context, true, true)
|
22
|
+
AMapLocationClient.updatePrivacyAgree(context, true)
|
23
|
+
AMapLocationClient.updatePrivacyShow(context, true, true)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
@ReactMethod
|
28
|
+
fun getVersion(promise: Promise) {
|
29
|
+
promise.resolve(MapsInitializer.getVersion())
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#import <React/RCTUIManager.h>
|
2
|
+
|
3
|
+
@interface RCT_EXTERN_MODULE(AMapCircleManager, RCTViewManager)
|
4
|
+
|
5
|
+
RCT_REMAP_VIEW_PROPERTY(center, circleCenter, CLLocationCoordinate2D)
|
6
|
+
RCT_EXPORT_VIEW_PROPERTY(radius, double)
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(strokeWidth, double)
|
8
|
+
RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
|
9
|
+
RCT_EXPORT_VIEW_PROPERTY(fillColor, UIColor)
|
10
|
+
|
11
|
+
@end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
@objc(AMapCircleManager)
|
2
|
+
class AMapCircleManager: RCTViewManager {
|
3
|
+
override class func requiresMainQueueSetup() -> Bool { false }
|
4
|
+
override func view() -> UIView { Circle() }
|
5
|
+
}
|
6
|
+
|
7
|
+
class Circle: UIView, Overlay {
|
8
|
+
var overlay = MACircle()
|
9
|
+
var renderer: MACircleRenderer?
|
10
|
+
|
11
|
+
@objc var radius = 0.0 { didSet { overlay.radius = radius } }
|
12
|
+
@objc var strokeWidth = 1.0 { didSet { renderer?.lineWidth = strokeWidth } }
|
13
|
+
@objc var strokeColor = UIColor.black { didSet { renderer?.strokeColor = strokeColor } }
|
14
|
+
@objc var fillColor = UIColor.white { didSet { renderer?.fillColor = fillColor } }
|
15
|
+
|
16
|
+
@objc func setCircleCenter(_ center: CLLocationCoordinate2D) {
|
17
|
+
overlay.coordinate = center
|
18
|
+
}
|
19
|
+
|
20
|
+
func getOverlay() -> MABaseOverlay { overlay }
|
21
|
+
func getRenderer() -> MAOverlayRenderer {
|
22
|
+
if renderer == nil {
|
23
|
+
renderer = MACircleRenderer(circle: overlay)
|
24
|
+
renderer?.fillColor = fillColor
|
25
|
+
renderer?.strokeColor = strokeColor
|
26
|
+
renderer?.lineWidth = strokeWidth
|
27
|
+
}
|
28
|
+
return renderer!
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
@objc(AMapHeatMapManager)
|
2
|
+
class AMapHeatMapManager: RCTViewManager {
|
3
|
+
override class func requiresMainQueueSetup() -> Bool { false }
|
4
|
+
override func view() -> UIView { HeatMap() }
|
5
|
+
}
|
6
|
+
|
7
|
+
class HeatMap: UIView, Overlay {
|
8
|
+
var overlay = MAHeatMapTileOverlay()
|
9
|
+
var renderer: MATileOverlayRenderer?
|
10
|
+
|
11
|
+
func getOverlay() -> MABaseOverlay { overlay }
|
12
|
+
func getRenderer() -> MAOverlayRenderer {
|
13
|
+
if renderer == nil {
|
14
|
+
renderer = MATileOverlayRenderer(tileOverlay: overlay)
|
15
|
+
}
|
16
|
+
return renderer!
|
17
|
+
}
|
18
|
+
|
19
|
+
@objc func setRadius(_ radius: Int) { overlay.radius = radius }
|
20
|
+
@objc func setOpacity(_ opacity: Double) { overlay.opacity = opacity }
|
21
|
+
@objc func setData(_ data: NSArray) {
|
22
|
+
overlay.data = data.map { it -> MAHeatMapNode in
|
23
|
+
let item = MAHeatMapNode()
|
24
|
+
item.coordinate = (it as! NSDictionary).coordinate
|
25
|
+
item.intensity = 1
|
26
|
+
return item
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#import <React/RCTUIManager.h>
|
2
|
+
|
3
|
+
@interface RCT_EXTERN_MODULE(AMapViewManager, RCTViewManager)
|
4
|
+
|
5
|
+
RCT_EXPORT_VIEW_PROPERTY(mapType, MAMapType)
|
6
|
+
RCT_EXPORT_VIEW_PROPERTY(initialCameraPosition, NSDictionary)
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(distanceFilter, double)
|
8
|
+
RCT_EXPORT_VIEW_PROPERTY(headingFilter, double)
|
9
|
+
|
10
|
+
RCT_REMAP_VIEW_PROPERTY(myLocationEnabled, showsUserLocation, BOOL)
|
11
|
+
RCT_REMAP_VIEW_PROPERTY(buildingsEnabled, showsBuildings, BOOL)
|
12
|
+
RCT_REMAP_VIEW_PROPERTY(trafficEnabled, showTraffic, BOOL)
|
13
|
+
RCT_REMAP_VIEW_PROPERTY(indoorViewEnabled, showsIndoorMap, BOOL)
|
14
|
+
RCT_REMAP_VIEW_PROPERTY(compassEnabled, showsCompass, BOOL)
|
15
|
+
RCT_REMAP_VIEW_PROPERTY(scaleControlsEnabled, showsScale, BOOL)
|
16
|
+
RCT_REMAP_VIEW_PROPERTY(scrollGesturesEnabled, scrollEnabled, BOOL)
|
17
|
+
RCT_REMAP_VIEW_PROPERTY(zoomGesturesEnabled, zoomEnabled, BOOL)
|
18
|
+
RCT_REMAP_VIEW_PROPERTY(rotateGesturesEnabled, rotateEnabled, BOOL)
|
19
|
+
RCT_REMAP_VIEW_PROPERTY(tiltGesturesEnabled, rotateCameraEnabled, BOOL)
|
20
|
+
RCT_REMAP_VIEW_PROPERTY(minZoom, minZoomLevel, double)
|
21
|
+
RCT_REMAP_VIEW_PROPERTY(maxZoom, maxZoomLevel, double)
|
22
|
+
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
|
24
|
+
RCT_EXPORT_VIEW_PROPERTY(onPressPoi, RCTBubblingEventBlock)
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(onCameraIdle, RCTBubblingEventBlock)
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(onCameraMove, RCTBubblingEventBlock)
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock)
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
|
30
|
+
RCT_EXPORT_VIEW_PROPERTY(onCallback, RCTBubblingEventBlock)
|
31
|
+
|
32
|
+
RCT_EXTERN_METHOD(moveCamera:(nonnull NSNumber *)reactTag position:(NSDictionary *)_ duration:(int)_)
|
33
|
+
RCT_EXTERN_METHOD(call:(nonnull NSNumber *)reactTag callerId:(double)_ name:(NSString *)_ args:(NSDictionary *)_)
|
34
|
+
|
35
|
+
@end
|