@lugg/maps 1.0.0-beta.10 → 1.0.0-beta.12

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.
@@ -4,6 +4,7 @@ import android.content.Context
4
4
  import android.graphics.Bitmap
5
5
  import android.graphics.Canvas
6
6
  import android.view.View
7
+ import android.view.accessibility.AccessibilityEvent
7
8
  import androidx.core.graphics.createBitmap
8
9
  import androidx.core.view.isNotEmpty
9
10
  import com.facebook.react.uimanager.PointerEvents
@@ -53,6 +54,7 @@ class LuggCalloutView(context: Context) : ReactViewGroup(context) {
53
54
 
54
55
  // no-op: avoid accessibility traversal of detached callout children
55
56
  override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
57
+ override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
56
58
 
57
59
  fun createContentBitmap(): Bitmap? {
58
60
  var maxWidth = 0
@@ -3,12 +3,13 @@ package com.luggmaps
3
3
  import android.content.Context
4
4
  import android.graphics.Canvas
5
5
  import android.view.View
6
+ import android.view.accessibility.AccessibilityEvent
6
7
  import androidx.core.graphics.createBitmap
7
8
  import androidx.core.view.isNotEmpty
8
9
  import com.facebook.react.views.view.ReactViewGroup
9
- import com.google.android.gms.maps.model.AdvancedMarker
10
10
  import com.google.android.gms.maps.model.BitmapDescriptor
11
11
  import com.google.android.gms.maps.model.BitmapDescriptorFactory
12
+ import com.google.android.gms.maps.model.Marker
12
13
  import com.luggmaps.events.MarkerDragEvent
13
14
  import com.luggmaps.events.MarkerPressEvent
14
15
  import com.luggmaps.extensions.dispatchEvent
@@ -37,7 +38,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
37
38
  private set
38
39
 
39
40
  var delegate: LuggMarkerViewDelegate? = null
40
- var marker: AdvancedMarker? = null
41
+ var marker: Marker? = null
41
42
 
42
43
  var anchorX: Float = 0.5f
43
44
  private set
@@ -220,6 +221,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
220
221
 
221
222
  // no-op: avoid accessibility traversal of detached marker children
222
223
  override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {}
224
+ override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
223
225
 
224
226
  override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
225
227
  super.onSizeChanged(w, h, oldw, oldh)
@@ -15,8 +15,6 @@ import com.google.android.gms.maps.GoogleMap
15
15
  import com.google.android.gms.maps.GoogleMapOptions
16
16
  import com.google.android.gms.maps.MapView
17
17
  import com.google.android.gms.maps.OnMapReadyCallback
18
- import com.google.android.gms.maps.model.AdvancedMarker
19
- import com.google.android.gms.maps.model.AdvancedMarkerOptions
20
18
  import com.google.android.gms.maps.model.BitmapDescriptorFactory
21
19
  import com.google.android.gms.maps.model.Circle
22
20
  import com.google.android.gms.maps.model.CircleOptions
@@ -26,6 +24,7 @@ import com.google.android.gms.maps.model.LatLng
26
24
  import com.google.android.gms.maps.model.LatLngBounds
27
25
  import com.google.android.gms.maps.model.MapColorScheme
28
26
  import com.google.android.gms.maps.model.Marker
27
+ import com.google.android.gms.maps.model.MarkerOptions
29
28
  import com.google.android.gms.maps.model.Polygon
30
29
  import com.google.android.gms.maps.model.PolygonOptions
31
30
  import com.google.android.gms.maps.model.PolylineOptions
@@ -692,12 +691,12 @@ class GoogleMapProvider(private val context: Context) :
692
691
  val map = googleMap ?: return
693
692
 
694
693
  val position = LatLng(markerView.latitude, markerView.longitude)
695
- val options = AdvancedMarkerOptions()
694
+ val options = MarkerOptions()
696
695
  .position(position)
697
696
  .title(markerView.title)
698
697
  .snippet(markerView.description)
699
698
 
700
- val marker = map.addMarker(options) as AdvancedMarker
699
+ val marker = map.addMarker(options) ?: return
701
700
  marker.setAnchor(markerView.anchorX, markerView.anchorY)
702
701
  marker.zIndex = markerView.zIndex
703
702
  marker.rotation = markerView.rotate
@@ -715,9 +714,8 @@ class GoogleMapProvider(private val context: Context) :
715
714
  }
716
715
  }
