@lugg/maps 0.2.0-alpha.0 → 0.2.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/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapView.kt → LuggGoogleMapView.kt} +107 -30
- 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} +6 -6
- package/android/src/main/java/com/luggmaps/{LuggMapsMarkerViewManager.kt → LuggMarkerViewManager.kt} +17 -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} +4 -4
- package/android/src/main/java/com/luggmaps/{LuggMapsPolylineViewManager.kt → LuggPolylineViewManager.kt} +16 -16
- 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} +104 -68
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +75 -60
- package/ios/{LuggMapsWrapperView.h → LuggMapWrapperView.h} +1 -1
- package/ios/{LuggMapsWrapperView.mm → LuggMapWrapperView.mm} +7 -7
- package/ios/{LuggMapsMarkerView.h → LuggMarkerView.h} +6 -6
- package/ios/{LuggMapsMarkerView.mm → LuggMarkerView.mm} +8 -8
- package/ios/{LuggMapsPolylineView.h → LuggPolylineView.h} +5 -5
- package/ios/{LuggMapsPolylineView.mm → LuggPolylineView.mm} +8 -8
- package/ios/events/CameraIdleEvent.h +6 -1
- package/ios/events/CameraMoveEvent.h +6 -3
- package/ios/events/ReadyEvent.h +20 -0
- package/lib/module/MapView.js +21 -7
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/{Marker.js → components/Marker.js} +2 -2
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/{Polyline.js → components/Polyline.js} +2 -2
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.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 +1 -2
- package/lib/module/index.js.map +1 -1
- 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/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/{Marker.types.d.ts → components/Marker.d.ts} +6 -5
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/{Polyline.types.d.ts → components/Polyline.d.ts} +6 -5
- package/lib/typescript/src/components/Polyline.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/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 +2 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +6 -6
- 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/MapView.tsx +27 -10
- package/src/MapView.types.ts +24 -15
- package/src/components/Marker.tsx +59 -0
- package/src/{Polyline.tsx → components/Polyline.tsx} +23 -3
- package/src/components/index.ts +2 -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 +3 -6
- 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 +0 -6
- 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.types.ts +0 -24
|
@@ -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
|
|
|
@@ -28,7 +28,7 @@ class LuggMapsPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
28
28
|
var cachedSpans: List<StyleSpan>? = null
|
|
29
29
|
private set
|
|
30
30
|
|
|
31
|
-
var delegate:
|
|
31
|
+
var delegate: LuggPolylineViewDelegate? = null
|
|
32
32
|
var polyline: Polyline? = null
|
|
33
33
|
|
|
34
34
|
init {
|
|
@@ -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,16 @@ 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
68
|
companion object {
|
|
69
|
-
const val NAME = "
|
|
69
|
+
const val NAME = "LuggPolylineView"
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -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
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#import "
|
|
2
|
-
#import "
|
|
3
|
-
#import "
|
|
4
|
-
#import "
|
|
1
|
+
#import "LuggAppleMapView.h"
|
|
2
|
+
#import "LuggMapWrapperView.h"
|
|
3
|
+
#import "LuggMarkerView.h"
|
|
4
|
+
#import "LuggPolylineView.h"
|
|
5
5
|
#import "core/MKPolylineAnimator.h"
|
|
6
6
|
#import "events/CameraIdleEvent.h"
|
|
7
7
|
#import "events/CameraMoveEvent.h"
|
|
8
|
+
#import "events/ReadyEvent.h"
|
|
8
9
|
#import "extensions/MKMapView+Zoom.h"
|
|
9
10
|
|
|
10
11
|
#import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
|
|
@@ -21,36 +22,39 @@ using namespace luggmaps::events;
|
|
|
21
22
|
@property(nonatomic, assign) CLLocationCoordinate2D coordinate;
|
|
22
23
|
@property(nonatomic, copy, nullable) NSString *title;
|
|
23
24
|
@property(nonatomic, copy, nullable) NSString *subtitle;
|
|
24
|
-
@property(nonatomic, strong)
|
|
25
|
+
@property(nonatomic, strong) LuggMarkerView *markerView;
|
|
25
26
|
@property(nonatomic, weak) MKAnnotationView *annotationView;
|
|
26
27
|
@end
|
|
27
28
|
|
|
28
29
|
@implementation AppleMarkerAnnotation
|
|
29
30
|
@end
|
|
30
31
|
|
|
31
|
-
@implementation
|
|
32
|
+
@implementation LuggAppleMapViewContent
|
|
32
33
|
@end
|
|
33
34
|
|
|
34
|
-
@interface
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
@interface LuggAppleMapView () <RCTLuggAppleMapViewViewProtocol,
|
|
36
|
+
MKMapViewDelegate, LuggMarkerViewDelegate,
|
|
37
|
+
LuggPolylineViewDelegate>
|
|
37
38
|
@end
|
|
38
39
|
|
|
39
|
-
@implementation
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
@implementation LuggAppleMapView {
|
|
41
|
+
LuggAppleMapViewContent *_mapView;
|
|
42
|
+
LuggMapWrapperView *_mapWrapperView;
|
|
43
|
+
BOOL _isMapReady;
|
|
42
44
|
BOOL _isDragging;
|
|
45
|
+
double _minZoom;
|
|
46
|
+
double _maxZoom;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
46
50
|
return concreteComponentDescriptorProvider<
|
|
47
|
-
|
|
51
|
+
LuggAppleMapViewComponentDescriptor>();
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
51
55
|
if (self = [super initWithFrame:frame]) {
|
|
52
56
|
static const auto defaultProps =
|
|
53
|
-
std::make_shared<const
|
|
57
|
+
std::make_shared<const LuggAppleMapViewProps>();
|
|
54
58
|
_props = defaultProps;
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -64,10 +68,10 @@ using namespace luggmaps::events;
|
|
|
64
68
|
index:(NSInteger)index {
|
|
65
69
|
[super mountChildComponentView:childComponentView index:index];
|
|
66
70
|
|
|
67
|
-
if ([childComponentView isKindOfClass:[
|
|
68
|
-
_mapWrapperView = (
|
|
69
|
-
} else if ([childComponentView isKindOfClass:[
|
|
70
|
-
|
|
71
|
+
if ([childComponentView isKindOfClass:[LuggMapWrapperView class]]) {
|
|
72
|
+
_mapWrapperView = (LuggMapWrapperView *)childComponentView;
|
|
73
|
+
} else if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
74
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
71
75
|
markerView.delegate = self;
|
|
72
76
|
|
|
73
77
|
AppleMarkerAnnotation *annotation = [[AppleMarkerAnnotation alloc] init];
|
|
@@ -79,9 +83,8 @@ using namespace luggmaps::events;
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
[self markerViewDidUpdate:markerView];
|
|
82
|
-
} else if ([childComponentView isKindOfClass:[
|
|
83
|
-
|
|
84
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
86
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
87
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
85
88
|
polylineView.delegate = self;
|
|
86
89
|
[self addPolylineViewToMap:polylineView];
|
|
87
90
|
}
|
|
@@ -90,8 +93,8 @@ using namespace luggmaps::events;
|
|
|
90
93
|
- (void)unmountChildComponentView:
|
|
91
94
|
(UIView<RCTComponentViewProtocol> *)childComponentView
|
|
92
95
|
index:(NSInteger)index {
|
|
93
|
-
if ([childComponentView isKindOfClass:[
|
|
94
|
-
|
|
96
|
+
if ([childComponentView isKindOfClass:[LuggMarkerView class]]) {
|
|
97
|
+
LuggMarkerView *markerView = (LuggMarkerView *)childComponentView;
|
|
95
98
|
markerView.delegate = nil;
|
|
96
99
|
|
|
97
100
|
AppleMarkerAnnotation *annotation =
|
|
@@ -103,9 +106,8 @@ using namespace luggmaps::events;
|
|
|
103
106
|
[_mapView removeAnnotation:annotation];
|
|
104
107
|
markerView.marker = nil;
|
|
105
108
|
}
|
|
106
|
-
} else if ([childComponentView isKindOfClass:[
|
|
107
|
-
|
|
108
|
-
(LuggMapsPolylineView *)childComponentView;
|
|
109
|
+
} else if ([childComponentView isKindOfClass:[LuggPolylineView class]]) {
|
|
110
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)childComponentView;
|
|
109
111
|
polylineView.delegate = nil;
|
|
110
112
|
MKPolyline *polyline = (MKPolyline *)polylineView.polyline;
|
|
111
113
|
if (polyline) {
|
|
@@ -130,6 +132,7 @@ using namespace luggmaps::events;
|
|
|
130
132
|
[_mapView removeFromSuperview];
|
|
131
133
|
_mapView = nil;
|
|
132
134
|
_mapWrapperView = nil;
|
|
135
|
+
_isMapReady = NO;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
#pragma mark - Map Initialization
|
|
@@ -140,10 +143,10 @@ using namespace luggmaps::events;
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
const auto &viewProps =
|
|
143
|
-
*std::static_pointer_cast<
|
|
146
|
+
*std::static_pointer_cast<LuggAppleMapViewProps const>(_props);
|
|
144
147
|
|
|
145
|
-
_mapView =
|
|
146
|
-
initWithFrame:_mapWrapperView.bounds];
|
|
148
|
+
_mapView =
|
|
149
|
+
[[LuggAppleMapViewContent alloc] initWithFrame:_mapWrapperView.bounds];
|
|
147
150
|
_mapView.autoresizingMask =
|
|
148
151
|
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
149
152
|
_mapView.delegate = self;
|
|
@@ -152,6 +155,15 @@ using namespace luggmaps::events;
|
|
|
152
155
|
_mapView.scrollEnabled = viewProps.scrollEnabled;
|
|
153
156
|
_mapView.rotateEnabled = viewProps.rotateEnabled;
|
|
154
157
|
_mapView.pitchEnabled = viewProps.pitchEnabled;
|
|
158
|
+
_mapView.showsUserLocation = viewProps.userLocationEnabled;
|
|
159
|
+
|
|
160
|
+
_minZoom = viewProps.minZoom;
|
|
161
|
+
_maxZoom = viewProps.maxZoom;
|
|
162
|
+
[self applyZoomRange];
|
|
163
|
+
|
|
164
|
+
_mapView.layoutMargins =
|
|
165
|
+
UIEdgeInsetsMake(viewProps.padding.top, viewProps.padding.left,
|
|
166
|
+
viewProps.padding.bottom, viewProps.padding.right);
|
|
155
167
|
|
|
156
168
|
[_mapWrapperView addSubview:_mapView];
|
|
157
169
|
|
|
@@ -162,18 +174,22 @@ using namespace luggmaps::events;
|
|
|
162
174
|
|
|
163
175
|
// Add annotations for any markers that were mounted before map was ready
|
|
164
176
|
for (UIView *subview in self.subviews) {
|
|
165
|
-
if ([subview isKindOfClass:[
|
|
166
|
-
|
|
177
|
+
if ([subview isKindOfClass:[LuggMarkerView class]]) {
|
|
178
|
+
LuggMarkerView *markerView = (LuggMarkerView *)subview;
|
|
167
179
|
AppleMarkerAnnotation *annotation =
|
|
168
180
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
169
181
|
if (annotation) {
|
|
170
182
|
[_mapView addAnnotation:annotation];
|
|
171
183
|
}
|
|
172
|
-
} else if ([subview isKindOfClass:[
|
|
173
|
-
|
|
184
|
+
} else if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
185
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
174
186
|
[self addPolylineViewToMap:polylineView];
|
|
175
187
|
}
|
|
176
188
|
}
|
|
189
|
+
|
|
190
|
+
_isMapReady = YES;
|
|
191
|
+
|
|
192
|
+
ReadyEvent::emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
- (void)setCameraWithLatitude:(double)latitude
|
|
@@ -185,6 +201,27 @@ using namespace luggmaps::events;
|
|
|
185
201
|
[_mapView setCenterCoordinate:center zoomLevel:zoom animated:animated];
|
|
186
202
|
}
|
|
187
203
|
|
|
204
|
+
- (CLLocationDistance)cameraDistanceForZoomLevel:(double)zoomLevel {
|
|
205
|
+
// Approximate conversion: at zoom 0, altitude ~128M km
|
|
206
|
+
// Each zoom level halves the altitude
|
|
207
|
+
return 128000000.0 / pow(2, zoomLevel);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
- (void)applyZoomRange {
|
|
211
|
+
if (!_mapView)
|
|
212
|
+
return;
|
|
213
|
+
|
|
214
|
+
CLLocationDistance minDistance =
|
|
215
|
+
_maxZoom > 0 ? [self cameraDistanceForZoomLevel:_maxZoom] : 0;
|
|
216
|
+
CLLocationDistance maxDistance =
|
|
217
|
+
_minZoom > 0 ? [self cameraDistanceForZoomLevel:_minZoom] : -1;
|
|
218
|
+
|
|
219
|
+
MKMapCameraZoomRange *zoomRange = [[MKMapCameraZoomRange alloc]
|
|
220
|
+
initWithMinCenterCoordinateDistance:minDistance
|
|
221
|
+
maxCenterCoordinateDistance:maxDistance];
|
|
222
|
+
_mapView.cameraZoomRange = zoomRange;
|
|
223
|
+
}
|
|
224
|
+
|
|
188
225
|
- (MKMapView *)mapView {
|
|
189
226
|
return _mapView;
|
|
190
227
|
}
|
|
@@ -194,16 +231,21 @@ using namespace luggmaps::events;
|
|
|
194
231
|
- (void)updateProps:(Props::Shared const &)props
|
|
195
232
|
oldProps:(Props::Shared const &)oldProps {
|
|
196
233
|
const auto &newViewProps =
|
|
197
|
-
*std::static_pointer_cast<
|
|
234
|
+
*std::static_pointer_cast<LuggAppleMapViewProps const>(props);
|
|
198
235
|
|
|
199
236
|
if (_mapView) {
|
|
200
237
|
_mapView.zoomEnabled = newViewProps.zoomEnabled;
|
|
201
238
|
_mapView.scrollEnabled = newViewProps.scrollEnabled;
|
|
202
239
|
_mapView.rotateEnabled = newViewProps.rotateEnabled;
|
|
203
240
|
_mapView.pitchEnabled = newViewProps.pitchEnabled;
|
|
241
|
+
_mapView.showsUserLocation = newViewProps.userLocationEnabled;
|
|
204
242
|
_mapView.layoutMargins = UIEdgeInsetsMake(
|
|
205
243
|
newViewProps.padding.top, newViewProps.padding.left,
|
|
206
244
|
newViewProps.padding.bottom, newViewProps.padding.right);
|
|
245
|
+
|
|
246
|
+
_minZoom = newViewProps.minZoom;
|
|
247
|
+
_maxZoom = newViewProps.maxZoom;
|
|
248
|
+
[self applyZoomRange];
|
|
207
249
|
}
|
|
208
250
|
|
|
209
251
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -213,7 +255,7 @@ using namespace luggmaps::events;
|
|
|
213
255
|
|
|
214
256
|
- (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
|
|
215
257
|
MKAnnotationView *annotationView = annotation.annotationView;
|
|
216
|
-
|
|
258
|
+
LuggMarkerView *markerView = annotation.markerView;
|
|
217
259
|
|
|
218
260
|
if (!annotationView || !markerView) {
|
|
219
261
|
return;
|
|
@@ -233,13 +275,13 @@ using namespace luggmaps::events;
|
|
|
233
275
|
|
|
234
276
|
#pragma mark - PolylineViewDelegate
|
|
235
277
|
|
|
236
|
-
- (void)polylineViewDidUpdate:(
|
|
278
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
237
279
|
[self syncPolylineView:polylineView];
|
|
238
280
|
}
|
|
239
281
|
|
|
240
282
|
#pragma mark - Polyline Management
|
|
241
283
|
|
|
242
|
-
- (void)addPolylineViewToMap:(
|
|
284
|
+
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
243
285
|
if (!_mapView) {
|
|
244
286
|
return;
|
|
245
287
|
}
|
|
@@ -263,7 +305,7 @@ using namespace luggmaps::events;
|
|
|
263
305
|
[_mapView addOverlay:polyline];
|
|
264
306
|
}
|
|
265
307
|
|
|
266
|
-
- (void)syncPolylineView:(
|
|
308
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
267
309
|
if (!_mapView) {
|
|
268
310
|
return;
|
|
269
311
|
}
|
|
@@ -311,10 +353,10 @@ using namespace luggmaps::events;
|
|
|
311
353
|
[_mapView addOverlay:newPolyline];
|
|
312
354
|
}
|
|
313
355
|
|
|
314
|
-
- (
|
|
356
|
+
- (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
|
|
315
357
|
for (UIView *subview in self.subviews) {
|
|
316
|
-
if ([subview isKindOfClass:[
|
|
317
|
-
|
|
358
|
+
if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
359
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
318
360
|
if (polylineView.polyline == overlay) {
|
|
319
361
|
return polylineView;
|
|
320
362
|
}
|
|
@@ -325,7 +367,7 @@ using namespace luggmaps::events;
|
|
|
325
367
|
|
|
326
368
|
#pragma mark - MarkerViewDelegate
|
|
327
369
|
|
|
328
|
-
- (void)markerViewDidLayout:(
|
|
370
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
329
371
|
AppleMarkerAnnotation *annotation =
|
|
330
372
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
331
373
|
if (annotation) {
|
|
@@ -333,7 +375,7 @@ using namespace luggmaps::events;
|
|
|
333
375
|
}
|
|
334
376
|
}
|
|
335
377
|
|
|
336
|
-
- (void)markerViewDidUpdate:(
|
|
378
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
337
379
|
AppleMarkerAnnotation *annotation =
|
|
338
380
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
339
381
|
|
|
@@ -367,27 +409,19 @@ using namespace luggmaps::events;
|
|
|
367
409
|
}
|
|
368
410
|
|
|
369
411
|
- (void)mapViewDidChangeVisibleRegion:(MKMapView *)mapView {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
CameraMoveEvent{mapView.centerCoordinate.latitude,
|
|
375
|
-
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
376
|
-
_isDragging}
|
|
377
|
-
.emit(emitter);
|
|
378
|
-
}
|
|
412
|
+
CameraMoveEvent{mapView.centerCoordinate.latitude,
|
|
413
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
414
|
+
_isDragging}
|
|
415
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
379
416
|
}
|
|
380
417
|
|
|
381
418
|
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
|
|
419
|
+
BOOL wasDragging = _isDragging;
|
|
382
420
|
_isDragging = NO;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
388
|
-
mapView.centerCoordinate.longitude, mapView.zoomLevel}
|
|
389
|
-
.emit(emitter);
|
|
390
|
-
}
|
|
421
|
+
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
422
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
423
|
+
static_cast<bool>(wasDragging)}
|
|
424
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
391
425
|
}
|
|
392
426
|
|
|
393
427
|
- (MKAnnotationView *)mapView:(MKMapView *)mapView
|
|
@@ -397,7 +431,7 @@ using namespace luggmaps::events;
|
|
|
397
431
|
}
|
|
398
432
|
|
|
399
433
|
AppleMarkerAnnotation *markerAnnotation = (AppleMarkerAnnotation *)annotation;
|
|
400
|
-
|
|
434
|
+
LuggMarkerView *markerView = markerAnnotation.markerView;
|
|
401
435
|
|
|
402
436
|
if (!markerView || !markerView.hasCustomView) {
|
|
403
437
|
return nil;
|
|
@@ -435,8 +469,7 @@ using namespace luggmaps::events;
|
|
|
435
469
|
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
|
|
436
470
|
rendererForOverlay:(id<MKOverlay>)overlay {
|
|
437
471
|
if ([overlay isKindOfClass:[MKPolyline class]]) {
|
|
438
|
-
|
|
439
|
-
[self findPolylineViewForOverlay:overlay];
|
|
472
|
+
LuggPolylineView *polylineView = [self findPolylineViewForOverlay:overlay];
|
|
440
473
|
MKPolyline *polyline = (MKPolyline *)overlay;
|
|
441
474
|
|
|
442
475
|
if (polylineView) {
|
|
@@ -494,7 +527,10 @@ using namespace luggmaps::events;
|
|
|
494
527
|
}
|
|
495
528
|
|
|
496
529
|
- (void)fitCoordinates:(NSArray *)coordinates
|
|
497
|
-
|
|
530
|
+
paddingTop:(double)paddingTop
|
|
531
|
+
paddingLeft:(double)paddingLeft
|
|
532
|
+
paddingBottom:(double)paddingBottom
|
|
533
|
+
paddingRight:(double)paddingRight
|
|
498
534
|
duration:(double)duration {
|
|
499
535
|
if (!_mapView || coordinates.count == 0) {
|
|
500
536
|
return;
|
|
@@ -517,7 +553,7 @@ using namespace luggmaps::events;
|
|
|
517
553
|
free(coords);
|
|
518
554
|
|
|
519
555
|
UIEdgeInsets edgePadding =
|
|
520
|
-
UIEdgeInsetsMake(
|
|
556
|
+
UIEdgeInsetsMake(paddingTop, paddingLeft, paddingBottom, paddingRight);
|
|
521
557
|
|
|
522
558
|
if (duration < 0) {
|
|
523
559
|
[_mapView setVisibleMapRect:mapRect edgePadding:edgePadding animated:YES];
|
|
@@ -534,11 +570,11 @@ using namespace luggmaps::events;
|
|
|
534
570
|
}
|
|
535
571
|
|
|
536
572
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
537
|
-
|
|
573
|
+
RCTLuggAppleMapViewHandleCommand(self, commandName, args);
|
|
538
574
|
}
|
|
539
575
|
|
|
540
|
-
Class<RCTComponentViewProtocol>
|
|
541
|
-
return
|
|
576
|
+
Class<RCTComponentViewProtocol> LuggAppleMapViewCls(void) {
|
|
577
|
+
return LuggAppleMapView.class;
|
|
542
578
|
}
|
|
543
579
|
|
|
544
580
|
@end
|