@lugg/maps 1.0.0-beta.1 → 1.0.0-beta.11

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 (178) hide show
  1. package/README.md +3 -0
  2. package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +9 -2
  3. package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
  4. package/android/src/main/java/com/luggmaps/LuggCircleView.kt +85 -0
  5. package/android/src/main/java/com/luggmaps/LuggCircleViewManager.kt +79 -0
  6. package/android/src/main/java/com/luggmaps/LuggGroundOverlayView.kt +81 -0
  7. package/android/src/main/java/com/luggmaps/LuggGroundOverlayViewManager.kt +82 -0
  8. package/android/src/main/java/com/luggmaps/LuggMapView.kt +49 -0
  9. package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
  10. package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +28 -0
  11. package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
  12. package/android/src/main/java/com/luggmaps/LuggPackage.kt +4 -1
  13. package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +1 -22
  14. package/android/src/main/java/com/luggmaps/LuggTileOverlayView.kt +92 -0
  15. package/android/src/main/java/com/luggmaps/LuggTileOverlayViewManager.kt +80 -0
  16. package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +451 -17
  17. package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +14 -0
  18. package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +27 -9
  19. package/android/src/main/java/com/luggmaps/events/CirclePressEvent.kt +12 -0
  20. package/android/src/main/java/com/luggmaps/events/GroundOverlayPressEvent.kt +12 -0
  21. package/android/src/main/java/com/luggmaps/events/TileOverlayPressEvent.kt +12 -0
  22. package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
  23. package/ios/LuggCalloutView.h +1 -1
  24. package/ios/LuggCalloutView.mm +21 -11
  25. package/ios/LuggCircleView.h +31 -0
  26. package/ios/LuggCircleView.mm +133 -0
  27. package/ios/LuggGroundOverlayView.h +30 -0
  28. package/ios/LuggGroundOverlayView.mm +125 -0
  29. package/ios/LuggMapView.mm +84 -2
  30. package/ios/LuggMarkerView.h +3 -0
  31. package/ios/LuggMarkerView.mm +23 -0
  32. package/ios/LuggTileOverlayView.h +31 -0
  33. package/ios/LuggTileOverlayView.mm +130 -0
  34. package/ios/core/AppleMapProvider.mm +697 -37
  35. package/ios/core/GMSPolylineAnimator.m +6 -3
  36. package/ios/core/GoogleMapProvider.mm +400 -22
  37. package/ios/core/MapProviderDelegate.h +20 -1
  38. package/ios/events/CirclePressEvent.h +20 -0
  39. package/ios/events/GroundOverlayPressEvent.h +20 -0
  40. package/ios/events/TileOverlayPressEvent.h +20 -0
  41. package/lib/module/MapProvider.web.js +4 -1
  42. package/lib/module/MapProvider.web.js.map +1 -1
  43. package/lib/module/MapView.js +12 -1
  44. package/lib/module/MapView.js.map +1 -1
  45. package/lib/module/MapView.web.js +21 -18
  46. package/lib/module/MapView.web.js.map +1 -1
  47. package/lib/module/components/Circle.js +46 -0
  48. package/lib/module/components/Circle.js.map +1 -0
  49. package/lib/module/components/Circle.types.js +4 -0
  50. package/lib/module/components/Circle.types.js.map +1 -0
  51. package/lib/module/components/Circle.web.js +79 -0
  52. package/lib/module/components/Circle.web.js.map +1 -0
  53. package/lib/module/components/GeoJson.js +3 -3
  54. package/lib/module/components/GeoJson.js.map +1 -1
  55. package/lib/module/components/GroundOverlay.js +45 -0
  56. package/lib/module/components/GroundOverlay.js.map +1 -0
  57. package/lib/module/components/GroundOverlay.types.js +4 -0
  58. package/lib/module/components/GroundOverlay.types.js.map +1 -0
  59. package/lib/module/components/GroundOverlay.web.js +77 -0
  60. package/lib/module/components/GroundOverlay.web.js.map +1 -0
  61. package/lib/module/components/Marker.js +22 -4
  62. package/lib/module/components/Marker.js.map +1 -1
  63. package/lib/module/components/Marker.web.js +23 -10
  64. package/lib/module/components/Marker.web.js.map +1 -1
  65. package/lib/module/components/Polygon.web.js +3 -3
  66. package/lib/module/components/Polygon.web.js.map +1 -1
  67. package/lib/module/components/Polyline.web.js +6 -12
  68. package/lib/module/components/Polyline.web.js.map +1 -1
  69. package/lib/module/components/TileOverlay.js +44 -0
  70. package/lib/module/components/TileOverlay.js.map +1 -0
  71. package/lib/module/components/TileOverlay.types.js +4 -0
  72. package/lib/module/components/TileOverlay.types.js.map +1 -0
  73. package/lib/module/components/TileOverlay.web.js +69 -0
  74. package/lib/module/components/TileOverlay.web.js.map +1 -0
  75. package/lib/module/components/index.js +3 -0
  76. package/lib/module/components/index.js.map +1 -1
  77. package/lib/module/components/index.web.js +3 -0
  78. package/lib/module/components/index.web.js.map +1 -1
  79. package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  80. package/lib/module/fabric/LuggCircleViewNativeComponent.ts +25 -0
  81. package/lib/module/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
  82. package/lib/module/fabric/LuggMapViewNativeComponent.ts +13 -5
  83. package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  84. package/lib/module/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
  85. package/lib/module/index.js +3 -0
  86. package/lib/module/index.js.map +1 -1
  87. package/lib/module/index.web.js +3 -0
  88. package/lib/module/index.web.js.map +1 -1
  89. package/lib/typescript/src/MapProvider.web.d.ts +3 -2
  90. package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
  91. package/lib/typescript/src/MapView.d.ts +1 -1
  92. package/lib/typescript/src/MapView.d.ts.map +1 -1
  93. package/lib/typescript/src/MapView.types.d.ts +36 -1
  94. package/lib/typescript/src/MapView.types.d.ts.map +1 -1
  95. package/lib/typescript/src/MapView.web.d.ts +1 -1
  96. package/lib/typescript/src/MapView.web.d.ts.map +1 -1
  97. package/lib/typescript/src/components/Circle.d.ts +10 -0
  98. package/lib/typescript/src/components/Circle.d.ts.map +1 -0
  99. package/lib/typescript/src/components/Circle.types.d.ts +33 -0
  100. package/lib/typescript/src/components/Circle.types.d.ts.map +1 -0
  101. package/lib/typescript/src/components/Circle.web.d.ts +3 -0
  102. package/lib/typescript/src/components/Circle.web.d.ts.map +1 -0
  103. package/lib/typescript/src/components/GeoJson.d.ts +2 -1
  104. package/lib/typescript/src/components/GeoJson.d.ts.map +1 -1
  105. package/lib/typescript/src/components/GroundOverlay.d.ts +10 -0
  106. package/lib/typescript/src/components/GroundOverlay.d.ts.map +1 -0
  107. package/lib/typescript/src/components/GroundOverlay.types.d.ts +35 -0
  108. package/lib/typescript/src/components/GroundOverlay.types.d.ts.map +1 -0
  109. package/lib/typescript/src/components/GroundOverlay.web.d.ts +3 -0
  110. package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -0
  111. package/lib/typescript/src/components/Marker.d.ts +6 -3
  112. package/lib/typescript/src/components/Marker.d.ts.map +1 -1
  113. package/lib/typescript/src/components/Marker.types.d.ts +18 -6
  114. package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
  115. package/lib/typescript/src/components/Marker.web.d.ts +3 -2
  116. package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
  117. package/lib/typescript/src/components/Polygon.web.d.ts +1 -1
  118. package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -1
  119. package/lib/typescript/src/components/Polyline.web.d.ts +1 -1
  120. package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
  121. package/lib/typescript/src/components/TileOverlay.d.ts +10 -0
  122. package/lib/typescript/src/components/TileOverlay.d.ts.map +1 -0
  123. package/lib/typescript/src/components/TileOverlay.types.d.ts +36 -0
  124. package/lib/typescript/src/components/TileOverlay.types.d.ts.map +1 -0
  125. package/lib/typescript/src/components/TileOverlay.web.d.ts +3 -0
  126. package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -0
  127. package/lib/typescript/src/components/index.d.ts +7 -1
  128. package/lib/typescript/src/components/index.d.ts.map +1 -1
  129. package/lib/typescript/src/components/index.web.d.ts +6 -0
  130. package/lib/typescript/src/components/index.web.d.ts.map +1 -1
  131. package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
  132. package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts +18 -0
  133. package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts.map +1 -0
  134. package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts +21 -0
  135. package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts.map +1 -0
  136. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +10 -5
  137. package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
  138. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
  139. package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
  140. package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts +21 -0
  141. package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts.map +1 -0
  142. package/lib/typescript/src/index.d.ts +9 -3
  143. package/lib/typescript/src/index.d.ts.map +1 -1
  144. package/lib/typescript/src/index.web.d.ts +7 -1
  145. package/lib/typescript/src/index.web.d.ts.map +1 -1
  146. package/lib/typescript/src/types.d.ts +0 -4
  147. package/lib/typescript/src/types.d.ts.map +1 -1
  148. package/package.json +5 -2
  149. package/src/MapProvider.web.tsx +5 -3
  150. package/src/MapView.tsx +12 -1
  151. package/src/MapView.types.ts +118 -1
  152. package/src/MapView.web.tsx +378 -345
  153. package/src/components/Circle.tsx +52 -0
  154. package/src/components/Circle.types.ts +33 -0
  155. package/src/components/Circle.web.tsx +95 -0
  156. package/src/components/GeoJson.tsx +3 -3
  157. package/src/components/GroundOverlay.tsx +47 -0
  158. package/src/components/GroundOverlay.types.ts +36 -0
  159. package/src/components/GroundOverlay.web.tsx +81 -0
  160. package/src/components/Marker.tsx +32 -6
  161. package/src/components/Marker.types.ts +19 -6
  162. package/src/components/Marker.web.tsx +196 -150
  163. package/src/components/Polygon.web.tsx +93 -89
  164. package/src/components/Polyline.web.tsx +235 -235
  165. package/src/components/TileOverlay.tsx +44 -0
  166. package/src/components/TileOverlay.types.ts +37 -0
  167. package/src/components/TileOverlay.web.tsx +97 -0
  168. package/src/components/index.ts +10 -0
  169. package/src/components/index.web.ts +9 -0
  170. package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
  171. package/src/fabric/LuggCircleViewNativeComponent.ts +25 -0
  172. package/src/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
  173. package/src/fabric/LuggMapViewNativeComponent.ts +13 -5
  174. package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
  175. package/src/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
  176. package/src/index.ts +12 -1
  177. package/src/index.web.ts +15 -0
  178. package/src/types.ts +0 -5
