@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.10
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 +17 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +111 -36
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +66 -39
- package/android/src/main/java/com/luggmaps/{LuggMapsWrapperView.kt → LuggMapWrapperView.kt} +1 -1
- package/android/src/main/java/com/luggmaps/LuggMapWrapperViewManager.kt +25 -0
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerView.kt → LuggMarkerView.kt} +13 -7
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +23 -17
- package/android/src/main/java/com/luggmaps/{LuggMapsPackage.kt → LuggPackage.kt} +2 -2
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineView.kt → LuggPolylineView.kt} +11 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +22 -16
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -43
- package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +10 -2
- package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +6 -5
- package/android/src/main/java/com/luggmaps/events/ReadyEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +14 -0
- package/ios/{LuggMapsAppleMapView.h → LuggAppleMapView.h} +2 -2
- package/ios/{LuggMapsAppleMapView.mm → LuggAppleMapView.mm} +140 -71
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +82 -64
- package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
- package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
- package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +8 -6
- package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +21 -8
- package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +6 -5
- package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +14 -9
- package/ios/core/GMSPolylineAnimator.m +85 -36
- package/ios/core/MKPolylineAnimator.m +63 -32
- package/ios/events/CameraIdleEvent.h +6 -1
- package/ios/events/CameraMoveEvent.h +6 -3
- package/ios/events/ReadyEvent.h +20 -0
- package/lib/module/MapProvider.js +13 -0
- package/lib/module/MapProvider.js.map +1 -0
- package/lib/module/MapProvider.types.js +4 -0
- package/lib/module/MapProvider.types.js.map +1 -0
- package/lib/module/MapProvider.web.js +14 -0
- package/lib/module/MapProvider.web.js.map +1 -0
- package/lib/module/MapView.js +21 -7
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +266 -0
- package/lib/module/MapView.web.js.map +1 -0
- package/lib/module/{Marker.js → components/Marker.js} +6 -3
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/components/Marker.web.js +34 -0
- package/lib/module/components/Marker.web.js.map +1 -0
- package/lib/module/{Polyline.js → components/Polyline.js} +7 -4
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/Polyline.web.js +177 -0
- package/lib/module/components/Polyline.web.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/index.web.js +5 -0
- package/lib/module/components/index.web.js.map +1 -0
- package/{src/fabric/LuggMapsAppleMapViewNativeComponent.ts → lib/module/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
- package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
- package/{src/fabric/LuggMapsWrapperViewNativeComponent.ts → lib/module/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/lib/module/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{src/fabric/LuggMapsPolylineViewNativeComponent.ts → lib/module/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +6 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsAndroid.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts +6 -0
- package/lib/typescript/plugin/src/withLuggMapsIOS.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.d.ts +8 -0
- package/lib/typescript/src/MapProvider.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.types.d.ts +16 -0
- package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.web.d.ts +3 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +24 -14
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +12 -0
- package/lib/typescript/src/MapView.web.d.ts.map +1 -0
- package/lib/typescript/src/{Marker.types.d.ts → components/Marker.d.ts} +10 -5
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/{Marker.d.ts → components/Marker.web.d.ts} +2 -2
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
- package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +10 -5
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +6 -0
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/index.web.d.ts +5 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsAppleMapViewNativeComponent.d.ts → LuggAppleMapViewNativeComponent.d.ts} +10 -3
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +10 -3
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsWrapperViewNativeComponent.d.ts → LuggMapWrapperViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMapWrapperViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsMarkerViewNativeComponent.d.ts → LuggMarkerViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsPolylineViewNativeComponent.d.ts → LuggPolylineViewNativeComponent.d.ts} +1 -1
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +7 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/package.json +20 -7
- package/plugin/build/index.js +4 -4
- package/{lib/typescript/plugin/src/withMapsAndroid.d.ts → plugin/build/withLuggMapsAndroid.d.ts} +0 -1
- package/plugin/build/withLuggMapsAndroid.js +15 -0
- package/{lib/typescript/plugin/src/withMapsIOS.d.ts → plugin/build/withLuggMapsIOS.d.ts} +0 -1
- package/plugin/build/withLuggMapsIOS.js +27 -0
- package/plugin/build/withMapsAndroid.d.ts +1 -1
- package/plugin/build/withMapsIOS.d.ts +1 -1
- package/src/MapProvider.tsx +10 -0
- package/src/MapProvider.types.ts +16 -0
- package/src/MapProvider.web.tsx +6 -0
- package/src/MapView.tsx +27 -10
- package/src/MapView.types.ts +24 -15
- package/src/MapView.web.tsx +319 -0
- package/src/components/Marker.tsx +63 -0
- package/src/components/Marker.web.tsx +32 -0
- package/src/components/Polyline.tsx +57 -0
- package/src/components/Polyline.web.tsx +222 -0
- package/src/components/index.ts +2 -0
- package/src/components/index.web.ts +4 -0
- package/{lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts → src/fabric/LuggAppleMapViewNativeComponent.ts} +13 -3
- package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +13 -3
- package/{lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts → src/fabric/LuggMapWrapperViewNativeComponent.ts} +1 -1
- package/src/fabric/{LuggMapsMarkerViewNativeComponent.ts → LuggMarkerViewNativeComponent.ts} +1 -1
- package/{lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts → src/fabric/LuggPolylineViewNativeComponent.ts} +1 -1
- package/src/index.ts +11 -7
- package/src/index.web.ts +17 -0
- package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +0 -25
- package/lib/module/Marker.js.map +0 -1
- package/lib/module/Marker.types.js +0 -4
- package/lib/module/Marker.types.js.map +0 -1
- package/lib/module/Polyline.js.map +0 -1
- package/lib/module/Polyline.types.js +0 -4
- package/lib/module/Polyline.types.js.map +0 -1
- package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +0 -1
- package/lib/typescript/src/Marker.d.ts.map +0 -1
- package/lib/typescript/src/Marker.types.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.d.ts +0 -6
- package/lib/typescript/src/Polyline.d.ts.map +0 -1
- package/lib/typescript/src/Polyline.types.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +0 -1
- package/src/Marker.tsx +0 -31
- package/src/Marker.types.ts +0 -32
- package/src/Polyline.tsx +0 -32
- package/src/Polyline.types.ts +0 -24
package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt}
RENAMED
|
@@ -7,31 +7,31 @@ import com.facebook.react.uimanager.ThemedReactContext
|
|
|
7
7
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
8
8
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
9
9
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
|
-
import com.facebook.react.viewmanagers.
|
|
11
|
-
import com.facebook.react.viewmanagers.
|
|
10
|
+
import com.facebook.react.viewmanagers.LuggMarkerViewManagerDelegate
|
|
11
|
+
import com.facebook.react.viewmanagers.LuggMarkerViewManagerInterface
|
|
12
12
|
|
|
13
|
-
@ReactModule(name =
|
|
14
|
-
class
|
|
15
|
-
ViewGroupManager<
|
|
16
|
-
|
|
17
|
-
private val delegate: ViewManagerDelegate<
|
|
13
|
+
@ReactModule(name = LuggMarkerViewManager.NAME)
|
|
14
|
+
class LuggMarkerViewManager :
|
|
15
|
+
ViewGroupManager<LuggMarkerView>(),
|
|
16
|
+
LuggMarkerViewManagerInterface<LuggMarkerView> {
|
|
17
|
+
private val delegate: ViewManagerDelegate<LuggMarkerView> = LuggMarkerViewManagerDelegate(this)
|
|
18
18
|
|
|
19
|
-
override fun getDelegate(): ViewManagerDelegate<
|
|
19
|
+
override fun getDelegate(): ViewManagerDelegate<LuggMarkerView> = delegate
|
|
20
20
|
override fun getName(): String = NAME
|
|
21
|
-
override fun createViewInstance(context: ThemedReactContext):
|
|
21
|
+
override fun createViewInstance(context: ThemedReactContext): LuggMarkerView = LuggMarkerView(context)
|
|
22
22
|
|
|
23
|
-
override fun onDropViewInstance(view:
|
|
23
|
+
override fun onDropViewInstance(view: LuggMarkerView) {
|
|
24
24
|
super.onDropViewInstance(view)
|
|
25
25
|
view.onDropViewInstance()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
override fun onAfterUpdateTransaction(view:
|
|
28
|
+
override fun onAfterUpdateTransaction(view: LuggMarkerView) {
|
|
29
29
|
super.onAfterUpdateTransaction(view)
|
|
30
30
|
view.onAfterUpdateTransaction()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
@ReactProp(name = "coordinate")
|
|
34
|
-
override fun setCoordinate(view:
|
|
34
|
+
override fun setCoordinate(view: LuggMarkerView, value: ReadableMap?) {
|
|
35
35
|
value?.let {
|
|
36
36
|
val latitude = if (it.hasKey("latitude")) it.getDouble("latitude") else 0.0
|
|
37
37
|
val longitude = if (it.hasKey("longitude")) it.getDouble("longitude") else 0.0
|
|
@@ -40,22 +40,22 @@ class LuggMapsMarkerViewManager :
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@ReactProp(name = "name")
|
|
43
|
-
override fun setName(view:
|
|
43
|
+
override fun setName(view: LuggMarkerView, value: String?) {
|
|
44
44
|
view.setName(value)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@ReactProp(name = "title")
|
|
48
|
-
override fun setTitle(view:
|
|
48
|
+
override fun setTitle(view: LuggMarkerView, value: String?) {
|
|
49
49
|
view.setTitle(value)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@ReactProp(name = "description")
|
|
53
|
-
override fun setDescription(view:
|
|
53
|
+
override fun setDescription(view: LuggMarkerView, value: String?) {
|
|
54
54
|
view.setDescription(value)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@ReactProp(name = "anchor")
|
|
58
|
-
override fun setAnchor(view:
|
|
58
|
+
override fun setAnchor(view: LuggMarkerView, value: ReadableMap?) {
|
|
59
59
|
value?.let {
|
|
60
60
|
val x = if (it.hasKey("x")) it.getDouble("x") else 0.5
|
|
61
61
|
val y = if (it.hasKey("y")) it.getDouble("y") else 1.0
|
|
@@ -63,7 +63,13 @@ class LuggMapsMarkerViewManager :
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
@ReactProp(name = "zIndex", defaultFloat = 0f)
|
|
67
|
+
override fun setZIndex(view: LuggMarkerView, zIndex: Float) {
|
|
68
|
+
super.setZIndex(view, zIndex)
|
|
69
|
+
view.setZIndex(zIndex)
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
companion object {
|
|
67
|
-
const val NAME = "
|
|
73
|
+
const val NAME = "LuggMarkerView"
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -5,9 +5,9 @@ import com.facebook.react.bridge.NativeModule
|
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.uimanager.ViewManager
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class LuggPackage : ReactPackage {
|
|
9
9
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
|
10
|
-
listOf(
|
|
10
|
+
listOf(LuggGoogleMapViewManager(), LuggMarkerViewManager(), LuggMapWrapperViewManager(), LuggPolylineViewManager())
|
|
11
11
|
|
|
12
12
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> = emptyList()
|
|
13
13
|
}
|
|
@@ -8,11 +8,11 @@ import com.google.android.gms.maps.model.Polyline
|
|
|
8
8
|
import com.google.android.gms.maps.model.StrokeStyle
|
|
9
9
|
import com.google.android.gms.maps.model.StyleSpan
|
|
10
10
|
|
|
11
|
-
interface
|
|
12
|
-
fun polylineViewDidUpdate(polylineView:
|
|
11
|
+
interface LuggPolylineViewDelegate {
|
|
12
|
+
fun polylineViewDidUpdate(polylineView: LuggPolylineView)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
16
16
|
var coordinates: List<LatLng> = emptyList()
|
|
17
17
|
private set
|
|
18
18
|
|
|
@@ -25,10 +25,13 @@ class LuggMapsPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
25
25
|
var animated: Boolean = false
|
|
26
26
|
private set
|
|
27
27
|
|
|
28
|
+
var zIndex: Float = 0f
|
|
29
|
+
private set
|
|
30
|
+
|
|
28
31
|
var cachedSpans: List<StyleSpan>? = null
|
|
29
32
|
private set
|
|
30
33
|
|
|
31
|
-
var delegate:
|
|
34
|
+
var delegate: LuggPolylineViewDelegate? = null
|
|
32
35
|
var polyline: Polyline? = null
|
|
33
36
|
|
|
34
37
|
init {
|
|
@@ -55,6 +58,10 @@ class LuggMapsPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
55
58
|
animated = value
|
|
56
59
|
}
|
|
57
60
|
|
|
61
|
+
fun setZIndex(value: Float) {
|
|
62
|
+
zIndex = value
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
fun getOrCreateSpans(): List<StyleSpan> {
|
|
59
66
|
cachedSpans?.let { return it }
|
|
60
67
|
|
|
@@ -6,32 +6,32 @@ import com.facebook.react.uimanager.ThemedReactContext
|
|
|
6
6
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
7
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
8
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
-
import com.facebook.react.viewmanagers.
|
|
10
|
-
import com.facebook.react.viewmanagers.
|
|
9
|
+
import com.facebook.react.viewmanagers.LuggPolylineViewManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.LuggPolylineViewManagerInterface
|
|
11
11
|
import com.google.android.gms.maps.model.LatLng
|
|
12
12
|
|
|
13
|
-
@ReactModule(name =
|
|
14
|
-
class
|
|
15
|
-
ViewGroupManager<
|
|
16
|
-
|
|
17
|
-
private val delegate: ViewManagerDelegate<
|
|
13
|
+
@ReactModule(name = LuggPolylineViewManager.NAME)
|
|
14
|
+
class LuggPolylineViewManager :
|
|
15
|
+
ViewGroupManager<LuggPolylineView>(),
|
|
16
|
+
LuggPolylineViewManagerInterface<LuggPolylineView> {
|
|
17
|
+
private val delegate: ViewManagerDelegate<LuggPolylineView> = LuggPolylineViewManagerDelegate(this)
|
|
18
18
|
|
|
19
|
-
override fun getDelegate(): ViewManagerDelegate<
|
|
19
|
+
override fun getDelegate(): ViewManagerDelegate<LuggPolylineView> = delegate
|
|
20
20
|
override fun getName(): String = NAME
|
|
21
|
-
override fun createViewInstance(context: ThemedReactContext):
|
|
21
|
+
override fun createViewInstance(context: ThemedReactContext): LuggPolylineView = LuggPolylineView(context)
|
|
22
22
|
|
|
23
|
-
override fun onDropViewInstance(view:
|
|
23
|
+
override fun onDropViewInstance(view: LuggPolylineView) {
|
|
24
24
|
super.onDropViewInstance(view)
|
|
25
25
|
view.onDropViewInstance()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
override fun onAfterUpdateTransaction(view:
|
|
28
|
+
override fun onAfterUpdateTransaction(view: LuggPolylineView) {
|
|
29
29
|
super.onAfterUpdateTransaction(view)
|
|
30
30
|
view.onAfterUpdateTransaction()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
@ReactProp(name = "coordinates")
|
|
34
|
-
override fun setCoordinates(view:
|
|
34
|
+
override fun setCoordinates(view: LuggPolylineView, value: ReadableArray?) {
|
|
35
35
|
value?.let { array ->
|
|
36
36
|
val coords = mutableListOf<LatLng>()
|
|
37
37
|
for (i in 0 until array.size()) {
|
|
@@ -45,7 +45,7 @@ class LuggMapsPolylineViewManager :
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@ReactProp(name = "strokeColors")
|
|
48
|
-
override fun setStrokeColors(view:
|
|
48
|
+
override fun setStrokeColors(view: LuggPolylineView, value: ReadableArray?) {
|
|
49
49
|
val colors = mutableListOf<Int>()
|
|
50
50
|
value?.let { array ->
|
|
51
51
|
for (i in 0 until array.size()) {
|
|
@@ -56,16 +56,22 @@ class LuggMapsPolylineViewManager :
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
@ReactProp(name = "strokeWidth", defaultDouble = 1.0)
|
|
59
|
-
override fun setStrokeWidth(view:
|
|
59
|
+
override fun setStrokeWidth(view: LuggPolylineView, value: Double) {
|
|
60
60
|
view.setStrokeWidth(value.toFloat())
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
@ReactProp(name = "animated", defaultBoolean = false)
|
|
64
|
-
override fun setAnimated(view:
|
|
64
|
+
override fun setAnimated(view: LuggPolylineView, value: Boolean) {
|
|
65
65
|
view.setAnimated(value)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
@ReactProp(name = "zIndex", defaultFloat = 0f)
|
|
69
|
+
override fun setZIndex(view: LuggPolylineView, value: Float) {
|
|
70
|
+
super.setZIndex(view, value)
|
|
71
|
+
view.setZIndex(value)
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
companion object {
|
|
69
|
-
const val NAME = "
|
|
75
|
+
const val NAME = "LuggPolylineView"
|
|
70
76
|
}
|
|
71
77
|
}
|
|
@@ -2,18 +2,24 @@ package com.luggmaps.core
|
|
|
2
2
|
|
|
3
3
|
import android.animation.ValueAnimator
|
|
4
4
|
import android.graphics.Color
|
|
5
|
+
import android.location.Location
|
|
5
6
|
import android.view.animation.LinearInterpolator
|
|
6
7
|
import com.google.android.gms.maps.model.LatLng
|
|
7
8
|
import com.google.android.gms.maps.model.Polyline
|
|
8
9
|
import com.google.android.gms.maps.model.StrokeStyle
|
|
9
10
|
import com.google.android.gms.maps.model.StyleSpan
|
|
10
11
|
import kotlin.math.floor
|
|
11
|
-
import kotlin.math.max
|
|
12
12
|
import kotlin.math.min
|
|
13
13
|
|
|
14
14
|
class PolylineAnimator {
|
|
15
15
|
var polyline: Polyline? = null
|
|
16
16
|
var coordinates: List<LatLng> = emptyList()
|
|
17
|
+
set(value) {
|
|
18
|
+
field = value
|
|
19
|
+
if (animated && animator != null) {
|
|
20
|
+
computeCumulativeDistances()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
17
23
|
var strokeColors: List<Int> = listOf(Color.BLACK)
|
|
18
24
|
var strokeWidth: Float = 1f
|
|
19
25
|
|
|
@@ -31,6 +37,8 @@ class PolylineAnimator {
|
|
|
31
37
|
|
|
32
38
|
private var animator: ValueAnimator? = null
|
|
33
39
|
private var animationProgress: Float = 0f
|
|
40
|
+
private var cumulativeDistances: FloatArray = floatArrayOf()
|
|
41
|
+
private var totalLength: Float = 0f
|
|
34
42
|
|
|
35
43
|
fun update() {
|
|
36
44
|
if (animated) return
|
|
@@ -50,8 +58,10 @@ class PolylineAnimator {
|
|
|
50
58
|
private fun startAnimation() {
|
|
51
59
|
if (animator != null) return
|
|
52
60
|
|
|
61
|
+
computeCumulativeDistances()
|
|
62
|
+
|
|
53
63
|
animator = ValueAnimator.ofFloat(0f, 2.15f).apply {
|
|
54
|
-
duration =
|
|
64
|
+
duration = 2150
|
|
55
65
|
repeatCount = ValueAnimator.INFINITE
|
|
56
66
|
interpolator = LinearInterpolator()
|
|
57
67
|
addUpdateListener { animation ->
|
|
@@ -62,6 +72,58 @@ class PolylineAnimator {
|
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
|
|
75
|
+
private fun computeCumulativeDistances() {
|
|
76
|
+
if (coordinates.size < 2) {
|
|
77
|
+
cumulativeDistances = floatArrayOf(0f)
|
|
78
|
+
totalLength = 0f
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
val distances = FloatArray(coordinates.size)
|
|
83
|
+
distances[0] = 0f
|
|
84
|
+
var total = 0f
|
|
85
|
+
|
|
86
|
+
for (i in 1 until coordinates.size) {
|
|
87
|
+
val prev = coordinates[i - 1]
|
|
88
|
+
val curr = coordinates[i]
|
|
89
|
+
val results = FloatArray(1)
|
|
90
|
+
Location.distanceBetween(prev.latitude, prev.longitude, curr.latitude, curr.longitude, results)
|
|
91
|
+
total += results[0]
|
|
92
|
+
distances[i] = total
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
cumulativeDistances = distances
|
|
96
|
+
totalLength = total
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private fun indexForDistance(distance: Float): Int {
|
|
100
|
+
for (i in 1 until cumulativeDistances.size) {
|
|
101
|
+
if (cumulativeDistances[i] >= distance) {
|
|
102
|
+
return i - 1
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return (cumulativeDistances.size - 2).coerceAtLeast(0)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private fun coordinateAtDistance(distance: Float): LatLng {
|
|
109
|
+
if (distance <= 0f) return coordinates.first()
|
|
110
|
+
if (distance >= totalLength) return coordinates.last()
|
|
111
|
+
|
|
112
|
+
val idx = indexForDistance(distance)
|
|
113
|
+
val segStart = cumulativeDistances[idx]
|
|
114
|
+
val segEnd = cumulativeDistances[idx + 1]
|
|
115
|
+
val segLength = segEnd - segStart
|
|
116
|
+
|
|
117
|
+
val t = if (segLength > 0) (distance - segStart) / segLength else 0f
|
|
118
|
+
val c1 = coordinates[idx]
|
|
119
|
+
val c2 = coordinates[idx + 1]
|
|
120
|
+
|
|
121
|
+
return LatLng(
|
|
122
|
+
c1.latitude + (c2.latitude - c1.latitude) * t,
|
|
123
|
+
c1.longitude + (c2.longitude - c1.longitude) * t
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
65
127
|
private fun stopAnimation() {
|
|
66
128
|
animator?.cancel()
|
|
67
129
|
animator = null
|
|
@@ -69,71 +131,55 @@ class PolylineAnimator {
|
|
|
69
131
|
|
|
70
132
|
private fun updateAnimatedPolyline() {
|
|
71
133
|
val poly = polyline ?: return
|
|
72
|
-
if (coordinates.size < 2) {
|
|
134
|
+
if (coordinates.size < 2 || totalLength <= 0f) {
|
|
73
135
|
poly.points = coordinates
|
|
74
136
|
return
|
|
75
137
|
}
|
|
76
138
|
|
|
77
|
-
val segmentCount = coordinates.size - 1
|
|
78
139
|
val progress = min(animationProgress, 2f)
|
|
79
140
|
|
|
80
|
-
val
|
|
81
|
-
val
|
|
141
|
+
val headDist: Float
|
|
142
|
+
val tailDist: Float
|
|
82
143
|
|
|
83
144
|
if (progress <= 1f) {
|
|
84
|
-
|
|
85
|
-
|
|
145
|
+
tailDist = 0f
|
|
146
|
+
headDist = progress * totalLength
|
|
86
147
|
} else {
|
|
87
148
|
val shrinkProgress = progress - 1f
|
|
88
|
-
|
|
89
|
-
|
|
149
|
+
tailDist = shrinkProgress * totalLength
|
|
150
|
+
headDist = totalLength
|
|
90
151
|
}
|
|
91
152
|
|
|
92
|
-
if (
|
|
153
|
+
if (headDist <= tailDist) {
|
|
93
154
|
poly.setSpans(emptyList())
|
|
94
155
|
poly.points = listOf(coordinates.firstOrNull() ?: LatLng(0.0, 0.0))
|
|
95
156
|
return
|
|
96
157
|
}
|
|
97
158
|
|
|
98
|
-
val
|
|
99
|
-
val
|
|
100
|
-
val
|
|
159
|
+
val visibleLength = headDist - tailDist
|
|
160
|
+
val startIndex = indexForDistance(tailDist)
|
|
161
|
+
val endIndex = indexForDistance(headDist)
|
|
101
162
|
|
|
102
163
|
val points = mutableListOf<LatLng>()
|
|
103
164
|
val spans = mutableListOf<StyleSpan>()
|
|
104
165
|
|
|
105
|
-
|
|
106
|
-
var coord = coordinates[i]
|
|
107
|
-
|
|
108
|
-
// Interpolate tail
|
|
109
|
-
if (i == startIndex && tailPos > startIndex.toFloat() && i + 1 < coordinates.size) {
|
|
110
|
-
val t = tailPos - startIndex
|
|
111
|
-
val next = coordinates[i + 1]
|
|
112
|
-
coord = LatLng(
|
|
113
|
-
coord.latitude + (next.latitude - coord.latitude) * t,
|
|
114
|
-
coord.longitude + (next.longitude - coord.longitude) * t
|
|
115
|
-
)
|
|
116
|
-
}
|
|
166
|
+
points.add(coordinateAtDistance(tailDist))
|
|
117
167
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
val prev = coordinates[i - 1]
|
|
122
|
-
coord = LatLng(
|
|
123
|
-
prev.latitude + (coordinates[i].latitude - prev.latitude) * t,
|
|
124
|
-
prev.longitude + (coordinates[i].longitude - prev.longitude) * t
|
|
125
|
-
)
|
|
126
|
-
}
|
|
168
|
+
for (i in (startIndex + 1)..endIndex) {
|
|
169
|
+
points.add(coordinates[i])
|
|
170
|
+
}
|
|
127
171
|
|
|
128
|
-
|
|
172
|
+
val endCoord = coordinateAtDistance(headDist)
|
|
173
|
+
val lastAdded = points.lastOrNull()
|
|
174
|
+
if (lastAdded == null || endCoord.latitude != lastAdded.latitude || endCoord.longitude != lastAdded.longitude) {
|
|
175
|
+
points.add(endCoord)
|
|
176
|
+
}
|
|
129
177
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
spans.add(StyleSpan(StrokeStyle.colorBuilder(color).build()))
|
|
136
|
-
}
|
|
178
|
+
for (i in 0 until (points.size - 1)) {
|
|
179
|
+
val segMidDist = tailDist + visibleLength * (i + 0.5f) / (points.size - 1)
|
|
180
|
+
val gradientPos = (segMidDist - tailDist) / visibleLength
|
|
181
|
+
val color = colorAtGradientPosition(gradientPos)
|
|
182
|
+
spans.add(StyleSpan(StrokeStyle.colorBuilder(color).build()))
|
|
137
183
|
}
|
|
138
184
|
|
|
139
185
|
poly.points = points
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
package com.luggmaps.events
|
|
2
2
|
|
|
3
|
+
import android.view.View
|
|
3
4
|
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
4
6
|
import com.facebook.react.uimanager.events.Event
|
|
5
7
|
|
|
6
|
-
class CameraIdleEvent(
|
|
7
|
-
|
|
8
|
+
class CameraIdleEvent(
|
|
9
|
+
view: View,
|
|
10
|
+
private val latitude: Double,
|
|
11
|
+
private val longitude: Double,
|
|
12
|
+
private val zoom: Float,
|
|
13
|
+
private val gesture: Boolean
|
|
14
|
+
) : Event<CameraIdleEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
8
15
|
override fun getEventName() = "topCameraIdle"
|
|
9
16
|
|
|
10
17
|
override fun getEventData() =
|
|
@@ -17,5 +24,6 @@ class CameraIdleEvent(surfaceId: Int, viewId: Int, private val latitude: Double,
|
|
|
17
24
|
}
|
|
18
25
|
)
|
|
19
26
|
putDouble("zoom", zoom.toDouble())
|
|
27
|
+
putBoolean("gesture", gesture)
|
|
20
28
|
}
|
|
21
29
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
package com.luggmaps.events
|
|
2
2
|
|
|
3
|
+
import android.view.View
|
|
3
4
|
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
4
6
|
import com.facebook.react.uimanager.events.Event
|
|
5
7
|
|
|
6
8
|
class CameraMoveEvent(
|
|
7
|
-
|
|
8
|
-
viewId: Int,
|
|
9
|
+
view: View,
|
|
9
10
|
private val latitude: Double,
|
|
10
11
|
private val longitude: Double,
|
|
11
12
|
private val zoom: Float,
|
|
12
|
-
private val
|
|
13
|
-
) : Event<CameraMoveEvent>(
|
|
13
|
+
private val gesture: Boolean
|
|
14
|
+
) : Event<CameraMoveEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
14
15
|
override fun getEventName() = "topCameraMove"
|
|
15
16
|
|
|
16
17
|
override fun getEventData() =
|
|
@@ -23,6 +24,6 @@ class CameraMoveEvent(
|
|
|
23
24
|
}
|
|
24
25
|
)
|
|
25
26
|
putDouble("zoom", zoom.toDouble())
|
|
26
|
-
putBoolean("
|
|
27
|
+
putBoolean("gesture", gesture)
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -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 ReadyEvent(view: View) : Event<ReadyEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
|
|
9
|
+
override fun getEventName() = "topReady"
|
|
10
|
+
|
|
11
|
+
override fun getEventData() = Arguments.createMap()
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.luggmaps.extensions
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
6
|
+
import com.facebook.react.uimanager.events.Event
|
|
7
|
+
|
|
8
|
+
fun View.dispatchEvent(event: Event<*>) {
|
|
9
|
+
val eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(
|
|
10
|
+
context as ThemedReactContext,
|
|
11
|
+
id
|
|
12
|
+
)
|
|
13
|
+
eventDispatcher?.dispatchEvent(event)
|
|
14
|
+
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
6
|
|
|
7
|
-
@interface
|
|
7
|
+
@interface LuggAppleMapViewContent : MKMapView
|
|
8
8
|
@end
|
|
9
9
|
|
|
10
|
-
@interface
|
|
10
|
+
@interface LuggAppleMapView : RCTViewComponentView
|
|
11
11
|
|
|
12
12
|
- (MKMapView *)mapView;
|
|
13
13
|
|