@exterio/react-native-yamap-lite 1.0.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.
Files changed (141) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +510 -0
  3. package/YamapLite.podspec +21 -0
  4. package/android/build.gradle +101 -0
  5. package/android/gradle.properties +14 -0
  6. package/android/settings.gradle +1 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/yamaplite/ClusteredYamapLiteViewManager.kt +181 -0
  9. package/android/src/main/java/com/yamaplite/Components/ClusteredYamapLiteView.kt +169 -0
  10. package/android/src/main/java/com/yamaplite/Components/YamapLiteCircleView.kt +145 -0
  11. package/android/src/main/java/com/yamaplite/Components/YamapLiteMarkerView.kt +214 -0
  12. package/android/src/main/java/com/yamaplite/Components/YamapLitePolygon.kt +149 -0
  13. package/android/src/main/java/com/yamaplite/Components/YamapLitePolyline.kt +171 -0
  14. package/android/src/main/java/com/yamaplite/Components/YamapLiteView.kt +678 -0
  15. package/android/src/main/java/com/yamaplite/Events/CameraPositionChangeEvent.kt +38 -0
  16. package/android/src/main/java/com/yamaplite/Events/MapLoadEvent.kt +34 -0
  17. package/android/src/main/java/com/yamaplite/Events/PressEvent.kt +24 -0
  18. package/android/src/main/java/com/yamaplite/Utils/ImageCache.kt +45 -0
  19. package/android/src/main/java/com/yamaplite/Utils/PointParser.kt +39 -0
  20. package/android/src/main/java/com/yamaplite/Utils/ResolveImageHelper.kt +122 -0
  21. package/android/src/main/java/com/yamaplite/Utils/YamapUtils.kt +169 -0
  22. package/android/src/main/java/com/yamaplite/YamapLiteCircleViewManager.kt +67 -0
  23. package/android/src/main/java/com/yamaplite/YamapLiteMarkerViewManager.kt +82 -0
  24. package/android/src/main/java/com/yamaplite/YamapLitePackage.kt +41 -0
  25. package/android/src/main/java/com/yamaplite/YamapLitePolygonViewManager.kt +61 -0
  26. package/android/src/main/java/com/yamaplite/YamapLitePolylineViewManager.kt +75 -0
  27. package/android/src/main/java/com/yamaplite/YamapLiteViewManager.kt +176 -0
  28. package/ios/ClusteredYamapLiteView.h +15 -0
  29. package/ios/ClusteredYamapLiteView.mm +325 -0
  30. package/ios/ClusteredYamapLiteViewManager.mm +17 -0
  31. package/ios/Components/Circle.swift +108 -0
  32. package/ios/Components/ClusteredYamap.swift +190 -0
  33. package/ios/Components/Marker.swift +187 -0
  34. package/ios/Components/Polygon.swift +108 -0
  35. package/ios/Components/Polyline.swift +125 -0
  36. package/ios/Components/Yamap.swift +585 -0
  37. package/ios/Listeners/CameraListener.swift +54 -0
  38. package/ios/Listeners/ClusterListener.swift +38 -0
  39. package/ios/Listeners/MapInputListener.swift +35 -0
  40. package/ios/Listeners/MapLoadListener.swift +35 -0
  41. package/ios/Listeners/MapObjectTap.swift +12 -0
  42. package/ios/Listeners/UserLocationObjectListener.swift +29 -0
  43. package/ios/Models/YamapModels.swift +77 -0
  44. package/ios/Utils/ImageCache.swift +20 -0
  45. package/ios/Utils/PointsEqual.h +45 -0
  46. package/ios/Utils/ResolveImageHelper.swift +142 -0
  47. package/ios/YamapLiteCircleView.h +15 -0
  48. package/ios/YamapLiteCircleView.mm +102 -0
  49. package/ios/YamapLiteMarkerView.h +15 -0
  50. package/ios/YamapLiteMarkerView.mm +102 -0
  51. package/ios/YamapLitePolygonView.h +15 -0
  52. package/ios/YamapLitePolygonView.mm +120 -0
  53. package/ios/YamapLitePolylineView.h +15 -0
  54. package/ios/YamapLitePolylineView.mm +115 -0
  55. package/ios/YamapLiteView.h +15 -0
  56. package/ios/YamapLiteView.mm +361 -0
  57. package/ios/YamapLiteViewManager.mm +17 -0
  58. package/ios/YamapUtils.h +5 -0
  59. package/ios/YamapUtils.mm +205 -0
  60. package/lib/module/@types/index.js +8 -0
  61. package/lib/module/@types/index.js.map +1 -0
  62. package/lib/module/ClusteredYamapLiteViewNativeComponent.ts +98 -0
  63. package/lib/module/Components/Circle.js +20 -0
  64. package/lib/module/Components/Circle.js.map +1 -0
  65. package/lib/module/Components/ClusteredYamap.js +133 -0
  66. package/lib/module/Components/ClusteredYamap.js.map +1 -0
  67. package/lib/module/Components/Marker.js +40 -0
  68. package/lib/module/Components/Marker.js.map +1 -0
  69. package/lib/module/Components/Polygon.js +25 -0
  70. package/lib/module/Components/Polygon.js.map +1 -0
  71. package/lib/module/Components/Polyline.js +25 -0
  72. package/lib/module/Components/Polyline.js.map +1 -0
  73. package/lib/module/Components/Yamap.js +124 -0
  74. package/lib/module/Components/Yamap.js.map +1 -0
  75. package/lib/module/Components/index.js +9 -0
  76. package/lib/module/Components/index.js.map +1 -0
  77. package/lib/module/NativeYamapUtils.js +5 -0
  78. package/lib/module/NativeYamapUtils.js.map +1 -0
  79. package/lib/module/Utils/YamapUtils.js +14 -0
  80. package/lib/module/Utils/YamapUtils.js.map +1 -0
  81. package/lib/module/YamapCircleViewNativeComponent.ts +28 -0
  82. package/lib/module/YamapLiteViewNativeComponent.ts +93 -0
  83. package/lib/module/YamapMarkerViewNativeComponent.ts +32 -0
  84. package/lib/module/YamapPolygonViewNativeComponent.ts +28 -0
  85. package/lib/module/YamapPolylineViewNativeComponent.ts +31 -0
  86. package/lib/module/index.js +7 -0
  87. package/lib/module/index.js.map +1 -0
  88. package/lib/module/package.json +1 -0
  89. package/lib/typescript/package.json +1 -0
  90. package/lib/typescript/src/@types/index.d.ts +257 -0
  91. package/lib/typescript/src/@types/index.d.ts.map +1 -0
  92. package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts +82 -0
  93. package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts.map +1 -0
  94. package/lib/typescript/src/Components/Circle.d.ts +4 -0
  95. package/lib/typescript/src/Components/Circle.d.ts.map +1 -0
  96. package/lib/typescript/src/Components/ClusteredYamap.d.ts +3 -0
  97. package/lib/typescript/src/Components/ClusteredYamap.d.ts.map +1 -0
  98. package/lib/typescript/src/Components/Marker.d.ts +3 -0
  99. package/lib/typescript/src/Components/Marker.d.ts.map +1 -0
  100. package/lib/typescript/src/Components/Polygon.d.ts +4 -0
  101. package/lib/typescript/src/Components/Polygon.d.ts.map +1 -0
  102. package/lib/typescript/src/Components/Polyline.d.ts +4 -0
  103. package/lib/typescript/src/Components/Polyline.d.ts.map +1 -0
  104. package/lib/typescript/src/Components/Yamap.d.ts +3 -0
  105. package/lib/typescript/src/Components/Yamap.d.ts.map +1 -0
  106. package/lib/typescript/src/Components/index.d.ts +7 -0
  107. package/lib/typescript/src/Components/index.d.ts.map +1 -0
  108. package/lib/typescript/src/NativeYamapUtils.d.ts +30 -0
  109. package/lib/typescript/src/NativeYamapUtils.d.ts.map +1 -0
  110. package/lib/typescript/src/Utils/YamapUtils.d.ts +27 -0
  111. package/lib/typescript/src/Utils/YamapUtils.d.ts.map +1 -0
  112. package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts +20 -0
  113. package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts.map +1 -0
  114. package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts +80 -0
  115. package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts.map +1 -0
  116. package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts +25 -0
  117. package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts.map +1 -0
  118. package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts +20 -0
  119. package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts.map +1 -0
  120. package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts +23 -0
  121. package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts.map +1 -0
  122. package/lib/typescript/src/index.d.ts +5 -0
  123. package/lib/typescript/src/index.d.ts.map +1 -0
  124. package/package.json +189 -0
  125. package/src/@types/index.ts +314 -0
  126. package/src/ClusteredYamapLiteViewNativeComponent.ts +98 -0
  127. package/src/Components/Circle.tsx +22 -0
  128. package/src/Components/ClusteredYamap.tsx +194 -0
  129. package/src/Components/Marker.tsx +50 -0
  130. package/src/Components/Polygon.tsx +27 -0
  131. package/src/Components/Polyline.tsx +27 -0
  132. package/src/Components/Yamap.tsx +176 -0
  133. package/src/Components/index.ts +6 -0
  134. package/src/NativeYamapUtils.ts +47 -0
  135. package/src/Utils/YamapUtils.ts +63 -0
  136. package/src/YamapCircleViewNativeComponent.ts +28 -0
  137. package/src/YamapLiteViewNativeComponent.ts +93 -0
  138. package/src/YamapMarkerViewNativeComponent.ts +32 -0
  139. package/src/YamapPolygonViewNativeComponent.ts +28 -0
  140. package/src/YamapPolylineViewNativeComponent.ts +31 -0
  141. package/src/index.tsx +5 -0