717
716
 
718
- // Workaround: AdvancedMarker.iconView is buggy on Android, so we manually add the custom
719
- // content view to the wrapper and position it via screen projection instead. The underlying
720
- // marker uses a transparent bitmap matching the content size so taps still trigger onMarkerClick.
717
+ // Live marker: content view is added to the wrapper and positioned via screen projection.
718
+ // The underlying marker uses a transparent bitmap matching the content size so taps still trigger onMarkerClick.
721
719
  private fun showLiveMarker(markerView: LuggMarkerView) {
722
720
  val wrapper = wrapperView ?: return
723
721
 
@@ -21,12 +21,19 @@ class PolylineAnimator {
21
21
  var polyline: Polyline? = null
22
22
  var coordinates: List<LatLng> = emptyList()
23
23
  set(value) {
24
+ if (field === value) return
24
25
  field = value
26
+ dirty = true
25
27
  if (animated && animator != null) {
26
28
  computeCumulativeDistances()
27
29
  }
28
30
  }
29
31
  var strokeColors: List<Int> = listOf(Color.BLACK)
32
+ set(value) {
33
+ if (field === value) return
34
+ field = value
35
+ dirty = true
36
+ }
30
37
  var strokeWidth: Float = 1f
31
38
  var animatedOptions: AnimatedOptions = AnimatedOptions()
32
39
  set(value) {
@@ -53,6 +60,7 @@ class PolylineAnimator {
53
60
  private var animationProgress: Float = 0f
54
61
  private var cumulativeDistances: FloatArray = floatArrayOf()
55
62
  private var totalLength: Float = 0f
63
+ private var dirty: Boolean = true
56
64
 
57
65
  // Reusable collections to avoid per-frame allocations
58
66
  private val reusablePoints = ArrayList<LatLng>()
@@ -73,14 +81,16 @@ class PolylineAnimator {
73
81
 
74
82
  fun update() {
75
83
  if (animated) return
84
+ if (!dirty) return
76
85
 
77
86
  val poly = polyline ?: return
78
87
  if (coordinates.size < 2) return
79
88
 
89
+ dirty = false
80
90
  poly.points = coordinates
81
91
 
82
92
  if (strokeColors.size > 1) {
83
- poly.setSpans(createGradientSpans())
93
+ applyGradientSpans(poly)
84
94
  } else {
85
95
  poly.color = strokeColors.firstOrNull() ?: Color.BLACK
86
96
  }
@@ -256,15 +266,18 @@ class PolylineAnimator {
256
266
  }
257
267
  }
258
268
 
259
- private fun createGradientSpans(): List<StyleSpan> {
269
+ private fun applyGradientSpans(poly: Polyline) {
260
270
  val segmentCount = coordinates.size - 1
261
271
  val spanCount = min(segmentCount, MAX_GRADIENT_SPANS)
262
272
  val segmentsPerSpan = segmentCount.toDouble() / spanCount
263
- return (0 until spanCount).map { i ->
273
+
274
+ reusableSpans.clear()
275
+ for (i in 0 until spanCount) {
264
276
  val position = (i + 0.5f) / spanCount
265
277
  val color = colorAtGradientPosition(position)
266
- StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan)
278
+ reusableSpans.add(StyleSpan(StrokeStyle.colorBuilder(color).build(), segmentsPerSpan))
267
279
  }
280
+ poly.setSpans(reusableSpans)
268
281
  }
269
282
 
270
283
  private fun colorAtGradientPosition(position: Float): Int {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lugg/maps",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "Universal maps for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",