expo-gaode-map 1.1.8 → 2.0.0-alpha.2
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/README.en.md +32 -46
- package/README.md +51 -70
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +98 -268
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapViewModule.kt +1 -49
- package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +30 -7
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +1 -0
- package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +10 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +38 -14
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleViewModule.kt +3 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterView.kt +8 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapView.kt +4 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +322 -93
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +11 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +4 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +25 -11
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonViewModule.kt +3 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +20 -10
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineViewModule.kt +6 -2
- package/build/ExpoGaodeMap.types.d.ts +27 -6
- package/build/ExpoGaodeMap.types.d.ts.map +1 -1
- package/build/ExpoGaodeMap.types.js +3 -0
- package/build/ExpoGaodeMap.types.js.map +1 -1
- package/build/ExpoGaodeMapModule.d.ts +157 -10
- package/build/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapModule.js +4 -0
- package/build/ExpoGaodeMapModule.js.map +1 -1
- package/build/ExpoGaodeMapView.d.ts +1 -17
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +4 -221
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +11 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +12 -58
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +13 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +51 -115
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts +7 -15
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +10 -80
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts +7 -14
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +9 -66
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/index.d.ts +1 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -10
- package/build/index.js.map +1 -1
- package/build/types/map-view.types.d.ts +0 -90
- package/build/types/map-view.types.d.ts.map +1 -1
- package/build/types/map-view.types.js.map +1 -1
- package/build/types/overlays.types.d.ts +9 -9
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.en.md +1 -21
- package/docs/API.md +84 -56
- package/docs/EXAMPLES.en.md +0 -48
- package/docs/EXAMPLES.md +49 -102
- package/docs/INITIALIZATION.md +59 -71
- package/docs/MIGRATION.md +423 -0
- package/ios/ExpoGaodeMapModule.swift +4 -0
- package/ios/ExpoGaodeMapView.swift +365 -258
- package/ios/ExpoGaodeMapViewModule.swift +3 -50
- package/ios/managers/CameraManager.swift +23 -2
- package/ios/managers/UIManager.swift +10 -5
- package/ios/modules/LocationManager.swift +10 -0
- package/ios/overlays/CircleView.swift +98 -19
- package/ios/overlays/CircleViewModule.swift +21 -0
- package/ios/overlays/ClusterView.swift +33 -4
- package/ios/overlays/HeatMapView.swift +16 -4
- package/ios/overlays/MarkerView.swift +235 -146
- package/ios/overlays/MarkerViewModule.swift +7 -3
- package/ios/overlays/MultiPointView.swift +30 -1
- package/ios/overlays/PolygonView.swift +63 -12
- package/ios/overlays/PolygonViewModule.swift +17 -0
- package/ios/overlays/PolylineView.swift +95 -25
- package/ios/overlays/PolylineViewModule.swift +17 -8
- package/ios/utils/PermissionManager.swift +9 -14
- package/package.json +4 -3
- package/src/ExpoGaodeMap.types.ts +28 -3
- package/src/ExpoGaodeMapModule.ts +201 -12
- package/src/ExpoGaodeMapView.tsx +9 -234
- package/src/components/overlays/Circle.tsx +14 -70
- package/src/components/overlays/Cluster.tsx +0 -1
- package/src/components/overlays/Marker.tsx +63 -138
- package/src/components/overlays/Polygon.tsx +12 -92
- package/src/components/overlays/Polyline.tsx +11 -77
- package/src/index.ts +4 -29
- package/src/types/map-view.types.ts +1 -85
- package/src/types/overlays.types.ts +9 -9
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +0 -574
- package/build/modules/AMapLocation.d.ts +0 -78
- package/build/modules/AMapLocation.d.ts.map +0 -1
- package/build/modules/AMapLocation.js +0 -132
- package/build/modules/AMapLocation.js.map +0 -1
- package/build/modules/AMapPermissions.d.ts +0 -29
- package/build/modules/AMapPermissions.d.ts.map +0 -1
- package/build/modules/AMapPermissions.js +0 -23
- package/build/modules/AMapPermissions.js.map +0 -1
- package/build/modules/AMapSDK.d.ts +0 -22
- package/build/modules/AMapSDK.d.ts.map +0 -1
- package/build/modules/AMapSDK.js +0 -25
- package/build/modules/AMapSDK.js.map +0 -1
- package/build/modules/AMapView.d.ts +0 -44
- package/build/modules/AMapView.d.ts.map +0 -1
- package/build/modules/AMapView.js +0 -65
- package/build/modules/AMapView.js.map +0 -1
- package/ios/managers/OverlayManager.swift +0 -522
- package/src/modules/AMapLocation.ts +0 -165
- package/src/modules/AMapPermissions.ts +0 -41
- package/src/modules/AMapSDK.ts +0 -31
- package/src/modules/AMapView.ts +0 -72
|
@@ -6,6 +6,7 @@ import com.amap.api.maps.AMap
|
|
|
6
6
|
import com.amap.api.maps.model.Circle
|
|
7
7
|
import com.amap.api.maps.model.CircleOptions
|
|
8
8
|
import com.amap.api.maps.model.LatLng
|
|
9
|
+
import expo.modules.gaodemap.utils.ColorParser
|
|
9
10
|
import expo.modules.kotlin.AppContext
|
|
10
11
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
11
12
|
import expo.modules.kotlin.views.ExpoView
|
|
@@ -13,7 +14,7 @@ import expo.modules.kotlin.views.ExpoView
|
|
|
13
14
|
class CircleView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
14
15
|
|
|
15
16
|
@Suppress("unused")
|
|
16
|
-
private val
|
|
17
|
+
private val onCirclePress by EventDispatcher()
|
|
17
18
|
|
|
18
19
|
private var circle: Circle? = null
|
|
19
20
|
private var aMap: AMap? = null
|
|
@@ -22,6 +23,8 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
22
23
|
private var fillColor: Int = Color.argb(50, 0, 0, 255)
|
|
23
24
|
private var strokeColor: Int = Color.BLUE
|
|
24
25
|
private var strokeWidth: Float = 10f
|
|
26
|
+
|
|
27
|
+
private var _zIndex: Float = 0f
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* 设置地图实例
|
|
@@ -40,6 +43,10 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
40
43
|
val lat = centerMap["latitude"]
|
|
41
44
|
val lng = centerMap["longitude"]
|
|
42
45
|
if (lat != null && lng != null) {
|
|
46
|
+
// 坐标验证
|
|
47
|
+
if (lat < -90 || lat > 90 || lng < -180 || lng > 180) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
43
50
|
center = LatLng(lat, lng)
|
|
44
51
|
circle?.center = center
|
|
45
52
|
}
|
|
@@ -49,24 +56,33 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
49
56
|
* 设置半径
|
|
50
57
|
*/
|
|
51
58
|
fun setRadius(radiusValue: Double) {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
// 半径验证(必须大于0)
|
|
60
|
+
val validRadius = if (radiusValue > 0) radiusValue else 1000.0
|
|
61
|
+
radius = validRadius
|
|
62
|
+
circle?.let {
|
|
63
|
+
it.radius = radius
|
|
64
|
+
} ?: createOrUpdateCircle()
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
/**
|
|
57
68
|
* 设置填充颜色
|
|
58
69
|
*/
|
|
59
|
-
fun setFillColor(color:
|
|
60
|
-
fillColor = color
|
|
61
|
-
|
|
70
|
+
fun setFillColor(color: Any) {
|
|
71
|
+
fillColor = ColorParser.parseColor(color)
|
|
72
|
+
circle?.let {
|
|
73
|
+
it.fillColor = fillColor
|
|
74
|
+
} ?: createOrUpdateCircle()
|
|
75
|
+
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
/**
|
|
65
79
|
* 设置边框颜色
|
|
66
80
|
*/
|
|
67
|
-
fun setStrokeColor(color:
|
|
68
|
-
strokeColor =
|
|
69
|
-
circle?.
|
|
81
|
+
fun setStrokeColor(color: Any) {
|
|
82
|
+
strokeColor = ColorParser.parseColor(color)
|
|
83
|
+
circle?.let {
|
|
84
|
+
it.strokeColor = strokeColor
|
|
85
|
+
} ?: createOrUpdateCircle()
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
/**
|
|
@@ -76,14 +92,19 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
76
92
|
fun setStrokeWidth(width: Float) {
|
|
77
93
|
val density = context.resources.displayMetrics.density
|
|
78
94
|
strokeWidth = width * density
|
|
79
|
-
circle?.
|
|
95
|
+
circle?.let {
|
|
96
|
+
it.strokeWidth = strokeWidth
|
|
97
|
+
} ?: createOrUpdateCircle()
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
/**
|
|
83
101
|
* 设置 z-index
|
|
84
102
|
*/
|
|
85
103
|
fun setZIndex(zIndex: Float) {
|
|
86
|
-
|
|
104
|
+
_zIndex = zIndex
|
|
105
|
+
circle?.let {
|
|
106
|
+
it.zIndex = _zIndex
|
|
107
|
+
} ?: createOrUpdateCircle()
|
|
87
108
|
}
|
|
88
109
|
|
|
89
110
|
/**
|
|
@@ -94,14 +115,15 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
94
115
|
val centerPoint = center ?: return
|
|
95
116
|
|
|
96
117
|
if (circle == null) {
|
|
97
|
-
|
|
118
|
+
|
|
98
119
|
circle = map.addCircle(
|
|
99
120
|
CircleOptions()
|
|
100
121
|
.center(centerPoint)
|
|
101
122
|
.radius(radius)
|
|
102
123
|
.fillColor(fillColor)
|
|
103
124
|
.strokeColor(strokeColor)
|
|
104
|
-
.strokeWidth(strokeWidth
|
|
125
|
+
.strokeWidth(strokeWidth)
|
|
126
|
+
.zIndex(_zIndex)
|
|
105
127
|
)
|
|
106
128
|
}
|
|
107
129
|
}
|
|
@@ -112,7 +134,7 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
112
134
|
fun checkPress(latLng: LatLng): Boolean {
|
|
113
135
|
circle?.let { c ->
|
|
114
136
|
if (c.contains(latLng)) {
|
|
115
|
-
|
|
137
|
+
onCirclePress(mapOf(
|
|
116
138
|
"latitude" to latLng.latitude,
|
|
117
139
|
"longitude" to latLng.longitude
|
|
118
140
|
))
|
|
@@ -133,5 +155,7 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
133
155
|
override fun onDetachedFromWindow() {
|
|
134
156
|
super.onDetachedFromWindow()
|
|
135
157
|
removeCircle()
|
|
158
|
+
aMap = null
|
|
136
159
|
}
|
|
160
|
+
|
|
137
161
|
}
|
|
@@ -11,7 +11,7 @@ class CircleViewModule : Module() {
|
|
|
11
11
|
Name("CircleView")
|
|
12
12
|
|
|
13
13
|
View(CircleView::class) {
|
|
14
|
-
Events("
|
|
14
|
+
Events("onCirclePress")
|
|
15
15
|
|
|
16
16
|
Prop<Map<String, Double>>("center") { view, center ->
|
|
17
17
|
view.setCenter(center)
|
|
@@ -21,11 +21,11 @@ class CircleViewModule : Module() {
|
|
|
21
21
|
view.setRadius(radius)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
Prop<
|
|
24
|
+
Prop<Any>("fillColor") { view, color ->
|
|
25
25
|
view.setFillColor(color)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
Prop<
|
|
28
|
+
Prop<Any>("strokeColor") { view, color ->
|
|
29
29
|
view.setStrokeColor(color)
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -42,7 +42,12 @@ class ClusterView(context: Context, appContext: AppContext) : ExpoView(context,
|
|
|
42
42
|
* 设置聚合点数据
|
|
43
43
|
*/
|
|
44
44
|
fun setPoints(pointsList: List<Map<String, Any>>) {
|
|
45
|
-
|
|
45
|
+
// 过滤无效坐标
|
|
46
|
+
points = pointsList.filter { point ->
|
|
47
|
+
val lat = (point["latitude"] as? Number)?.toDouble()
|
|
48
|
+
val lng = (point["longitude"] as? Number)?.toDouble()
|
|
49
|
+
lat != null && lng != null && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180
|
|
50
|
+
}
|
|
46
51
|
createOrUpdateCluster()
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -118,10 +123,12 @@ class ClusterView(context: Context, appContext: AppContext) : ExpoView(context,
|
|
|
118
123
|
fun removeCluster() {
|
|
119
124
|
markers.forEach { it.remove() }
|
|
120
125
|
markers.clear()
|
|
126
|
+
points = emptyList()
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
override fun onDetachedFromWindow() {
|
|
124
130
|
super.onDetachedFromWindow()
|
|
125
131
|
removeCluster()
|
|
132
|
+
aMap = null
|
|
126
133
|
}
|
|
127
134
|
}
|
|
@@ -34,7 +34,8 @@ class HeatMapView(context: Context, appContext: AppContext) : ExpoView(context,
|
|
|
34
34
|
data.forEach { point ->
|
|
35
35
|
val lat = (point["latitude"] as? Number)?.toDouble()
|
|
36
36
|
val lng = (point["longitude"] as? Number)?.toDouble()
|
|
37
|
-
|
|
37
|
+
// 坐标验证
|
|
38
|
+
if (lat != null && lng != null && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180) {
|
|
38
39
|
dataList.add(LatLng(lat, lng))
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -88,10 +89,12 @@ class HeatMapView(context: Context, appContext: AppContext) : ExpoView(context,
|
|
|
88
89
|
fun removeHeatMap() {
|
|
89
90
|
heatmapOverlay?.remove()
|
|
90
91
|
heatmapOverlay = null
|
|
92
|
+
dataList.clear()
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
override fun onDetachedFromWindow() {
|
|
94
96
|
super.onDetachedFromWindow()
|
|
95
97
|
removeHeatMap()
|
|
98
|
+
aMap = null
|
|
96
99
|
}
|
|
97
100
|
}
|