@lugg/maps 0.2.0-alpha.9 → 1.0.0-beta.0
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.md +20 -19
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +290 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +99 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +13 -5
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +157 -13
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- package/android/src/main/java/com/luggmaps/LuggPolygonView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggPolygonViewManager.kt +100 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +698 -0
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +60 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -24
- package/android/src/main/java/com/luggmaps/events/LongPressEvent.kt +29 -0
- package/android/src/main/java/com/luggmaps/events/MarkerDragEvent.kt +41 -0
- package/android/src/main/java/com/luggmaps/events/MarkerPressEvent.kt +34 -0
- package/android/src/main/java/com/luggmaps/events/PolygonPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/PressEvent.kt +29 -0
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +343 -0
- package/ios/LuggMarkerView.h +13 -0
- package/ios/LuggMarkerView.mm +119 -0
- package/ios/LuggPolygonView.h +31 -0
- package/ios/LuggPolygonView.mm +151 -0
- package/ios/LuggPolylineView.h +4 -0
- package/ios/LuggPolylineView.mm +23 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/core/AppleMapProvider.mm +1029 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +101 -15
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +689 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +167 -42
- package/ios/core/MapProviderDelegate.h +84 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/events/LongPressEvent.h +29 -0
- package/ios/events/MarkerDragEvent.h +69 -0
- package/ios/events/MarkerPressEvent.h +29 -0
- package/ios/events/PolygonPressEvent.h +20 -0
- package/ios/events/PressEvent.h +29 -0
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +2 -4
- package/lib/module/MapProvider.js.map +1 -1
- package/lib/module/MapProvider.web.js +12 -7
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +33 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +283 -181
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/GeoJson.js +159 -0
- package/lib/module/components/GeoJson.js.map +1 -0
- package/lib/module/components/GeoJson.types.js +4 -0
- package/lib/module/components/GeoJson.types.js.map +1 -0
- package/lib/module/components/Marker.js +28 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.types.js +4 -0
- package/lib/module/components/Marker.types.js.map +1 -0
- package/lib/module/components/Marker.web.js +98 -27
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.js +46 -0
- package/lib/module/components/Polygon.js.map +1 -0
- package/lib/module/components/Polygon.types.js +4 -0
- package/lib/module/components/Polygon.types.js.map +1 -0
- package/lib/module/components/Polygon.web.js +87 -0
- package/lib/module/components/Polygon.web.js.map +1 -0
- package/lib/module/components/Polyline.js +17 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.types.js +4 -0
- package/lib/module/components/Polyline.types.js.map +1 -0
- package/lib/module/components/Polyline.web.js +108 -31
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +2 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/lib/module/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +4 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.d.ts +1 -1
- package/lib/typescript/src/MapProvider.d.ts.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +17 -1
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +4 -4
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +35 -9
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +2 -11
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.d.ts +4 -0
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts +79 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +6 -33
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +74 -0
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.web.d.ts +2 -5
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.d.ts +10 -0
- package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.types.d.ts +33 -0
- package/lib/typescript/src/components/Polygon.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.web.d.ts +3 -0
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +6 -21
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.types.d.ts +53 -0
- package/lib/typescript/src/components/Polyline.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +2 -5
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +8 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -2
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +30 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +45 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +9 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/MapProvider.tsx +1 -3
- package/src/MapProvider.web.tsx +12 -3
- package/src/MapView.tsx +32 -26
- package/src/MapView.types.ts +43 -9
- package/src/MapView.web.tsx +345 -211
- package/src/components/GeoJson.tsx +221 -0
- package/src/components/GeoJson.types.ts +107 -0
- package/src/components/Marker.tsx +45 -36
- package/src/components/Marker.types.ts +75 -0
- package/src/components/Marker.web.tsx +116 -28
- package/src/components/Polygon.tsx +52 -0
- package/src/components/Polygon.types.ts +33 -0
- package/src/components/Polygon.web.tsx +104 -0
- package/src/components/Polyline.tsx +23 -22
- package/src/components/Polyline.types.ts +55 -0
- package/src/components/Polyline.web.tsx +151 -37
- package/src/components/index.ts +16 -2
- package/src/components/index.web.ts +6 -2
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/src/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +28 -1
- package/src/index.web.ts +15 -1
- package/src/types.ts +13 -0
- package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +0 -511
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -592
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -455
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
package com.luggmaps
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.graphics.Bitmap
|
|
5
|
+
import android.graphics.Canvas
|
|
4
6
|
import android.view.View
|
|
7
|
+
import android.view.ViewGroup
|
|
8
|
+
import androidx.core.graphics.createBitmap
|
|
5
9
|
import androidx.core.view.isNotEmpty
|
|
6
10
|
import com.facebook.react.views.view.ReactViewGroup
|
|
7
11
|
import com.google.android.gms.maps.model.AdvancedMarker
|
|
12
|
+
import com.google.android.gms.maps.model.BitmapDescriptor
|
|
13
|
+
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
|
14
|
+
import com.luggmaps.events.MarkerDragEvent
|
|
15
|
+
import com.luggmaps.events.MarkerPressEvent
|
|
16
|
+
import com.luggmaps.extensions.dispatchEvent
|
|
8
17
|
|
|
9
18
|
interface LuggMarkerViewDelegate {
|
|
10
19
|
fun markerViewDidUpdate(markerView: LuggMarkerView)
|
|
@@ -12,6 +21,8 @@ interface LuggMarkerViewDelegate {
|
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
24
|
+
private var scaleUpdateRunnable: Runnable? = null
|
|
25
|
+
|
|
15
26
|
var name: String? = null
|
|
16
27
|
private set
|
|
17
28
|
|
|
@@ -36,23 +47,120 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
36
47
|
var zIndex: Float = 0f
|
|
37
48
|
private set
|
|
38
49
|
|
|
50
|
+
var rotate: Float = 0f
|
|
51
|
+
private set
|
|
52
|
+
|
|
53
|
+
var scale: Float = 1f
|
|
54
|
+
private set
|
|
55
|
+
|
|
56
|
+
var scaleChanged: Boolean = false
|
|
57
|
+
private set
|
|
58
|
+
|
|
59
|
+
var rasterize: Boolean = true
|
|
60
|
+
private set
|
|
61
|
+
|
|
62
|
+
var draggable: Boolean = false
|
|
63
|
+
private set
|
|
64
|
+
|
|
65
|
+
var isDragging: Boolean = false
|
|
66
|
+
|
|
39
67
|
var didLayout: Boolean = false
|
|
40
68
|
private set
|
|
41
69
|
|
|
42
70
|
val hasCustomView: Boolean
|
|
43
71
|
get() = iconView.isNotEmpty()
|
|
44
72
|
|
|
45
|
-
val iconView: ReactViewGroup =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
val iconView: ReactViewGroup = ReactViewGroup(context)
|
|
74
|
+
|
|
75
|
+
private fun measureIconViewBounds(): Pair<Int, Int> {
|
|
76
|
+
var maxWidth = 0
|
|
77
|
+
var maxHeight = 0
|
|
78
|
+
for (i in 0 until iconView.childCount) {
|
|
79
|
+
val child = iconView.getChildAt(i)
|
|
80
|
+
val childRight = child.left + child.width
|
|
81
|
+
val childBottom = child.top + child.height
|
|
82
|
+
if (childRight > maxWidth) maxWidth = childRight
|
|
83
|
+
if (childBottom > maxHeight) maxHeight = childBottom
|
|
84
|
+
}
|
|
85
|
+
return Pair(maxWidth, maxHeight)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private fun createIconBitmap(): BitmapDescriptor? {
|
|
89
|
+
val (width, height) = measureIconViewBounds()
|
|
90
|
+
if (width <= 0 || height <= 0) return null
|
|
91
|
+
|
|
92
|
+
val scaledWidth = (width * scale).toInt()
|
|
93
|
+
val scaledHeight = (height * scale).toInt()
|
|
94
|
+
|
|
95
|
+
val bitmap = createBitmap(scaledWidth, scaledHeight)
|
|
96
|
+
val canvas = Canvas(bitmap)
|
|
97
|
+
canvas.scale(scale, scale)
|
|
98
|
+
iconView.draw(canvas)
|
|
99
|
+
return BitmapDescriptorFactory.fromBitmap(bitmap)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private fun createIconViewWrapper(): View {
|
|
103
|
+
val (width, height) = measureIconViewBounds()
|
|
104
|
+
val scaledWidth = (width * scale).toInt()
|
|
105
|
+
val scaledHeight = (height * scale).toInt()
|
|
106
|
+
|
|
107
|
+
(iconView.parent as? ViewGroup)?.removeView(iconView)
|
|
108
|
+
iconView.scaleX = scale
|
|
109
|
+
iconView.scaleY = scale
|
|
110
|
+
iconView.pivotX = 0f
|
|
111
|
+
iconView.pivotY = 0f
|
|
112
|
+
|
|
113
|
+
return object : ReactViewGroup(context) {
|
|
114
|
+
init {
|
|
115
|
+
addView(iconView)
|
|
53
116
|
}
|
|
54
117
|
|
|
55
|
-
|
|
118
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
119
|
+
setMeasuredDimension(scaledWidth, scaledHeight)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
fun applyIconToMarker() {
|
|
125
|
+
val m = marker ?: return
|
|
126
|
+
if (!hasCustomView) return
|
|
127
|
+
|
|
128
|
+
if (rasterize) {
|
|
129
|
+
createIconBitmap()?.let { m.setIcon(it) }
|
|
130
|
+
} else {
|
|
131
|
+
m.iconView = createIconViewWrapper()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fun applyScaleToMarker() {
|
|
136
|
+
val m = marker ?: return
|
|
137
|
+
if (!hasCustomView) return
|
|
138
|
+
|
|
139
|
+
scaleUpdateRunnable?.let { removeCallbacks(it) }
|
|
140
|
+
scaleUpdateRunnable = Runnable {
|
|
141
|
+
if (rasterize) {
|
|
142
|
+
createIconBitmap()?.let { m.setIcon(it) }
|
|
143
|
+
} else {
|
|
144
|
+
m.iconView = createIconViewWrapper()
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
post(scaleUpdateRunnable)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fun updateIcon(onAddMarker: () -> Unit) {
|
|
151
|
+
if (!hasCustomView) return
|
|
152
|
+
if (rasterize) {
|
|
153
|
+
post {
|
|
154
|
+
if (marker == null) {
|
|
155
|
+
onAddMarker()
|
|
156
|
+
} else {
|
|
157
|
+
applyIconToMarker()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
marker?.remove()
|
|
162
|
+
marker = null
|
|
163
|
+
post { onAddMarker() }
|
|
56
164
|
}
|
|
57
165
|
}
|
|
58
166
|
|
|
@@ -92,6 +200,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
92
200
|
bottom: Int
|
|
93
201
|
) {
|
|
94
202
|
super.onLayout(changed, left, top, right, bottom)
|
|
203
|
+
|
|
95
204
|
if (changed && !didLayout) {
|
|
96
205
|
didLayout = true
|
|
97
206
|
delegate?.markerViewDidLayout(this)
|
|
@@ -120,6 +229,43 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
120
229
|
this.zIndex = zIndex
|
|
121
230
|
}
|
|
122
231
|
|
|
232
|
+
fun setRotate(rotate: Float) {
|
|
233
|
+
this.rotate = rotate
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
fun setScale(scale: Float) {
|
|
237
|
+
scaleChanged = this.scale != scale
|
|
238
|
+
this.scale = scale
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
fun clearScaleChanged() {
|
|
242
|
+
scaleChanged = false
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
fun setRasterize(rasterize: Boolean) {
|
|
246
|
+
this.rasterize = rasterize
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
fun setDraggable(draggable: Boolean) {
|
|
250
|
+
this.draggable = draggable
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
fun emitPressEvent(x: Float, y: Float) {
|
|
254
|
+
dispatchEvent(MarkerPressEvent(this, latitude, longitude, x, y))
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fun emitDragStartEvent(x: Float, y: Float) {
|
|
258
|
+
dispatchEvent(MarkerDragEvent(this, MarkerDragEvent.DRAG_START, latitude, longitude, x, y))
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
fun emitDragChangeEvent(x: Float, y: Float) {
|
|
262
|
+
dispatchEvent(MarkerDragEvent(this, MarkerDragEvent.DRAG_CHANGE, latitude, longitude, x, y))
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
fun emitDragEndEvent(x: Float, y: Float) {
|
|
266
|
+
dispatchEvent(MarkerDragEvent(this, MarkerDragEvent.DRAG_END, latitude, longitude, x, y))
|
|
267
|
+
}
|
|
268
|
+
|
|
123
269
|
fun setName(name: String?) {
|
|
124
270
|
this.name = name
|
|
125
271
|
}
|
|
@@ -129,12 +275,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
129
275
|
}
|
|
130
276
|
|
|
131
277
|
fun onDropViewInstance() {
|
|
278
|
+
scaleUpdateRunnable?.let { removeCallbacks(it) }
|
|
279
|
+
scaleUpdateRunnable = null
|
|
132
280
|
didLayout = false
|
|
133
281
|
delegate = null
|
|
134
282
|
iconView.removeAllViews()
|
|
135
283
|
}
|
|
136
|
-
|
|
137
|
-
companion object {
|
|
138
|
-
private const val TAG = "Lugg"
|
|
139
|
-
}
|
|
140
284
|
}
|
|
@@ -20,6 +20,14 @@ class LuggMarkerViewManager :
|
|
|
20
20
|
override fun getName(): String = NAME
|
|
21
21
|
override fun createViewInstance(context: ThemedReactContext): LuggMarkerView = LuggMarkerView(context)
|
|
22
22
|
|
|
23
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> =
|
|
24
|
+
mapOf(
|
|
25
|
+
"topMarkerPress" to mapOf("registrationName" to "onMarkerPress"),
|
|
26
|
+
"topMarkerDragStart" to mapOf("registrationName" to "onMarkerDragStart"),
|
|
27
|
+
"topMarkerDragChange" to mapOf("registrationName" to "onMarkerDragChange"),
|
|
28
|
+
"topMarkerDragEnd" to mapOf("registrationName" to "onMarkerDragEnd")
|
|
29
|
+
)
|
|
30
|
+
|
|
23
31
|
override fun onDropViewInstance(view: LuggMarkerView) {
|
|
24
32
|
super.onDropViewInstance(view)
|
|
25
33
|
view.onDropViewInstance()
|
|
@@ -69,6 +77,26 @@ class LuggMarkerViewManager :
|
|
|
69
77
|
view.setZIndex(zIndex)
|
|
70
78
|
}
|
|
71
79
|
|
|
80
|
+
@ReactProp(name = "rotate", defaultDouble = 0.0)
|
|
81
|
+
override fun setRotate(view: LuggMarkerView, value: Double) {
|
|
82
|
+
view.setRotate(value.toFloat())
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@ReactProp(name = "scale", defaultDouble = 1.0)
|
|
86
|
+
override fun setScale(view: LuggMarkerView, value: Double) {
|
|
87
|
+
view.setScale(value.toFloat())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@ReactProp(name = "rasterize", defaultBoolean = true)
|
|
91
|
+
override fun setRasterize(view: LuggMarkerView, value: Boolean) {
|
|
92
|
+
view.setRasterize(value)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@ReactProp(name = "draggable", defaultBoolean = false)
|
|
96
|
+
override fun setDraggable(view: LuggMarkerView, value: Boolean) {
|
|
97
|
+
view.setDraggable(value)
|
|
98
|
+
}
|
|
99
|
+
|
|
72
100
|
companion object {
|
|
73
101
|
const val NAME = "LuggMarkerView"
|
|
74
102
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
package com.luggmaps
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
5
|
import com.facebook.react.uimanager.ViewManager
|
|
7
6
|
|
|
8
7
|
class LuggPackage : ReactPackage {
|
|
9
8
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
10
|
-
listOf(
|
|
11
|
-
|
|
12
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = emptyList()
|
|
9
|
+
listOf(LuggMapViewManager(), LuggMarkerViewManager(), LuggMapWrapperViewManager(), LuggPolylineViewManager(), LuggPolygonViewManager())
|
|
13
10
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package com.luggmaps
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Color
|
|
5
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
6
|
+
import com.google.android.gms.maps.model.LatLng
|
|
7
|
+
import com.google.android.gms.maps.model.Polygon
|
|
8
|
+
import com.luggmaps.events.PolygonPressEvent
|
|
9
|
+
import com.luggmaps.extensions.dispatchEvent
|
|
10
|
+
|
|
11
|
+
interface LuggPolygonViewDelegate {
|
|
12
|
+
fun polygonViewDidUpdate(polygonView: LuggPolygonView)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class LuggPolygonView(context: Context) : ReactViewGroup(context) {
|
|
16
|
+
var coordinates: List<LatLng> = emptyList()
|
|
17
|
+
private set
|
|
18
|
+
|
|
19
|
+
var holes: List<List<LatLng>> = emptyList()
|
|
20
|
+
private set
|
|
21
|
+
|
|
22
|
+
var strokeColor: Int = Color.BLACK
|
|
23
|
+
private set
|
|
24
|
+
|
|
25
|
+
var fillColor: Int = Color.argb(77, 0, 0, 0)
|
|
26
|
+
private set
|
|
27
|
+
|
|
28
|
+
var strokeWidth: Float = 1f
|
|
29
|
+
private set
|
|
30
|
+
|
|
31
|
+
var zIndex: Float = 0f
|
|
32
|
+
private set
|
|
33
|
+
|
|
34
|
+
var tappable: Boolean = false
|
|
35
|
+
private set
|
|
36
|
+
|
|
37
|
+
var delegate: LuggPolygonViewDelegate? = null
|
|
38
|
+
var polygon: Polygon? = null
|
|
39
|
+
|
|
40
|
+
init {
|
|
41
|
+
visibility = GONE
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fun setCoordinates(coords: List<LatLng>) {
|
|
45
|
+
coordinates = coords
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fun setHoles(value: List<List<LatLng>>) {
|
|
49
|
+
holes = value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fun setStrokeColor(color: Int) {
|
|
53
|
+
strokeColor = color
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fun setFillColor(color: Int) {
|
|
57
|
+
fillColor = color
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fun setStrokeWidth(width: Float) {
|
|
61
|
+
strokeWidth = width
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fun setZIndex(value: Float) {
|
|
65
|
+
zIndex = value
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fun setTappable(value: Boolean) {
|
|
69
|
+
tappable = value
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fun emitPressEvent() {
|
|
73
|
+
dispatchEvent(PolygonPressEvent(this))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fun onAfterUpdateTransaction() {
|
|
77
|
+
delegate?.polygonViewDidUpdate(this)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun onDropViewInstance() {
|
|
81
|
+
delegate = null
|
|
82
|
+
polygon?.remove()
|
|
83
|
+
polygon = null
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
package com.luggmaps
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.LuggPolygonViewManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.LuggPolygonViewManagerInterface
|
|
11
|
+
import com.google.android.gms.maps.model.LatLng
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = LuggPolygonViewManager.NAME)
|
|
14
|
+
class LuggPolygonViewManager :
|
|
15
|
+
ViewGroupManager<LuggPolygonView>(),
|
|
16
|
+
LuggPolygonViewManagerInterface<LuggPolygonView> {
|
|
17
|
+
private val delegate: ViewManagerDelegate<LuggPolygonView> = LuggPolygonViewManagerDelegate(this)
|
|
18
|
+
|
|
19
|
+
override fun getDelegate(): ViewManagerDelegate<LuggPolygonView> = delegate
|
|
20
|
+
override fun getName(): String = NAME
|
|
21
|
+
override fun createViewInstance(context: ThemedReactContext): LuggPolygonView = LuggPolygonView(context)
|
|
22
|
+
|
|
23
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> =
|
|
24
|
+
mapOf("topPolygonPress" to mapOf("registrationName" to "onPolygonPress"))
|
|
25
|
+
|
|
26
|
+
override fun onDropViewInstance(view: LuggPolygonView) {
|
|
27
|
+
super.onDropViewInstance(view)
|
|
28
|
+
view.onDropViewInstance()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun onAfterUpdateTransaction(view: LuggPolygonView) {
|
|
32
|
+
super.onAfterUpdateTransaction(view)
|
|
33
|
+
view.onAfterUpdateTransaction()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactProp(name = "coordinates")
|
|
37
|
+
override fun setCoordinates(view: LuggPolygonView, value: ReadableArray?) {
|
|
38
|
+
value?.let { array ->
|
|
39
|
+
val coords = mutableListOf<LatLng>()
|
|
40
|
+
for (i in 0 until array.size()) {
|
|
41
|
+
val coord = array.getMap(i)
|
|
42
|
+
val lat = coord?.getDouble("latitude") ?: 0.0
|
|
43
|
+
val lng = coord?.getDouble("longitude") ?: 0.0
|
|
44
|
+
coords.add(LatLng(lat, lng))
|
|
45
|
+
}
|
|
46
|
+
view.setCoordinates(coords)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@ReactProp(name = "holes")
|
|
51
|
+
override fun setHoles(view: LuggPolygonView, value: ReadableArray?) {
|
|
52
|
+
value?.let { array ->
|
|
53
|
+
val holesList = mutableListOf<List<LatLng>>()
|
|
54
|
+
for (i in 0 until array.size()) {
|
|
55
|
+
val holeArray = array.getArray(i)
|
|
56
|
+
val hole = mutableListOf<LatLng>()
|
|
57
|
+
if (holeArray != null) {
|
|
58
|
+
for (j in 0 until holeArray.size()) {
|
|
59
|
+
val coord = holeArray.getMap(j)
|
|
60
|
+
val lat = coord?.getDouble("latitude") ?: 0.0
|
|
61
|
+
val lng = coord?.getDouble("longitude") ?: 0.0
|
|
62
|
+
hole.add(LatLng(lat, lng))
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
holesList.add(hole)
|
|
66
|
+
}
|
|
67
|
+
view.setHoles(holesList)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactProp(name = "strokeColor", customType = "Color")
|
|
72
|
+
override fun setStrokeColor(view: LuggPolygonView, value: Int?) {
|
|
73
|
+
view.setStrokeColor(value ?: android.graphics.Color.BLACK)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactProp(name = "fillColor", customType = "Color")
|
|
77
|
+
override fun setFillColor(view: LuggPolygonView, value: Int?) {
|
|
78
|
+
view.setFillColor(value ?: android.graphics.Color.argb(77, 0, 0, 0))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactProp(name = "strokeWidth", defaultDouble = 1.0)
|
|
82
|
+
override fun setStrokeWidth(view: LuggPolygonView, value: Double) {
|
|
83
|
+
view.setStrokeWidth(value.toFloat())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@ReactProp(name = "tappable")
|
|
87
|
+
override fun setTappable(view: LuggPolygonView, value: Boolean) {
|
|
88
|
+
view.setTappable(value)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@ReactProp(name = "zIndex", defaultFloat = 0f)
|
|
92
|
+
override fun setZIndex(view: LuggPolygonView, value: Float) {
|
|
93
|
+
super.setZIndex(view, value)
|
|
94
|
+
view.setZIndex(value)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
companion object {
|
|
98
|
+
const val NAME = "LuggPolygonView"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -12,6 +12,8 @@ interface LuggPolylineViewDelegate {
|
|
|
12
12
|
fun polylineViewDidUpdate(polylineView: LuggPolylineView)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
data class AnimatedOptions(val duration: Long = 2150L, val easing: String = "linear", val trailLength: Float = 1f, val delay: Long = 0L)
|
|
16
|
+
|
|
15
17
|
class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
16
18
|
var coordinates: List<LatLng> = emptyList()
|
|
17
19
|
private set
|
|
@@ -25,6 +27,12 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
25
27
|
var animated: Boolean = false
|
|
26
28
|
private set
|
|
27
29
|
|
|
30
|
+
var animatedOptions: AnimatedOptions = AnimatedOptions()
|
|
31
|
+
private set
|
|
32
|
+
|
|
33
|
+
var zIndex: Float = 0f
|
|
34
|
+
private set
|
|
35
|
+
|
|
28
36
|
var cachedSpans: List<StyleSpan>? = null
|
|
29
37
|
private set
|
|
30
38
|
|
|
@@ -55,6 +63,14 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
55
63
|
animated = value
|
|
56
64
|
}
|
|
57
65
|
|
|
66
|
+
fun setAnimatedOptions(options: AnimatedOptions) {
|
|
67
|
+
animatedOptions = options
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fun setZIndex(value: Float) {
|
|
71
|
+
zIndex = value
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
fun getOrCreateSpans(): List<StyleSpan> {
|
|
59
75
|
cachedSpans?.let { return it }
|
|
60
76
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.luggmaps
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableArray
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
5
6
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
7
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
@@ -65,6 +66,27 @@ class LuggPolylineViewManager :
|
|
|
65
66
|
view.setAnimated(value)
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
@ReactProp(name = "animatedOptions")
|
|
70
|
+
override fun setAnimatedOptions(view: LuggPolylineView, value: ReadableMap?) {
|
|
71
|
+
val options = if (value != null) {
|
|
72
|
+
AnimatedOptions(
|
|
73
|
+
duration = if (value.hasKey("duration")) value.getDouble("duration").toLong() else 2150L,
|
|
74
|
+
easing = if (value.hasKey("easing")) value.getString("easing") ?: "linear" else "linear",
|
|
75
|
+
trailLength = if (value.hasKey("trailLength")) value.getDouble("trailLength").toFloat() else 1f,
|
|
76
|
+
delay = if (value.hasKey("delay")) value.getDouble("delay").toLong() else 0L
|
|
77
|
+
)
|
|
78
|
+
} else {
|
|
79
|
+
AnimatedOptions()
|
|
80
|
+
}
|
|
81
|
+
view.setAnimatedOptions(options)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@ReactProp(name = "zIndex", defaultFloat = 0f)
|
|
85
|
+
override fun setZIndex(view: LuggPolylineView, value: Float) {
|
|
86
|
+
super.setZIndex(view, value)
|
|
87
|
+
view.setZIndex(value)
|
|
88
|
+
}
|
|
89
|
+
|
|
68
90
|
companion object {
|
|
69
91
|
const val NAME = "LuggPolylineView"
|
|
70
92
|
}
|