@lugg/maps 0.2.0-alpha.0 → 0.2.0-alpha.1
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} +81 -28
- package/android/src/main/java/com/luggmaps/{LuggMapsGoogleMapViewManager.kt → LuggGoogleMapViewManager.kt} +57 -38
- 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} +95 -66
- package/ios/{LuggMapsGoogleMapView.h → LuggGoogleMapView.h} +1 -1
- package/ios/{LuggMapsGoogleMapView.mm → LuggGoogleMapView.mm} +64 -58
- 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 +13 -5
- 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} +9 -2
- package/lib/module/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
- 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 +23 -12
- 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} +9 -2
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggMapsGoogleMapViewNativeComponent.d.ts → LuggGoogleMapViewNativeComponent.d.ts} +9 -2
- 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 +16 -8
- package/src/MapView.types.ts +23 -13
- 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} +9 -2
- package/src/fabric/{LuggMapsGoogleMapViewNativeComponent.ts → LuggGoogleMapViewNativeComponent.ts} +9 -2
- 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
|
@@ -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,11 @@ 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];
|
|
155
163
|
|
|
156
164
|
[_mapWrapperView addSubview:_mapView];
|
|
157
165
|
|
|
@@ -162,18 +170,22 @@ using namespace luggmaps::events;
|
|
|
162
170
|
|
|
163
171
|
// Add annotations for any markers that were mounted before map was ready
|
|
164
172
|
for (UIView *subview in self.subviews) {
|
|
165
|
-
if ([subview isKindOfClass:[
|
|
166
|
-
|
|
173
|
+
if ([subview isKindOfClass:[LuggMarkerView class]]) {
|
|
174
|
+
LuggMarkerView *markerView = (LuggMarkerView *)subview;
|
|
167
175
|
AppleMarkerAnnotation *annotation =
|
|
168
176
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
169
177
|
if (annotation) {
|
|
170
178
|
[_mapView addAnnotation:annotation];
|
|
171
179
|
}
|
|
172
|
-
} else if ([subview isKindOfClass:[
|
|
173
|
-
|
|
180
|
+
} else if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
181
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
174
182
|
[self addPolylineViewToMap:polylineView];
|
|
175
183
|
}
|
|
176
184
|
}
|
|
185
|
+
|
|
186
|
+
_isMapReady = YES;
|
|
187
|
+
|
|
188
|
+
ReadyEvent::emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
177
189
|
}
|
|
178
190
|
|
|
179
191
|
- (void)setCameraWithLatitude:(double)latitude
|
|
@@ -185,6 +197,27 @@ using namespace luggmaps::events;
|
|
|
185
197
|
[_mapView setCenterCoordinate:center zoomLevel:zoom animated:animated];
|
|
186
198
|
}
|
|
187
199
|
|
|
200
|
+
- (CLLocationDistance)cameraDistanceForZoomLevel:(double)zoomLevel {
|
|
201
|
+
// Approximate conversion: at zoom 0, altitude ~128M km
|
|
202
|
+
// Each zoom level halves the altitude
|
|
203
|
+
return 128000000.0 / pow(2, zoomLevel);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
- (void)applyZoomRange {
|
|
207
|
+
if (!_mapView)
|
|
208
|
+
return;
|
|
209
|
+
|
|
210
|
+
CLLocationDistance minDistance =
|
|
211
|
+
_maxZoom > 0 ? [self cameraDistanceForZoomLevel:_maxZoom] : 0;
|
|
212
|
+
CLLocationDistance maxDistance =
|
|
213
|
+
_minZoom > 0 ? [self cameraDistanceForZoomLevel:_minZoom] : -1;
|
|
214
|
+
|
|
215
|
+
MKMapCameraZoomRange *zoomRange = [[MKMapCameraZoomRange alloc]
|
|
216
|
+
initWithMinCenterCoordinateDistance:minDistance
|
|
217
|
+
maxCenterCoordinateDistance:maxDistance];
|
|
218
|
+
_mapView.cameraZoomRange = zoomRange;
|
|
219
|
+
}
|
|
220
|
+
|
|
188
221
|
- (MKMapView *)mapView {
|
|
189
222
|
return _mapView;
|
|
190
223
|
}
|
|
@@ -194,16 +227,21 @@ using namespace luggmaps::events;
|
|
|
194
227
|
- (void)updateProps:(Props::Shared const &)props
|
|
195
228
|
oldProps:(Props::Shared const &)oldProps {
|
|
196
229
|
const auto &newViewProps =
|
|
197
|
-
*std::static_pointer_cast<
|
|
230
|
+
*std::static_pointer_cast<LuggAppleMapViewProps const>(props);
|
|
198
231
|
|
|
199
232
|
if (_mapView) {
|
|
200
233
|
_mapView.zoomEnabled = newViewProps.zoomEnabled;
|
|
201
234
|
_mapView.scrollEnabled = newViewProps.scrollEnabled;
|
|
202
235
|
_mapView.rotateEnabled = newViewProps.rotateEnabled;
|
|
203
236
|
_mapView.pitchEnabled = newViewProps.pitchEnabled;
|
|
237
|
+
_mapView.showsUserLocation = newViewProps.userLocationEnabled;
|
|
204
238
|
_mapView.layoutMargins = UIEdgeInsetsMake(
|
|
205
239
|
newViewProps.padding.top, newViewProps.padding.left,
|
|
206
240
|
newViewProps.padding.bottom, newViewProps.padding.right);
|
|
241
|
+
|
|
242
|
+
_minZoom = newViewProps.minZoom;
|
|
243
|
+
_maxZoom = newViewProps.maxZoom;
|
|
244
|
+
[self applyZoomRange];
|
|
207
245
|
}
|
|
208
246
|
|
|
209
247
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -213,7 +251,7 @@ using namespace luggmaps::events;
|
|
|
213
251
|
|
|
214
252
|
- (void)updateAnnotationViewFrame:(AppleMarkerAnnotation *)annotation {
|
|
215
253
|
MKAnnotationView *annotationView = annotation.annotationView;
|
|
216
|
-
|
|
254
|
+
LuggMarkerView *markerView = annotation.markerView;
|
|
217
255
|
|
|
218
256
|
if (!annotationView || !markerView) {
|
|
219
257
|
return;
|
|
@@ -233,13 +271,13 @@ using namespace luggmaps::events;
|
|
|
233
271
|
|
|
234
272
|
#pragma mark - PolylineViewDelegate
|
|
235
273
|
|
|
236
|
-
- (void)polylineViewDidUpdate:(
|
|
274
|
+
- (void)polylineViewDidUpdate:(LuggPolylineView *)polylineView {
|
|
237
275
|
[self syncPolylineView:polylineView];
|
|
238
276
|
}
|
|
239
277
|
|
|
240
278
|
#pragma mark - Polyline Management
|
|
241
279
|
|
|
242
|
-
- (void)addPolylineViewToMap:(
|
|
280
|
+
- (void)addPolylineViewToMap:(LuggPolylineView *)polylineView {
|
|
243
281
|
if (!_mapView) {
|
|
244
282
|
return;
|
|
245
283
|
}
|
|
@@ -263,7 +301,7 @@ using namespace luggmaps::events;
|
|
|
263
301
|
[_mapView addOverlay:polyline];
|
|
264
302
|
}
|
|
265
303
|
|
|
266
|
-
- (void)syncPolylineView:(
|
|
304
|
+
- (void)syncPolylineView:(LuggPolylineView *)polylineView {
|
|
267
305
|
if (!_mapView) {
|
|
268
306
|
return;
|
|
269
307
|
}
|
|
@@ -311,10 +349,10 @@ using namespace luggmaps::events;
|
|
|
311
349
|
[_mapView addOverlay:newPolyline];
|
|
312
350
|
}
|
|
313
351
|
|
|
314
|
-
- (
|
|
352
|
+
- (LuggPolylineView *)findPolylineViewForOverlay:(id<MKOverlay>)overlay {
|
|
315
353
|
for (UIView *subview in self.subviews) {
|
|
316
|
-
if ([subview isKindOfClass:[
|
|
317
|
-
|
|
354
|
+
if ([subview isKindOfClass:[LuggPolylineView class]]) {
|
|
355
|
+
LuggPolylineView *polylineView = (LuggPolylineView *)subview;
|
|
318
356
|
if (polylineView.polyline == overlay) {
|
|
319
357
|
return polylineView;
|
|
320
358
|
}
|
|
@@ -325,7 +363,7 @@ using namespace luggmaps::events;
|
|
|
325
363
|
|
|
326
364
|
#pragma mark - MarkerViewDelegate
|
|
327
365
|
|
|
328
|
-
- (void)markerViewDidLayout:(
|
|
366
|
+
- (void)markerViewDidLayout:(LuggMarkerView *)markerView {
|
|
329
367
|
AppleMarkerAnnotation *annotation =
|
|
330
368
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
331
369
|
if (annotation) {
|
|
@@ -333,7 +371,7 @@ using namespace luggmaps::events;
|
|
|
333
371
|
}
|
|
334
372
|
}
|
|
335
373
|
|
|
336
|
-
- (void)markerViewDidUpdate:(
|
|
374
|
+
- (void)markerViewDidUpdate:(LuggMarkerView *)markerView {
|
|
337
375
|
AppleMarkerAnnotation *annotation =
|
|
338
376
|
(AppleMarkerAnnotation *)markerView.marker;
|
|
339
377
|
|
|
@@ -367,27 +405,19 @@ using namespace luggmaps::events;
|
|
|
367
405
|
}
|
|
368
406
|
|
|
369
407
|
- (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
|
-
}
|
|
408
|
+
CameraMoveEvent{mapView.centerCoordinate.latitude,
|
|
409
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
410
|
+
_isDragging}
|
|
411
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
379
412
|
}
|
|
380
413
|
|
|
381
414
|
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
|
|
415
|
+
BOOL wasDragging = _isDragging;
|
|
382
416
|
_isDragging = NO;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
388
|
-
mapView.centerCoordinate.longitude, mapView.zoomLevel}
|
|
389
|
-
.emit(emitter);
|
|
390
|
-
}
|
|
417
|
+
CameraIdleEvent{mapView.centerCoordinate.latitude,
|
|
418
|
+
mapView.centerCoordinate.longitude, mapView.zoomLevel,
|
|
419
|
+
static_cast<bool>(wasDragging)}
|
|
420
|
+
.emit<LuggAppleMapViewEventEmitter>(_eventEmitter);
|
|
391
421
|
}
|
|
392
422
|
|
|
393
423
|
- (MKAnnotationView *)mapView:(MKMapView *)mapView
|
|
@@ -397,7 +427,7 @@ using namespace luggmaps::events;
|
|
|
397
427
|
}
|
|
398
428
|
|
|
399
429
|
AppleMarkerAnnotation *markerAnnotation = (AppleMarkerAnnotation *)annotation;
|
|
400
|
-
|
|
430
|
+
LuggMarkerView *markerView = markerAnnotation.markerView;
|
|
401
431
|
|
|
402
432
|
if (!markerView || !markerView.hasCustomView) {
|
|
403
433
|
return nil;
|
|
@@ -435,8 +465,7 @@ using namespace luggmaps::events;
|
|
|
435
465
|
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
|
|
436
466
|
rendererForOverlay:(id<MKOverlay>)overlay {
|
|
437
467
|
if ([overlay isKindOfClass:[MKPolyline class]]) {
|
|
438
|
-
|
|
439
|
-
[self findPolylineViewForOverlay:overlay];
|
|
468
|
+
LuggPolylineView *polylineView = [self findPolylineViewForOverlay:overlay];
|
|
440
469
|
MKPolyline *polyline = (MKPolyline *)overlay;
|
|
441
470
|
|
|
442
471
|
if (polylineView) {
|
|
@@ -534,11 +563,11 @@ using namespace luggmaps::events;
|
|
|
534
563
|
}
|
|
535
564
|
|
|
536
565
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
537
|
-
|
|
566
|
+
RCTLuggAppleMapViewHandleCommand(self, commandName, args);
|
|
538
567
|
}
|
|
539
568
|
|
|
540
|
-
Class<RCTComponentViewProtocol>
|
|
541
|
-
return
|
|
569
|
+
Class<RCTComponentViewProtocol> LuggAppleMapViewCls(void) {
|
|
570
|
+
return LuggAppleMapView.class;
|
|
542
571
|
}
|
|
543
572
|
|
|
544
573
|
@end
|