@@ -0,0 +1,75 @@
1
+ package com.yamaplite
2
+
3
+ import android.graphics.Color
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.facebook.react.uimanager.SimpleViewManager
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+ import com.facebook.react.uimanager.annotations.ReactProp
8
+ import com.facebook.react.viewmanagers.YamapLitePolylineViewManagerInterface
9
+ import com.yamaplite.components.YamapPolyline
10
+ import com.yamaplite.utils.PointParser
11
+
12
+ class YamapLitePolylineViewManager :
13
+ SimpleViewManager<YamapPolyline>(), YamapLitePolylineViewManagerInterface<YamapPolyline> {
14
+ override fun getName(): String {
15
+ return NAME
16
+ }
17
+
18
+ override fun createViewInstance(context: ThemedReactContext): YamapPolyline {
19
+ return YamapPolyline(context)
20
+ }
21
+
22
+ @ReactProp(name = "strokeColor")
23
+ override fun setStrokeColor(view: YamapPolyline, color: Int?) {
24
+ view.setStrokeColor(color ?: Color.BLACK)
25
+ }
26
+
27
+ @ReactProp(name = "strokeWidth")
28
+ override fun setStrokeWidth(view: YamapPolyline, width: Float) {
29
+ view.setStrokeWidth(width)
30
+ }
31
+
32
+ @ReactProp(name = "outlineColor")
33
+ override fun setOutlineColor(view: YamapPolyline, color: Int?) {
34
+ view.setOutlineColor(color ?: Color.BLACK)
35
+ }
36
+
37
+ @ReactProp(name = "zInd")
38
+ override fun setZInd(view: YamapPolyline, zIndex: Int) {
39
+ view.setZIndex(zIndex.toFloat())
40
+ }
41
+
42
+ @ReactProp(name = "dashLength")
43
+ override fun setDashLength(view: YamapPolyline, length: Float) {
44
+ view.setDashLength(length)
45
+ }
46
+
47
+ @ReactProp(name = "gapLength")
48
+ override fun setGapLength(view: YamapPolyline, length: Float) {
49
+ view.setGapLength(length)
50
+ }
51
+
52
+ @ReactProp(name = "outlineWidth")
53
+ override fun setOutlineWidth(view: YamapPolyline, width: Float) {
54
+ view.setOutlineWidth(width)
55
+ }
56
+
57
+ @ReactProp(name = "dashOffset")
58
+ override fun setDashOffset(view: YamapPolyline, offset: Float) {
59
+ view.setDashOffset(offset)
60
+ }
61
+
62
+ @ReactProp(name = "points")
63
+ override fun setPoints(view: YamapPolyline, points: ReadableArray?) {
64
+ view.setPoints(PointParser.parsePoints(points))
65
+ }
66
+
67
+ @ReactProp(name = "handled")
68
+ override fun setHandled(view: YamapPolyline, handled: Boolean) {
69
+ view.setHandled(handled)
70
+ }
71
+
72
+ companion object {
73
+ const val NAME = "YamapLitePolylineView"
74
+ }
75
+ }
@@ -0,0 +1,176 @@
1
+ package com.yamaplite
2
+
3
+ import android.view.View
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.uimanager.ThemedReactContext
6
+ import com.facebook.react.uimanager.ViewGroupManager
7
+ import com.facebook.react.uimanager.ViewManagerDelegate
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.facebook.react.viewmanagers.YamapLiteViewManagerDelegate
10
+ import com.facebook.react.viewmanagers.YamapLiteViewManagerInterface
11
+ import com.yamaplite.components.YamapLiteView
12
+
13
+ class YamapLiteViewManager :
14
+ ViewGroupManager<YamapLiteView>(), YamapLiteViewManagerInterface<YamapLiteView> {
15
+ private val mDelegate: ViewManagerDelegate<YamapLiteView>
16
+
17
+ init {
18
+ mDelegate = YamapLiteViewManagerDelegate(this)
19
+ }
20
+
21
+ override fun getDelegate(): ViewManagerDelegate<YamapLiteView> = mDelegate
22
+
23
+ override fun createViewInstance(context: ThemedReactContext): YamapLiteView {
24
+ return YamapLiteView(context)
25
+ }
26
+
27
+ override fun onDropViewInstance(view: YamapLiteView) {
28
+ view.onDropViewInstance()
29
+ super.onDropViewInstance(view)
30
+ }
31
+
32
+ override fun addView(parent: YamapLiteView, child: View, index: Int) {
33
+ parent.addReactChild(child, index)
34
+ super.addView(parent, child, index)
35
+ }
36
+
37
+ override fun getChildAt(parent: YamapLiteView, index: Int): View {
38
+ return parent.getReactChildAt(index)
39
+ ?: throw IndexOutOfBoundsException(
40
+ "Index $index is out of bounds for child count ${parent.getReactChildCount()}"
41
+ )
42
+ }
43
+
44
+ override fun getChildCount(parent: YamapLiteView): Int {
45
+ return parent.getReactChildCount()
46
+ }
47
+
48
+ override fun removeViewAt(parent: YamapLiteView, index: Int) {
49
+ val childCount = parent.getReactChildCount()
50
+ if (index >= 0 && index < childCount) {
51
+ parent.removeReactChildAt(index)
52
+ super.removeViewAt(parent, index)
53
+ }
54
+ }
55
+
56
+ override fun getName() = "YamapLiteView"
57
+
58
+ @ReactProp(name = "userLocationIcon")
59
+ override fun setUserLocationIcon(view: YamapLiteView, value: String?) {
60
+ view.setUserLocationIcon(value)
61
+ }
62
+
63
+ @ReactProp(name = "userLocationIconScale")
64
+ override fun setUserLocationIconScale(view: YamapLiteView, value: Float) {
65
+ view.setUserLocationIconScale(value)
66
+ }
67
+
68
+ @ReactProp(name = "showUserPosition")
69
+ override fun setShowUserPosition(view: YamapLiteView, value: Boolean) {
70
+ view.setShowUserPosition(value)
71
+ }
72
+
73
+ @ReactProp(name = "nightMode")
74
+ override fun setNightMode(view: YamapLiteView, value: Boolean) {
75
+ view.setNightMode(value)
76
+ }
77
+
78
+ @ReactProp(name = "mapStyle")
79
+ override fun setMapStyle(view: YamapLiteView, value: String?) {
80
+ view.setMapStyle(value)
81
+ }
82
+
83
+ @ReactProp(name = "scrollGesturesEnabled")
84
+ override fun setScrollGesturesEnabled(view: YamapLiteView, _value: Boolean) {
85
+ view.setScrollGesturesEnabled(_value)
86
+ }
87
+
88
+ @ReactProp(name = "zoomGesturesEnabled")
89
+ override fun setZoomGesturesEnabled(view: YamapLiteView, _value: Boolean) {
90
+ view.setZoomGesturesEnabled(_value)
91
+ }
92
+
93
+ @ReactProp(name = "tiltGesturesEnabled")
94
+ override fun setTiltGesturesEnabled(view: YamapLiteView, _value: Boolean) {
95
+ view.setTiltGesturesEnabled(_value)
96
+ }
97
+
98
+ @ReactProp(name = "rotateGesturesEnabled")
99
+ override fun setRotateGesturesEnabled(view: YamapLiteView, _value: Boolean) {
100
+ view.setRotateGesturesEnabled(_value)
101
+ }
102
+
103
+ @ReactProp(name = "fastTapEnabled")
104
+ override fun setFastTapEnabled(view: YamapLiteView, _value: Boolean) {
105
+ view.setFastTapEnabled(_value)
106
+ }
107
+
108
+ @ReactProp(name = "initialRegion")
109
+ override fun setInitialRegion(view: YamapLiteView, value: ReadableMap?) {
110
+ if (value != null) {
111
+ val region = mutableMapOf<String, Any>()
112
+ if (value.hasKey("lat")) region["lat"] = value.getDouble("lat")
113
+ if (value.hasKey("lon")) region["lon"] = value.getDouble("lon")
114
+ if (value.hasKey("zoom")) region["zoom"] = value.getDouble("zoom")
115
+ if (value.hasKey("azimuth")) region["azimuth"] = value.getDouble("azimuth")
116
+ if (value.hasKey("tilt")) region["tilt"] = value.getDouble("tilt")
117
+ view.setInitialRegion(region)
118
+ }
119
+ }
120
+
121
+ @ReactProp(name = "maxFps")
122
+ override fun setMaxFps(view: YamapLiteView, _value: Float) {
123
+ view.setMaxFps(_value)
124
+ }
125
+
126
+ @ReactProp(name = "mapType")
127
+ override fun setMapType(view: YamapLiteView, _value: String?) {
128
+ view.setMapType(_value)
129
+ }
130
+
131
+ @ReactProp(name = "logoPosition")
132
+ override fun setLogoPosition(view: YamapLiteView, _value: ReadableMap?) {
133
+ if (_value != null) {
134
+ val position = mutableMapOf<String, Any>()
135
+ if (_value.hasKey("vertical")) position["vertical"] = _value.getString("vertical") ?: "bottom"
136
+ if (_value.hasKey("horizontal"))
137
+ position["horizontal"] = _value.getString("horizontal") ?: "left"
138
+ view.setLogoPosition(position)
139
+ }
140
+ }
141
+
142
+ @ReactProp(name = "logoPadding")
143
+ override fun setLogoPadding(view: YamapLiteView, _value: ReadableMap?) {
144
+ if (_value != null) {
145
+ val horizontalPadding =
146
+ if ((_value.hasKey("horizontal") && !_value.isNull("horizontal")))
147
+ _value.getInt("horizontal")
148
+ else 0
149
+ val verticalPadding =
150
+ if ((_value.hasKey("vertical") && !_value.isNull("vertical")))
151
+ _value.getInt("vertical")
152
+ else 0
153
+ view.setLogoPadding(horizontalPadding, verticalPadding)
154
+ }
155
+ }
156
+
157
+ @ReactProp(name = "userLocationAccuracyFillColor")
158
+ override fun setUserLocationAccuracyFillColor(view: YamapLiteView, _value: String?) {
159
+ view.setUserLocationAccuracyFillColor(_value)
160
+ }
161
+
162
+ @ReactProp(name = "userLocationAccuracyStrokeColor")
163
+ override fun setUserLocationAccuracyStrokeColor(view: YamapLiteView, _value: String?) {
164
+ view.setUserLocationAccuracyStrokeColor(_value)
165
+ }
166
+
167
+ @ReactProp(name = "userLocationAccuracyStrokeWidth")
168
+ override fun setUserLocationAccuracyStrokeWidth(view: YamapLiteView, _value: Float) {
169
+ view.setUserLocationAccuracyStrokeWidth(_value)
170
+ }
171
+
172
+ @ReactProp(name = "followUser")
173
+ override fun setFollowUser(view: YamapLiteView, _value: Boolean) {
174
+ view.setFollowUser(_value)
175
+ }
176
+ }
@@ -0,0 +1,15 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <React/RCTViewManager.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ #ifndef ClusteredYamapLiteViewNativeComponent_h
6
+ #define ClusteredYamapLiteViewNativeComponent_h
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface ClusteredYamapLiteView : RCTViewComponentView
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
14
+
15
+ #endif /* ClusteredYamapLiteViewNativeComponent_h */
@@ -0,0 +1,325 @@
1
+ #import "ClusteredYamapLiteView.h"
2
+ #include <os/log.h>
3
+ #include "ReactCodegen/react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
4
+ #include "YamapLiteCircleView.h"
5
+ #include "YamapLiteMarkerView.h"
6
+ #include "YamapLitePolygonView.h"
7
+ #include "YamapLitePolylineView.h"
8
+ #include <Foundation/Foundation.h>
9
+ #include <objc/NSObject.h>
10
+
11
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
12
+ #import <React/RCTConversions.h>
13
+
14
+ #import <react/renderer/components/YamapLiteViewSpec/ComponentDescriptors.h>
15
+ #import <react/renderer/components/YamapLiteViewSpec/EventEmitters.h>
16
+ #import <react/renderer/components/YamapLiteViewSpec/Props.h>
17
+ #import <react/renderer/components/YamapLiteViewSpec/RCTComponentViewHelpers.h>
18
+
19
+ #import "RCTFabricComponentsPlugins.h"
20
+ #import "YamapLite-Swift.h"
21
+ #import <YandexMapsMobile/YMKMapKitFactory.h>
22
+
23
+ using namespace facebook::react;
24
+
25
+ @interface ClusteredYamapLiteView () <RCTClusteredYamapLiteViewViewProtocol,
26
+ YamapViewComponentDelegate>
27
+
28
+ @end
29
+
30
+ @implementation ClusteredYamapLiteView {
31
+ ClusteredYamapView *_view;
32
+ }
33
+
34
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
35
+ return concreteComponentDescriptorProvider<
36
+ ClusteredYamapLiteViewComponentDescriptor>();
37
+ }
38
+
39
+ - (instancetype)initWithFrame:(CGRect)frame {
40
+ if (self = [super initWithFrame:frame]) {
41
+ static const auto defaultProps =
42
+ std::make_shared<const ClusteredYamapLiteViewProps>();
43
+ _props = defaultProps;
44
+
45
+ _view = [[ClusteredYamapView alloc] init];
46
+ _view.delegate = self;
47
+ self.contentView = _view;
48
+ }
49
+
50
+ return self;
51
+ }
52
+
53
+ - (void)updateProps:(Props::Shared const &)props
54
+ oldProps:(Props::Shared const &)oldProps {
55
+ const auto &oldViewProps =
56
+ *std::static_pointer_cast<ClusteredYamapLiteViewProps const>(_props);
57
+ const auto &newViewProps =
58
+ *std::static_pointer_cast<ClusteredYamapLiteViewProps const>(props);
59
+ // Ensure all map property updates happen on the main thread
60
+ // React Native Fabric can call updateProps from a background thread
61
+ dispatch_async(dispatch_get_main_queue(), ^{
62
+ // Always update properties from newViewProps to ensure applyProperties()
63
+ // uses correct values
64
+ NSString *sampleRate =
65
+ RCTNSStringFromStringNilIfEmpty(toString(newViewProps.mapType));
66
+ self->_view.mapType = sampleRate;
67
+ self->_view.nightMode = newViewProps.nightMode;
68
+ self->_view.zoomGesturesEnabled = newViewProps.zoomGesturesEnabled;
69
+ self->_view.scrollGesturesEnabled = newViewProps.scrollGesturesEnabled;
70
+ self->_view.rotateGesturesEnabled = newViewProps.rotateGesturesEnabled;
71
+ self->_view.tiltGesturesEnabled = newViewProps.tiltGesturesEnabled;
72
+ self->_view.fastTapEnabled = newViewProps.fastTapEnabled;
73
+ self->_view.userLocationAccuracyFillColor =
74
+ [self hexStringToColor:RCTNSStringFromString(
75
+ newViewProps.userLocationAccuracyFillColor)];
76
+ self->_view.userLocationAccuracyStrokeColor = [self
77
+ hexStringToColor:RCTNSStringFromString(
78
+ newViewProps.userLocationAccuracyStrokeColor)];
79
+ self->_view.userLocationAccuracyStrokeWidth =
80
+ newViewProps.userLocationAccuracyStrokeWidth;
81
+ self->_view.showUserPosition = newViewProps.showUserPosition;
82
+ self->_view.userLocationIconScale = newViewProps.userLocationIconScale;
83
+ self->_view.clusterColor = [self
84
+ hexStringToColor:RCTNSStringFromString(newViewProps.clusterColor)];
85
+
86
+ NSMutableArray<YMKPoint *> *markersArr =
87
+ [NSMutableArray arrayWithCapacity:newViewProps.clusteredMarkers.size()];
88
+
89
+ for (const auto &marker : newViewProps.clusteredMarkers) {
90
+ YMKPoint *point = [YMKPoint pointWithLatitude:marker.lat
91
+ longitude:marker.lon];
92
+ [markersArr addObject:point];
93
+ }
94
+
95
+ [self->_view setupClusteredMarkersWithMarkers:markersArr];
96
+ NSDictionary *logoPositionDict = @{
97
+ @"horizontal" :
98
+ RCTNSStringFromString(toString(newViewProps.logoPosition.horizontal)),
99
+ @"vertical" :
100
+ RCTNSStringFromString(toString(newViewProps.logoPosition.vertical))
101
+ };
102
+ [self->_view setShowUserPositionState:newViewProps.showUserPosition];
103
+ [self->_view updateUserIcon];
104
+ [self->_view
105
+ setUserLocationIconWithPath:RCTNSStringFromString(
106
+ newViewProps.userLocationIcon)];
107
+ [self->_view move:newViewProps.initialRegion.lat :newViewProps.initialRegion.lon :newViewProps.initialRegion.zoom :newViewProps.initialRegion.azimuth :newViewProps.initialRegion.tilt];
108
+ [self->_view setLogoPositionWithPosition:logoPositionDict];
109
+ [self->_view
110
+ setLogoPaddingWithVertical:newViewProps.logoPadding.vertical
111
+ horizontal:newViewProps.logoPadding.horizontal];
112
+ self->_view.maxFps = newViewProps.maxFps;
113
+ [self->_view applyProperties];
114
+ });
115
+
116
+ [super updateProps:props oldProps:oldProps];
117
+ }
118
+
119
+ - (void)handleCommand:(NSString *)commandName args:(NSArray *)args {
120
+ }
121
+
122
+ - (void)setCenter:(double)latitude
123
+ longitude:(double)longitude
124
+ zoom:(float)zoom
125
+ azimuth:(float)azimuth
126
+ tilt:(float)tilt
127
+ duration:(float)duration
128
+ animation:(NSString *)animation {
129
+ [_view setCenterWithLatitude:latitude
130
+ longitude:longitude
131
+ zoom:zoom
132
+ azimuth:azimuth
133
+ tilt:tilt
134
+ duration:duration
135
+ animation:animation];
136
+ }
137
+
138
+ - (void)setZoom:(float)zoom
139
+ duration:(float)duration
140
+ animation:(NSString *)animation {
141
+ if (_view != nil) {
142
+ [_view setZoomWithZoom:zoom duration:duration animation:animation];
143
+ } else {
144
+ os_log_error(OS_LOG_DEFAULT, "ClusteredYamapLiteView: _view is nil");
145
+ }
146
+ }
147
+
148
+ - (void)fitAllMarkers {
149
+ if (_view != nil) {
150
+ [_view fitAllMarkers];
151
+ } else {
152
+ os_log_error(OS_LOG_DEFAULT, "ClusteredYamapLiteView: _view is nil");
153
+ }
154
+ }
155
+
156
+ - (void)handleOnMapLoadedWithResult:(NSDictionary *)obj {
157
+ if (_view != nil) {
158
+ [_view applyProperties];
159
+ }
160
+
161
+ if (_eventEmitter != nil) {
162
+ ClusteredYamapLiteViewEventEmitter::OnMapLoaded event = {};
163
+ event.curZoomGeometryLoaded =
164
+ [[obj objectForKey:@"curZoomGeometryLoaded"] doubleValue];
165
+ event.curZoomModelsLoaded =
166
+ [[obj objectForKey:@"curZoomModelsLoaded"] doubleValue];
167
+ event.curZoomLabelsLoaded =
168
+ [[obj objectForKey:@"curZoomLabelsLoaded"] doubleValue];
169
+ event.curZoomPlacemarksLoaded =
170
+ [[obj objectForKey:@"curZoomPlacemarksLoaded"] doubleValue];
171
+ event.fullyLoaded = [[obj objectForKey:@"fullyLoaded"] doubleValue];
172
+ event.renderObjectCount =
173
+ [[obj objectForKey:@"renderObjectCount"] doubleValue];
174
+ event.tileMemoryUsage = [[obj objectForKey:@"tileMemoryUsage"] doubleValue];
175
+ event.delayedGeometryLoaded =
176
+ [[obj objectForKey:@"delayedGeometryLoaded"] doubleValue];
177
+ event.fullyAppeared = [[obj objectForKey:@"fullyAppeared"] doubleValue];
178
+ std::dynamic_pointer_cast<const ClusteredYamapLiteViewEventEmitter>(
179
+ _eventEmitter)
180
+ ->onMapLoaded(event);
181
+ }
182
+ }
183
+
184
+ - (void)handleOnCameraPositionChangeWithCoords:(NSDictionary *)coords {
185
+ if (_eventEmitter != nil) {
186
+ ClusteredYamapLiteViewEventEmitter::OnCameraPositionChange event = {};
187
+ event.point.lat = [[coords objectForKey:@"lat"] doubleValue];
188
+ event.point.lon = [[coords objectForKey:@"lon"] doubleValue];
189
+ event.zoom = [[coords objectForKey:@"zoom"] doubleValue];
190
+ event.azimuth = [[coords objectForKey:@"azimuth"] doubleValue];
191
+ event.tilt = [[coords objectForKey:@"tilt"] doubleValue];
192
+ event.finished = [[coords objectForKey:@"finished"] boolValue];
193
+ event.target = [[coords objectForKey:@"target"] doubleValue];
194
+
195
+ // Handle reason string - Swift strings bridge to NSString
196
+ id reasonObj = [coords objectForKey:@"reason"];
197
+ NSString *reasonString = @"GESTURES"; // default fallback
198
+ if ([reasonObj isKindOfClass:[NSString class]]) {
199
+ reasonString = (NSString *)reasonObj;
200
+ } else if (reasonObj != nil) {
201
+ // Fallback: try to get string representation
202
+ reasonString = [NSString stringWithFormat:@"%@", reasonObj];
203
+ }
204
+ if ([reasonString isEqualToString:@"APPLICATION"]) {
205
+ event.reason = ClusteredYamapLiteViewEventEmitter::
206
+ OnCameraPositionChangeReason::APPLICATION;
207
+ } else {
208
+ event.reason = ClusteredYamapLiteViewEventEmitter::
209
+ OnCameraPositionChangeReason::GESTURES;
210
+ }
211
+
212
+ std::dynamic_pointer_cast<const ClusteredYamapLiteViewEventEmitter>(
213
+ _eventEmitter)
214
+ ->onCameraPositionChange(event);
215
+ }
216
+ }
217
+
218
+ - (void)handleOnCameraPositionChangeEndWithCoords:
219
+ (NSDictionary<NSString *, id> *)coords {
220
+ if (_eventEmitter != nil) {
221
+ ClusteredYamapLiteViewEventEmitter::OnCameraPositionChangeEnd event = {};
222
+ event.point.lat = [[coords objectForKey:@"lat"] doubleValue];
223
+ event.point.lon = [[coords objectForKey:@"lon"] doubleValue];
224
+ event.zoom = [[coords objectForKey:@"zoom"] doubleValue];
225
+ event.azimuth = [[coords objectForKey:@"azimuth"] doubleValue];
226
+ event.tilt = [[coords objectForKey:@"tilt"] doubleValue];
227
+ event.finished = [[coords objectForKey:@"finished"] boolValue];
228
+ event.target = [[coords objectForKey:@"target"] doubleValue];
229
+
230
+ // Handle reason string - Swift strings bridge to NSString
231
+ id reasonObj = [coords objectForKey:@"reason"];
232
+ NSString *reasonString = @"GESTURES"; // default fallback
233
+ if ([reasonObj isKindOfClass:[NSString class]]) {
234
+ reasonString = (NSString *)reasonObj;
235
+ } else if (reasonObj != nil) {
236
+ // Fallback: try to get string representation
237
+ reasonString = [NSString stringWithFormat:@"%@", reasonObj];
238
+ }
239
+ if ([reasonString isEqualToString:@"APPLICATION"]) {
240
+ event.reason = ClusteredYamapLiteViewEventEmitter::
241
+ OnCameraPositionChangeEndReason::APPLICATION;
242
+ } else {
243
+ event.reason = ClusteredYamapLiteViewEventEmitter::
244
+ OnCameraPositionChangeEndReason::GESTURES;
245
+ }
246
+ std::dynamic_pointer_cast<const ClusteredYamapLiteViewEventEmitter>(
247
+ _eventEmitter)
248
+ ->onCameraPositionChangeEnd(event);
249
+ }
250
+ }
251
+
252
+ - (void)handleOnMapPressWithCoords:(NSDictionary *)coords {
253
+ if (_eventEmitter != nil) {
254
+ ClusteredYamapLiteViewEventEmitter::OnMapPress event = {};
255
+ event.lat = [[coords objectForKey:@"lat"] doubleValue];
256
+ event.lon = [[coords objectForKey:@"lon"] doubleValue];
257
+ std::dynamic_pointer_cast<const ClusteredYamapLiteViewEventEmitter>(
258
+ _eventEmitter)
259
+ ->onMapPress(event);
260
+ }
261
+ }
262
+
263
+ - (void)handleOnMapLongPressWithCoords:(NSDictionary *)coords {
264
+ if (_eventEmitter != nil) {
265
+ ClusteredYamapLiteViewEventEmitter::OnMapLongPress event = {};
266
+ event.lat = [[coords objectForKey:@"lat"] doubleValue];
267
+ event.lon = [[coords objectForKey:@"lon"] doubleValue];
268
+ std::dynamic_pointer_cast<const ClusteredYamapLiteViewEventEmitter>(
269
+ _eventEmitter)
270
+ ->onMapLongPress(event);
271
+ }
272
+ }
273
+
274
+ - (void)mountChildComponentView:
275
+ (nonnull UIView<RCTComponentViewProtocol> *)childComponentView
276
+ index:(NSInteger)index {
277
+ if ([childComponentView isKindOfClass:YamapLiteMarkerView.class]) {
278
+ [_view insertReactSubview:childComponentView atIndex:index];
279
+ }
280
+ if ([childComponentView isKindOfClass:YamapLiteCircleView.class]) {
281
+ [_view insertReactSubview:childComponentView atIndex:index];
282
+ }
283
+ if ([childComponentView isKindOfClass:YamapLitePolygonView.class]) {
284
+ [_view insertReactSubview:childComponentView atIndex:index];
285
+ }
286
+ if ([childComponentView isKindOfClass:YamapLitePolylineView.class]) {
287
+ [_view insertReactSubview:childComponentView atIndex:index];
288
+ }
289
+ }
290
+ - (void)unmountChildComponentView:
291
+ (nonnull UIView<RCTComponentViewProtocol> *)childComponentView
292
+ index:(NSInteger)index {
293
+ if ([childComponentView isKindOfClass:YamapLiteMarkerView.class] ||
294
+ [childComponentView isKindOfClass:YamapLiteCircleView.class] ||
295
+ [childComponentView isKindOfClass:YamapLitePolygonView.class] ||
296
+ [childComponentView isKindOfClass:YamapLitePolylineView.class]) {
297
+ [_view removeReactSubview:childComponentView];
298
+ [childComponentView removeFromSuperview];
299
+ }
300
+ }
301
+
302
+ Class<RCTComponentViewProtocol> ClusteredYamapLiteViewCls(void) {
303
+ return ClusteredYamapLiteView.class;
304
+ }
305
+
306
+ - hexStringToColor:(NSString *)stringToConvert {
307
+ NSString *noHashString =
308
+ [stringToConvert stringByReplacingOccurrencesOfString:@"#"
309
+ withString:@""];
310
+ NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
311
+
312
+ unsigned hex;
313
+ if (![stringScanner scanHexInt:&hex])
314
+ return nil;
315
+ int r = (hex >> 16) & 0xFF;
316
+ int g = (hex >> 8) & 0xFF;
317
+ int b = (hex) & 0xFF;
318
+
319
+ return [UIColor colorWithRed:r / 255.0f
320
+ green:g / 255.0f
321
+ blue:b / 255.0f
322
+ alpha:1.0f];
323
+ }
324
+
325
+ @end
@@ -0,0 +1,17 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <React/RCTUIManager.h>
3
+ #import "RCTBridge.h"
4
+
5
+ @interface ClusteredYamapLiteViewManager : RCTViewManager
6
+ @end
7
+
8
+ @implementation ClusteredYamapLiteViewManager
9
+
10
+ RCT_EXPORT_MODULE(ClusteredYamapLiteView)
11
+
12
+ - (UIView *)view
13
+ {
14
+ return [[UIView alloc] init];
15
+ }
16
+
17
+ @end