@@ -1,9 +1,12 @@
1
1
  package com.luggmaps.core
2
2
 
3
3
  import android.view.View
4
+ import com.luggmaps.LuggCircleView
5
+ import com.luggmaps.LuggGroundOverlayView
4
6
  import com.luggmaps.LuggMarkerView
5
7
  import com.luggmaps.LuggPolygonView
6
8
  import com.luggmaps.LuggPolylineView
9
+ import com.luggmaps.LuggTileOverlayView
7
10
 
8
11
  data class EdgeInsets(val top: Int = 0, val left: Int = 0, val bottom: Int = 0, val right: Int = 0)
9
12
 
@@ -29,11 +32,16 @@ interface MapProvider {
29
32
  fun setPitchEnabled(enabled: Boolean)
30
33
  fun setUserLocationEnabled(enabled: Boolean)
31
34
  fun setUserLocationButtonEnabled(enabled: Boolean)
35
+ fun setMapType(value: String)
32
36
  fun setTheme(value: String)
33
37
  fun setMinZoom(zoom: Double)
34
38
  fun setMaxZoom(zoom: Double)
35
39
  fun setEdgeInsets(edgeInsets: EdgeInsets)
36
40
  fun setEdgeInsets(edgeInsets: EdgeInsets, duration: Int)
41
+ fun setInsetAdjustment(value: String)
42
+ fun setPoiEnabled(enabled: Boolean)
43
+ fun setPoiFilterMode(mode: String)
44
+ fun setPoiFilterCategories(categories: List<String>)
37
45
 
38
46
  // Children
39
47
  fun addMarkerView(markerView: LuggMarkerView)
@@ -42,6 +50,12 @@ interface MapProvider {
42
50
  fun removePolylineView(polylineView: LuggPolylineView)
43
51
  fun addPolygonView(polygonView: LuggPolygonView)
44
52
  fun removePolygonView(polygonView: LuggPolygonView)
53
+ fun addCircleView(circleView: LuggCircleView)
54
+ fun removeCircleView(circleView: LuggCircleView)
55
+ fun addGroundOverlayView(groundOverlayView: LuggGroundOverlayView)
56
+ fun removeGroundOverlayView(groundOverlayView: LuggGroundOverlayView)
57
+ fun addTileOverlayView(tileOverlayView: LuggTileOverlayView)
58
+ fun removeTileOverlayView(tileOverlayView: LuggTileOverlayView)
45
59
 
46
60
  // Lifecycle
47
61
  fun pauseAnimations()
@@ -15,17 +15,25 @@ import kotlin.math.min
15
15
  class PolylineAnimator {
16
16
  companion object {
17
17
  private const val MAX_ANIMATION_SPANS = 16
18
+ private const val MAX_GRADIENT_SPANS = 512
18
19
  }
19
20
 
20
21
  var polyline: Polyline? = null
21
22
  var coordinates: List<LatLng> = emptyList()
22
23
  set(value) {
24
+ if (field === value) return
23
25
  field = value
26
+ dirty = true
24
27
  if (animated && animator != null) {
25
28
  computeCumulativeDistances()
26
29
  }
27
30
  }
28
31
  var strokeColors: List<Int> = listOf(Color.BLACK)
32
+ set(value) {
33
+ if (field === value) return
34
+ field = value
35
+ dirty = true
36
+ }
29
37
  var strokeWidth: Float = 1f
30
38
  var animatedOptions: AnimatedOptions = AnimatedOptions()
31
39
  set(value) {
@@ -52,6 +60,7 @@ class PolylineAnimator {
52
60
  private var animationProgress: Float = 0f
53
61
  private var cumulativeDistances: FloatArray = floatArrayOf()
54
62
  private var totalLength: Float = 0f
63
+ private var dirty: Boolean = true
55
64
 
56
65
  // Reusable collections to avoid per-frame allocations
57
66
  private val reusablePoints = ArrayList<LatLng>()
@@ -72,14 +81,16 @@ class PolylineAnimator {
72
81
 
73
82
  fun update() {
74
83
  if (animated) return
84
+ if (!dirty) return
75
85
 
76
86
  val poly = polyline ?: return
77
87
  if (coordinates.size < 2) return
78
88
 
89
+ dirty = false
79
90
  poly.points = coordinates
80
91
 
81
92
  if (strokeColors.size > 1) {
82
- poly.setSpans(createGradientSpans())
93
+ applyGradientSpans(poly)
83
94
  } else {
84
95
  poly.color = strokeColors.firstOrNull() ?: Color.BLACK
85
96
  }
@@ -209,8 +220,9 @@ class PolylineAnimator {
209
220
  }
210
221
 
211
222
  if (headDist <= tailDist) {
212
- poly.points = listOf(coordinates.firstOrNull() ?: LatLng(0.0, 0.0))
223
+ val point = coordinates.firstOrNull() ?: LatLng(0.0, 0.0)
213
224
  poly.color = strokeColors.firstOrNull() ?: Color.BLACK
225
+ poly.points = listOf(point, point)
214
226
  return
215
227
  }
216
228
 
@@ -234,11 +246,12 @@ class PolylineAnimator {
234
246
 
235
247
  if (reusablePoints.size < 2) return
236
248
 
249
+ // Clear spans before setting points to prevent IndexOutOfBoundsException
250
+ // when the new points list is shorter than what existing spans reference
251
+ poly.color = strokeColors.firstOrNull() ?: Color.BLACK
237
252
  poly.points = ArrayList(reusablePoints)
238
253
 
239
- if (strokeColors.size <= 1) {
240
- poly.color = strokeColors.firstOrNull() ?: Color.BLACK
241
- } else {
254
+ if (strokeColors.size > 1) {
242
255
  val segmentCount = reusablePoints.size - 1
243
256
  val spanCount = min(segmentCount, MAX_ANIMATION_SPANS)
244
257
  val segmentsPerSpan = segmentCount.toDouble() / spanCount
@@ -253,13 +266,18 @@ class PolylineAnimator {
253
266
  }
254
267
  }
255
268
 
256
- private fun createGradientSpans(): List<StyleSpan> {
269
+ private fun applyGradientSpans(poly: Polyline) {
257
270
  val segmentCount = coordinates.size - 1
258
- return (0 until segmentCount).map { i ->
259
- val position = i.toFloat() / segmentCount
271
+ val spanCount = min(segmentCount, MAX_GRADIENT_SPANS)
272
+ val segmentsPerSpan = segmentCount.toDouble() / spanCount
273
+
274
+ reusableSpans.clear()
275
+ for (i in 0 until spanCount) {
276
+ val position = (i + 0.5f) / spanCount
260
277
  val color = colorAtGradientPosition(position)
261
- StyleSpan(StrokeStyle.colorBuilder(color).build())
278
+ reusableSpans.add(StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan))
262
279
  }
280
+ poly.setSpans(reusableSpans)
263
281
  }
264
282
 
265
283
  private fun colorAtGradientPosition(position: Float): Int {
@@ -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 CirclePressEvent(view: View) : Event<CirclePressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
9
+ override fun getEventName() = "topCirclePress"
10
+
11
+ override fun getEventData() = Arguments.createMap()
12
+ }
@@ -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 GroundOverlayPressEvent(view: View) : Event<GroundOverlayPressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
9
+ override fun getEventName() = "topGroundOverlayPress"
10
+
11
+ override fun getEventData() = Arguments.createMap()
12
+ }
@@ -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 TileOverlayPressEvent(view: View) : Event<TileOverlayPressEvent>(UIManagerHelper.getSurfaceId(view), view.id) {
9
+ override fun getEventName() = "topTileOverlayPress"
10
+
11
+ override fun getEventData() = Arguments.createMap()
12
+ }
@@ -1,6 +1,7 @@
1
1
  package com.luggmaps.extensions
2
2
 
3
3
  import android.view.View
4
+ import android.view.ViewGroup
4
5
  import com.facebook.react.uimanager.ThemedReactContext
5
6
  import com.facebook.react.uimanager.UIManagerHelper
6
7
  import com.facebook.react.uimanager.events.Event
@@ -12,3 +13,13 @@ fun View.dispatchEvent(event: Event<*>) {
12
13
  )
13
14
  eventDispatcher?.dispatchEvent(event)
14
15
  }
16
+
17
+ fun View.findViewByTag(tag: String): View? {
18
+ if (this.tag?.toString() == tag) return this
19
+ if (this !is ViewGroup) return null
20
+ for (i in 0 until childCount) {
21
+ val found = getChildAt(i).findViewByTag(tag)
22
+ if (found != null) return found
23
+ }
24
+ return null
25
+ }
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
13
13
  @interface LuggCalloutView : RCTViewComponentView
14
14
 
15
15
  @property(nonatomic, readonly) BOOL bubbled;
16
- @property(nonatomic, readonly) CGPoint anchor;
16
+ @property(nonatomic, readonly) CGPoint offset;
17
17
  @property(nonatomic, readonly) BOOL hasCustomContent;
18
18
  @property(nonatomic, readonly) UIView *contentView;
19
19
  @property(nonatomic, weak, nullable) id<LuggCalloutViewDelegate> delegate;
@@ -43,7 +43,7 @@ using namespace facebook::react;
43
43
  @implementation LuggCalloutView {
44
44
  LuggCalloutContentView *_contentView;
45
45
  BOOL _bubbled;
46
- CGPoint _anchor;
46
+ CGPoint _offset;
47
47
  }
48
48
 
49
49
  + (ComponentDescriptorProvider)componentDescriptorProvider {
@@ -58,7 +58,7 @@ using namespace facebook::react;
58
58
  _props = defaultProps;
59
59
 
60
60
  _bubbled = YES;
61
- _anchor = CGPointMake(0.5, 1.0);
61
+ _offset = CGPointZero;
62
62
  _contentView = [[LuggCalloutContentView alloc] init];
63
63
  _contentView.backgroundColor = [UIColor clearColor];
64
64
 
@@ -74,29 +74,39 @@ using namespace facebook::react;
74
74
  const auto &newViewProps =
75
75
  *std::static_pointer_cast<LuggCalloutViewProps const>(props);
76
76
 
77
- _bubbled = newViewProps.bubbled;
77
+ BOOL changed = NO;
78
+
79
+ if (_bubbled != newViewProps.bubbled) {
80
+ _bubbled = newViewProps.bubbled;
81
+ changed = YES;
82
+ }
78
83
 
79
84
  if (oldProps) {
80
85
  const auto &oldViewProps =
81
86
  *std::static_pointer_cast<LuggCalloutViewProps const>(oldProps);
82
- if (newViewProps.anchor.x != oldViewProps.anchor.x ||
83
- newViewProps.anchor.y != oldViewProps.anchor.y) {
84
- _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
87
+ if (newViewProps.offset.x != oldViewProps.offset.x ||
88
+ newViewProps.offset.y != oldViewProps.offset.y) {
89
+ _offset = CGPointMake(newViewProps.offset.x, newViewProps.offset.y);
90
+ changed = YES;
85
91
  }
86
- } else if (newViewProps.anchor.x != 0 || newViewProps.anchor.y != 0) {
87
- _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
92
+ } else if (newViewProps.offset.x != 0 || newViewProps.offset.y != 0) {
93
+ _offset = CGPointMake(newViewProps.offset.x, newViewProps.offset.y);
94
+ changed = YES;
88
95
  }
89
96
 
90
97
  [super updateProps:props oldProps:oldProps];
91
- [_delegate calloutViewDidUpdate:self];
98
+
99
+ if (changed) {
100
+ [_delegate calloutViewDidUpdate:self];
101
+ }
92
102
  }
93
103
 
94
104
  - (BOOL)bubbled {
95
105
  return _bubbled;
96
106
  }
97
107
 
98
- - (CGPoint)anchor {
99
- return _anchor;
108
+ - (CGPoint)offset {
109
+ return _offset;
100
110
  }
101
111
 
102
112
  - (void)mountChildComponentView:
@@ -0,0 +1,31 @@
1
+ #import <CoreLocation/CoreLocation.h>
2
+ #import <React/RCTViewComponentView.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ NS_ASSUME_NONNULL_BEGIN
6
+
7
+ @class LuggCircleView;
8
+
9
+ @protocol LuggCircleViewDelegate <NSObject>
10
+ @optional
11
+ - (void)circleViewDidUpdate:(LuggCircleView *)circleView;
12
+ @end
13
+
14
+ @interface LuggCircleView : RCTViewComponentView
15
+
16
+ @property(nonatomic, readonly) CLLocationCoordinate2D center;
17
+ @property(nonatomic, readonly) CLLocationDistance radius;
18
+ @property(nonatomic, readonly) UIColor *strokeColor;
19
+ @property(nonatomic, readonly) UIColor *fillColor;
20
+ @property(nonatomic, readonly) CGFloat strokeWidth;
21
+ @property(nonatomic, readonly) NSInteger zIndex;
22
+ @property(nonatomic, readonly) BOOL tappable;
23
+ @property(nonatomic, weak, nullable) id<LuggCircleViewDelegate> delegate;
24
+ @property(nonatomic, strong, nullable) NSObject *circle;
25
+ @property(nonatomic, weak, nullable) NSObject *renderer;
26
+
27
+ - (void)emitPressEvent;
28
+
29
+ @end
30
+
31
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,133 @@
1
+ #import "LuggCircleView.h"
2
+ #import "events/CirclePressEvent.h"
3
+
4
+ #import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
5
+ #import <react/renderer/components/RNMapsSpec/EventEmitters.h>
6
+ #import <react/renderer/components/RNMapsSpec/Props.h>
7
+ #import <react/renderer/components/RNMapsSpec/RCTComponentViewHelpers.h>
8
+
9
+ #import "RCTFabricComponentsPlugins.h"
10
+ #import <React/RCTConversions.h>
11
+
12
+ using namespace facebook::react;
13
+ using namespace luggmaps::events;
14
+
15
+ @interface LuggCircleView () <RCTLuggCircleViewViewProtocol>
16
+ @end
17
+
18
+ @implementation LuggCircleView {
19
+ CLLocationCoordinate2D _center;
20
+ CLLocationDistance _radius;
21
+ UIColor *_strokeColor;
22
+ UIColor *_fillColor;
23
+ CGFloat _strokeWidth;
24
+ NSInteger _zIndex;
25
+ BOOL _tappable;
26
+ }
27
+
28
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
29
+ return concreteComponentDescriptorProvider<
30
+ LuggCircleViewComponentDescriptor>();
31
+ }
32
+
33
+ - (instancetype)initWithFrame:(CGRect)frame {
34
+ if (self = [super initWithFrame:frame]) {
35
+ static const auto defaultProps =
36
+ std::make_shared<const LuggCircleViewProps>();
37
+ _props = defaultProps;
38
+
39
+ _center = CLLocationCoordinate2DMake(0, 0);
40
+ _radius = 0;
41
+ _strokeColor = [UIColor blackColor];
42
+ _fillColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
43
+ _strokeWidth = 1.0;
44
+
45
+ self.hidden = YES;
46
+ }
47
+
48
+ return self;
49
+ }
50
+
51
+ - (void)updateProps:(Props::Shared const &)props
52
+ oldProps:(Props::Shared const &)oldProps {
53
+ [super updateProps:props oldProps:oldProps];
54
+ const auto &newViewProps =
55
+ *std::static_pointer_cast<LuggCircleViewProps const>(props);
56
+
57
+ _center = CLLocationCoordinate2DMake(newViewProps.center.latitude,
58
+ newViewProps.center.longitude);
59
+ _radius = newViewProps.radius;
60
+
61
+ if (newViewProps.strokeColor) {
62
+ UIColor *color = RCTUIColorFromSharedColor(newViewProps.strokeColor);
63
+ if (color) {
64
+ _strokeColor = color;
65
+ }
66
+ }
67
+
68
+ if (newViewProps.fillColor) {
69
+ UIColor *color = RCTUIColorFromSharedColor(newViewProps.fillColor);
70
+ if (color) {
71
+ _fillColor = color;
72
+ }
73
+ }
74
+
75
+ _strokeWidth = newViewProps.strokeWidth > 0 ? newViewProps.strokeWidth : 1.0;
76
+ _zIndex = newViewProps.zIndex.value_or(0);
77
+ _tappable = newViewProps.tappable;
78
+ }
79
+
80
+ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
81
+ [super finalizeUpdates:updateMask];
82
+
83
+ if (updateMask & RNComponentViewUpdateMaskProps) {
84
+ if ([self.delegate respondsToSelector:@selector(circleViewDidUpdate:)]) {
85
+ [self.delegate circleViewDidUpdate:self];
86
+ }
87
+ }
88
+ }
89
+
90
+ - (CLLocationCoordinate2D)center {
91
+ return _center;
92
+ }
93
+
94
+ - (CLLocationDistance)radius {
95
+ return _radius;
96
+ }
97
+
98
+ - (UIColor *)strokeColor {
99
+ return _strokeColor;
100
+ }
101
+
102
+ - (UIColor *)fillColor {
103
+ return _fillColor;
104
+ }
105
+
106
+ - (CGFloat)strokeWidth {
107
+ return _strokeWidth;
108
+ }
109
+
110
+ - (NSInteger)zIndex {
111
+ return _zIndex;
112
+ }
113
+
114
+ - (BOOL)tappable {
115
+ return _tappable;
116
+ }
117
+
118
+ - (void)emitPressEvent {
119
+ CirclePressEvent::emit<LuggCircleViewEventEmitter>(_eventEmitter);
120
+ }
121
+
122
+ - (void)prepareForRecycle {
123
+ [super prepareForRecycle];
124
+ self.circle = nil;
125
+ self.renderer = nil;
126
+ self.delegate = nil;
127
+ }
128
+
129
+ Class<RCTComponentViewProtocol> LuggCircleViewCls(void) {
130
+ return LuggCircleView.class;
131
+ }
132
+
133
+ @end
@@ -0,0 +1,30 @@
1
+ #import <CoreLocation/CoreLocation.h>
2
+ #import <React/RCTViewComponentView.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ NS_ASSUME_NONNULL_BEGIN
6
+
7
+ @class LuggGroundOverlayView;
8
+
9
+ @protocol LuggGroundOverlayViewDelegate <NSObject>
10
+ @optional
11
+ - (void)groundOverlayViewDidUpdate:(LuggGroundOverlayView *)groundOverlayView;
12
+ @end
13
+
14
+ @interface LuggGroundOverlayView : RCTViewComponentView
15
+
16
+ @property(nonatomic, readonly) NSString *imageUri;
17
+ @property(nonatomic, readonly) CLLocationCoordinate2D northeast;
18
+ @property(nonatomic, readonly) CLLocationCoordinate2D southwest;
19
+ @property(nonatomic, readonly) CGFloat opacity;
20
+ @property(nonatomic, readonly) CGFloat bearing;
21
+ @property(nonatomic, readonly) NSInteger zIndex;
22
+ @property(nonatomic, readonly) BOOL tappable;
23
+ @property(nonatomic, weak, nullable) id<LuggGroundOverlayViewDelegate> delegate;
24
+ @property(nonatomic, strong, nullable) NSObject *overlay;
25
+
26
+ - (void)emitPressEvent;
27
+
28
+ @end
29
+
30
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,125 @@
1
+ #import "LuggGroundOverlayView.h"
2
+ #import "events/GroundOverlayPressEvent.h"
3
+
4
+ #import <react/renderer/components/RNMapsSpec/ComponentDescriptors.h>
5
+ #import <react/renderer/components/RNMapsSpec/EventEmitters.h>
6
+ #import <react/renderer/components/RNMapsSpec/Props.h>
7
+ #import <react/renderer/components/RNMapsSpec/RCTComponentViewHelpers.h>
8
+
9
+ #import "RCTFabricComponentsPlugins.h"
10
+
11
+ using namespace facebook::react;
12
+ using namespace luggmaps::events;
13
+
14
+ @interface LuggGroundOverlayView () <RCTLuggGroundOverlayViewViewProtocol>
15
+ @end
16
+
17
+ @implementation LuggGroundOverlayView {
18
+ NSString *_imageUri;
19
+ CLLocationCoordinate2D _northeast;
20
+ CLLocationCoordinate2D _southwest;
21
+ CGFloat _opacity;
22
+ CGFloat _bearing;
23
+ NSInteger _zIndex;
24
+ BOOL _tappable;
25
+ }
26
+
27
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
28
+ return concreteComponentDescriptorProvider<
29
+ LuggGroundOverlayViewComponentDescriptor>();
30
+ }
31
+
32
+ - (instancetype)initWithFrame:(CGRect)frame {
33
+ if (self = [super initWithFrame:frame]) {
34
+ static const auto defaultProps =
35
+ std::make_shared<const LuggGroundOverlayViewProps>();
36
+ _props = defaultProps;
37
+
38
+ _imageUri = @"";
39
+ _northeast = CLLocationCoordinate2DMake(0, 0);
40
+ _southwest = CLLocationCoordinate2DMake(0, 0);
41
+ _opacity = 1.0;
42
+ _bearing = 0.0;
43
+
44
+ self.hidden = YES;
45
+ }
46
+
47
+ return self;
48
+ }
49
+
50
+ - (void)updateProps:(Props::Shared const &)props
51
+ oldProps:(Props::Shared const &)oldProps {
52
+ [super updateProps:props oldProps:oldProps];
53
+ const auto &newViewProps =
54
+ *std::static_pointer_cast<LuggGroundOverlayViewProps const>(props);
55
+
56
+ _imageUri = [NSString stringWithUTF8String:newViewProps.image.c_str()];
57
+
58
+ _northeast =
59
+ CLLocationCoordinate2DMake(newViewProps.bounds.northeast.latitude,
60
+ newViewProps.bounds.northeast.longitude);
61
+ _southwest =
62
+ CLLocationCoordinate2DMake(newViewProps.bounds.southwest.latitude,
63
+ newViewProps.bounds.southwest.longitude);
64
+
65
+ _opacity = newViewProps.opacity;
66
+ _bearing = newViewProps.bearing;
67
+ _zIndex = newViewProps.zIndex.value_or(0);
68
+ _tappable = newViewProps.tappable;
69
+ }
70
+
71
+ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
72
+ [super finalizeUpdates:updateMask];
73
+
74
+ if (updateMask & RNComponentViewUpdateMaskProps) {
75
+ if ([self.delegate
76
+ respondsToSelector:@selector(groundOverlayViewDidUpdate:)]) {
77
+ [self.delegate groundOverlayViewDidUpdate:self];
78
+ }
79
+ }
80
+ }
81
+
82
+ - (NSString *)imageUri {
83
+ return _imageUri;
84
+ }
85
+
86
+ - (CLLocationCoordinate2D)northeast {
87
+ return _northeast;
88
+ }
89
+
90
+ - (CLLocationCoordinate2D)southwest {
91
+ return _southwest;
92
+ }
93
+
94
+ - (CGFloat)opacity {
95
+ return _opacity;
96
+ }
97
+
98
+ - (CGFloat)bearing {
99
+ return _bearing;
100
+ }
101
+
102
+ - (NSInteger)zIndex {
103
+ return _zIndex;
104
+ }
105
+
106
+ - (BOOL)tappable {
107
+ return _tappable;
108
+ }
109
+
110
+ - (void)emitPressEvent {
111
+ GroundOverlayPressEvent::emit<LuggGroundOverlayViewEventEmitter>(
112
+ _eventEmitter);
113
+ }
114
+
115
+ - (void)prepareForRecycle {
116
+ [super prepareForRecycle];
117
+ self.overlay = nil;
118
+ self.delegate = nil;
119
+ }
120
+
121
+ Class<RCTComponentViewProtocol> LuggGroundOverlayViewCls(void) {
122
+ return LuggGroundOverlayView.class;
123
+ }
124
+
125
+ @end