@lugg/maps 0.2.0-alpha.8 → 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 +315 -217
- 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 +376 -244
- 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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package com.luggmaps.core
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.luggmaps.LuggMarkerView
|
|
5
|
+
import com.luggmaps.LuggPolygonView
|
|
6
|
+
import com.luggmaps.LuggPolylineView
|
|
7
|
+
|
|
8
|
+
data class EdgeInsets(val top: Int = 0, val left: Int = 0, val bottom: Int = 0, val right: Int = 0)
|
|
9
|
+
|
|
10
|
+
interface MapProviderDelegate {
|
|
11
|
+
fun mapProviderDidReady()
|
|
12
|
+
fun mapProviderDidMoveCamera(latitude: Double, longitude: Double, zoom: Float, gesture: Boolean)
|
|
13
|
+
fun mapProviderDidIdleCamera(latitude: Double, longitude: Double, zoom: Float, gesture: Boolean)
|
|
14
|
+
fun mapProviderDidPress(latitude: Double, longitude: Double, x: Float, y: Float)
|
|
15
|
+
fun mapProviderDidLongPress(latitude: Double, longitude: Double, x: Float, y: Float)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface MapProvider {
|
|
19
|
+
var delegate: MapProviderDelegate?
|
|
20
|
+
val isMapReady: Boolean
|
|
21
|
+
|
|
22
|
+
fun initializeMap(wrapperView: View, latitude: Double, longitude: Double, zoom: Float)
|
|
23
|
+
fun destroy()
|
|
24
|
+
|
|
25
|
+
// Props
|
|
26
|
+
fun setZoomEnabled(enabled: Boolean)
|
|
27
|
+
fun setScrollEnabled(enabled: Boolean)
|
|
28
|
+
fun setRotateEnabled(enabled: Boolean)
|
|
29
|
+
fun setPitchEnabled(enabled: Boolean)
|
|
30
|
+
fun setUserLocationEnabled(enabled: Boolean)
|
|
31
|
+
fun setUserLocationButtonEnabled(enabled: Boolean)
|
|
32
|
+
fun setTheme(value: String)
|
|
33
|
+
fun setMinZoom(zoom: Double)
|
|
34
|
+
fun setMaxZoom(zoom: Double)
|
|
35
|
+
fun setEdgeInsets(edgeInsets: EdgeInsets)
|
|
36
|
+
fun setEdgeInsets(edgeInsets: EdgeInsets, duration: Int)
|
|
37
|
+
|
|
38
|
+
// Children
|
|
39
|
+
fun addMarkerView(markerView: LuggMarkerView)
|
|
40
|
+
fun removeMarkerView(markerView: LuggMarkerView)
|
|
41
|
+
fun addPolylineView(polylineView: LuggPolylineView)
|
|
42
|
+
fun removePolylineView(polylineView: LuggPolylineView)
|
|
43
|
+
fun addPolygonView(polygonView: LuggPolygonView)
|
|
44
|
+
fun removePolygonView(polygonView: LuggPolygonView)
|
|
45
|
+
|
|
46
|
+
// Lifecycle
|
|
47
|
+
fun pauseAnimations()
|
|
48
|
+
fun resumeAnimations()
|
|
49
|
+
|
|
50
|
+
// Commands
|
|
51
|
+
fun moveCamera(latitude: Double, longitude: Double, zoom: Double, duration: Int)
|
|
52
|
+
fun fitCoordinates(
|
|
53
|
+
coordinates: List<Any>,
|
|
54
|
+
edgeInsetsTop: Int,
|
|
55
|
+
edgeInsetsLeft: Int,
|
|
56
|
+
edgeInsetsBottom: Int,
|
|
57
|
+
edgeInsetsRight: Int,
|
|
58
|
+
duration: Int
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -8,10 +8,15 @@ import com.google.android.gms.maps.model.LatLng
|
|
|
8
8
|
import com.google.android.gms.maps.model.Polyline
|
|
9
9
|
import com.google.android.gms.maps.model.StrokeStyle
|
|
10
10
|
import com.google.android.gms.maps.model.StyleSpan
|
|
11
|
+
import com.luggmaps.AnimatedOptions
|
|
11
12
|
import kotlin.math.floor
|
|
12
13
|
import kotlin.math.min
|
|
13
14
|
|
|
14
15
|
class PolylineAnimator {
|
|
16
|
+
companion object {
|
|
17
|
+
private const val MAX_ANIMATION_SPANS = 16
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
var polyline: Polyline? = null
|
|
16
21
|
var coordinates: List<LatLng> = emptyList()
|
|
17
22
|
set(value) {
|
|
@@ -22,6 +27,14 @@ class PolylineAnimator {
|
|
|
22
27
|
}
|
|
23
28
|
var strokeColors: List<Int> = listOf(Color.BLACK)
|
|
24
29
|
var strokeWidth: Float = 1f
|
|
30
|
+
var animatedOptions: AnimatedOptions = AnimatedOptions()
|
|
31
|
+
set(value) {
|
|
32
|
+
if (field == value) return
|
|
33
|
+
field = value
|
|
34
|
+
if (animated) {
|
|
35
|
+
restartAnimation()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
|
|
26
39
|
var animated: Boolean = false
|
|
27
40
|
set(value) {
|
|
@@ -40,6 +53,23 @@ class PolylineAnimator {
|
|
|
40
53
|
private var cumulativeDistances: FloatArray = floatArrayOf()
|
|
41
54
|
private var totalLength: Float = 0f
|
|
42
55
|
|
|
56
|
+
// Reusable collections to avoid per-frame allocations
|
|
57
|
+
private val reusablePoints = ArrayList<LatLng>()
|
|
58
|
+
private val reusableSpans = ArrayList<StyleSpan>()
|
|
59
|
+
|
|
60
|
+
private fun restartAnimation() {
|
|
61
|
+
stopAnimation()
|
|
62
|
+
startAnimation()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun applyEasing(t: Float): Float =
|
|
66
|
+
when (animatedOptions.easing) {
|
|
67
|
+
"easeIn" -> t * t
|
|
68
|
+
"easeOut" -> t * (2 - t)
|
|
69
|
+
"easeInOut" -> if (t < 0.5f) 2 * t * t else -1 + (4 - 2 * t) * t
|
|
70
|
+
else -> t
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
fun update() {
|
|
44
74
|
if (animated) return
|
|
45
75
|
|
|
@@ -60,8 +90,12 @@ class PolylineAnimator {
|
|
|
60
90
|
|
|
61
91
|
computeCumulativeDistances()
|
|
62
92
|
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
val trailLength = animatedOptions.trailLength.coerceIn(0.01f, 1f)
|
|
94
|
+
val maxProgress = if (trailLength < 1f) 1f else 2.15f
|
|
95
|
+
|
|
96
|
+
animator = ValueAnimator.ofFloat(0f, maxProgress).apply {
|
|
97
|
+
duration = (animatedOptions.duration * maxProgress).toLong()
|
|
98
|
+
startDelay = animatedOptions.delay
|
|
65
99
|
repeatCount = ValueAnimator.INFINITE
|
|
66
100
|
interpolator = LinearInterpolator()
|
|
67
101
|
addUpdateListener { animation ->
|
|
@@ -97,12 +131,19 @@ class PolylineAnimator {
|
|
|
97
131
|
}
|
|
98
132
|
|
|
99
133
|
private fun indexForDistance(distance: Float): Int {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
var left = 0
|
|
135
|
+
var right = cumulativeDistances.size - 1
|
|
136
|
+
|
|
137
|
+
while (left < right) {
|
|
138
|
+
val mid = (left + right + 1) / 2
|
|
139
|
+
if (cumulativeDistances[mid] <= distance) {
|
|
140
|
+
left = mid
|
|
141
|
+
} else {
|
|
142
|
+
right = mid - 1
|
|
103
143
|
}
|
|
104
144
|
}
|
|
105
|
-
|
|
145
|
+
|
|
146
|
+
return left.coerceAtMost(cumulativeDistances.size - 2).coerceAtLeast(0)
|
|
106
147
|
}
|
|
107
148
|
|
|
108
149
|
private fun coordinateAtDistance(distance: Float): LatLng {
|
|
@@ -118,6 +159,9 @@ class PolylineAnimator {
|
|
|
118
159
|
val c1 = coordinates[idx]
|
|
119
160
|
val c2 = coordinates[idx + 1]
|
|
120
161
|
|
|
162
|
+
// Reuse existing coordinate if no interpolation needed
|
|
163
|
+
if (t == 0f) return c1
|
|
164
|
+
|
|
121
165
|
return LatLng(
|
|
122
166
|
c1.latitude + (c2.latitude - c1.latitude) * t,
|
|
123
167
|
c1.longitude + (c2.longitude - c1.longitude) * t
|
|
@@ -129,6 +173,14 @@ class PolylineAnimator {
|
|
|
129
173
|
animator = null
|
|
130
174
|
}
|
|
131
175
|
|
|
176
|
+
fun pause() {
|
|
177
|
+
animator?.pause()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
fun resume() {
|
|
181
|
+
animator?.resume()
|
|
182
|
+
}
|
|
183
|
+
|
|
132
184
|
private fun updateAnimatedPolyline() {
|
|
133
185
|
val poly = polyline ?: return
|
|
134
186
|
if (coordinates.size < 2 || totalLength <= 0f) {
|
|
@@ -136,12 +188,18 @@ class PolylineAnimator {
|
|
|
136
188
|
return
|
|
137
189
|
}
|
|
138
190
|
|
|
139
|
-
val
|
|
191
|
+
val trailLength = animatedOptions.trailLength.coerceIn(0.01f, 1f)
|
|
192
|
+
val maxProgress = if (trailLength < 1f) 1f else 2f
|
|
193
|
+
val rawProgress = min(animationProgress, maxProgress)
|
|
194
|
+
val progress = applyEasing(rawProgress / maxProgress) * maxProgress
|
|
140
195
|
|
|
141
196
|
val headDist: Float
|
|
142
197
|
val tailDist: Float
|
|
143
198
|
|
|
144
|
-
if (
|
|
199
|
+
if (trailLength < 1f) {
|
|
200
|
+
headDist = progress * totalLength
|
|
201
|
+
tailDist = maxOf(0f, headDist - totalLength * trailLength)
|
|
202
|
+
} else if (progress <= 1f) {
|
|
145
203
|
tailDist = 0f
|
|
146
204
|
headDist = progress * totalLength
|
|
147
205
|
} else {
|
|
@@ -151,8 +209,8 @@ class PolylineAnimator {
|
|
|
151
209
|
}
|
|
152
210
|
|
|
153
211
|
if (headDist <= tailDist) {
|
|
154
|
-
poly.setSpans(emptyList())
|
|
155
212
|
poly.points = listOf(coordinates.firstOrNull() ?: LatLng(0.0, 0.0))
|
|
213
|
+
poly.color = strokeColors.firstOrNull() ?: Color.BLACK
|
|
156
214
|
return
|
|
157
215
|
}
|
|
158
216
|
|
|
@@ -160,31 +218,38 @@ class PolylineAnimator {
|
|
|
160
218
|
val startIndex = indexForDistance(tailDist)
|
|
161
219
|
val endIndex = indexForDistance(headDist)
|
|
162
220
|
|
|
163
|
-
|
|
164
|
-
val spans = mutableListOf<StyleSpan>()
|
|
221
|
+
reusablePoints.clear()
|
|
165
222
|
|
|
166
|
-
|
|
223
|
+
reusablePoints.add(coordinateAtDistance(tailDist))
|
|
167
224
|
|
|
168
225
|
for (i in (startIndex + 1)..endIndex) {
|
|
169
|
-
|
|
226
|
+
reusablePoints.add(coordinates[i])
|
|
170
227
|
}
|
|
171
228
|
|
|
172
229
|
val endCoord = coordinateAtDistance(headDist)
|
|
173
|
-
val lastAdded =
|
|
230
|
+
val lastAdded = reusablePoints.lastOrNull()
|
|
174
231
|
if (lastAdded == null || endCoord.latitude != lastAdded.latitude || endCoord.longitude != lastAdded.longitude) {
|
|
175
|
-
|
|
232
|
+
reusablePoints.add(endCoord)
|
|
176
233
|
}
|
|
177
234
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
val color = colorAtGradientPosition(gradientPos)
|
|
182
|
-
spans.add(StyleSpan(StrokeStyle.colorBuilder(color).build()))
|
|
183
|
-
}
|
|
235
|
+
if (reusablePoints.size < 2) return
|
|
236
|
+
|
|
237
|
+
poly.points = ArrayList(reusablePoints)
|
|
184
238
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
239
|
+
if (strokeColors.size <= 1) {
|
|
240
|
+
poly.color = strokeColors.firstOrNull() ?: Color.BLACK
|
|
241
|
+
} else {
|
|
242
|
+
val segmentCount = reusablePoints.size - 1
|
|
243
|
+
val spanCount = min(segmentCount, MAX_ANIMATION_SPANS)
|
|
244
|
+
val segmentsPerSpan = segmentCount.toDouble() / spanCount
|
|
245
|
+
|
|
246
|
+
reusableSpans.clear()
|
|
247
|
+
for (i in 0 until spanCount) {
|
|
248
|
+
val gradientPos = (i + 0.5f) / spanCount
|
|
249
|
+
val color = colorAtGradientPosition(gradientPos)
|
|
250
|
+
reusableSpans.add(StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan))
|
|
251
|
+
}
|
|
252
|
+
poly.setSpans(reusableSpans)
|
|
188
253
|
}
|
|
189
254
|
}
|
|
190
255
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.luggmaps.events
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
class LongPressEvent(view: View, private val latitude: Double, private val longitude: Double, private val x: Float, private val y: Float) :
|
|
9
|
+
Event<LongPressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
10
|
+
override fun getEventName() = "topMapLongPress"
|
|
11
|
+
|
|
12
|
+
override fun getEventData() =
|
|
13
|
+
Arguments.createMap().apply {
|
|
14
|
+
putMap(
|
|
15
|
+
"coordinate",
|
|
16
|
+
Arguments.createMap().apply {
|
|
17
|
+
putDouble("latitude", latitude)
|
|
18
|
+
putDouble("longitude", longitude)
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
putMap(
|
|
22
|
+
"point",
|
|
23
|
+
Arguments.createMap().apply {
|
|
24
|
+
putDouble("x", x.toDouble())
|
|
25
|
+
putDouble("y", y.toDouble())
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.luggmaps.events
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
class MarkerDragEvent(
|
|
9
|
+
view: View,
|
|
10
|
+
private val eventType: String,
|
|
11
|
+
private val latitude: Double,
|
|
12
|
+
private val longitude: Double,
|
|
13
|
+
private val x: Float,
|
|
14
|
+
private val y: Float
|
|
15
|
+
) : Event<MarkerDragEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
16
|
+
override fun getEventName() = eventType
|
|
17
|
+
|
|
18
|
+
override fun getEventData() =
|
|
19
|
+
Arguments.createMap().apply {
|
|
20
|
+
putMap(
|
|
21
|
+
"coordinate",
|
|
22
|
+
Arguments.createMap().apply {
|
|
23
|
+
putDouble("latitude", latitude)
|
|
24
|
+
putDouble("longitude", longitude)
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
putMap(
|
|
28
|
+
"point",
|
|
29
|
+
Arguments.createMap().apply {
|
|
30
|
+
putDouble("x", x.toDouble())
|
|
31
|
+
putDouble("y", y.toDouble())
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
companion object {
|
|
37
|
+
const val DRAG_START = "topMarkerDragStart"
|
|
38
|
+
const val DRAG_CHANGE = "topMarkerDragChange"
|
|
39
|
+
const val DRAG_END = "topMarkerDragEnd"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.luggmaps.events
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
class MarkerPressEvent(
|
|
9
|
+
view: View,
|
|
10
|
+
private val latitude: Double,
|
|
11
|
+
private val longitude: Double,
|
|
12
|
+
private val x: Float,
|
|
13
|
+
private val y: Float
|
|
14
|
+
) : Event<MarkerPressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
15
|
+
override fun getEventName() = "topMarkerPress"
|
|
16
|
+
|
|
17
|
+
override fun getEventData() =
|
|
18
|
+
Arguments.createMap().apply {
|
|
19
|
+
putMap(
|
|
20
|
+
"coordinate",
|
|
21
|
+
Arguments.createMap().apply {
|
|
22
|
+
putDouble("latitude", latitude)
|
|
23
|
+
putDouble("longitude", longitude)
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
putMap(
|
|
27
|
+
"point",
|
|
28
|
+
Arguments.createMap().apply {
|
|
29
|
+
putDouble("x", x.toDouble())
|
|
30
|
+
putDouble("y", y.toDouble())
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.luggmaps.events
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
class PolygonPressEvent(view: View) : Event<PolygonPressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
9
|
+
override fun getEventName() = "topPolygonPress"
|
|
10
|
+
|
|
11
|
+
override fun getEventData() = Arguments.createMap()
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.luggmaps.events
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
class PressEvent(view: View, private val latitude: Double, private val longitude: Double, private val x: Float, private val y: Float) :
|
|
9
|
+
Event<PressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
10
|
+
override fun getEventName() = "topMapPress"
|
|
11
|
+
|
|
12
|
+
override fun getEventData() =
|
|
13
|
+
Arguments.createMap().apply {
|
|
14
|
+
putMap(
|
|
15
|
+
"coordinate",
|
|
16
|
+
Arguments.createMap().apply {
|
|
17
|
+
putDouble("latitude", latitude)
|
|
18
|
+
putDouble("longitude", longitude)
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
putMap(
|
|
22
|
+
"point",
|
|
23
|
+
Arguments.createMap().apply {
|
|
24
|
+
putDouble("x", x.toDouble())
|
|
25
|
+
putDouble("y", y.toDouble())
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}
|