@lugg/maps 1.0.0-beta.11 → 1.0.0-beta.13
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/LuggMarkerView.kt +2 -2
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +2 -1
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +17 -9
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +1 -1
- package/package.json +1 -1
|
@@ -7,9 +7,9 @@ import android.view.accessibility.AccessibilityEvent
|
|
|
7
7
|
import androidx.core.graphics.createBitmap
|
|
8
8
|
import androidx.core.view.isNotEmpty
|
|
9
9
|
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
-
import com.google.android.gms.maps.model.AdvancedMarker
|
|
11
10
|
import com.google.android.gms.maps.model.BitmapDescriptor
|
|
12
11
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
|
12
|
+
import com.google.android.gms.maps.model.Marker
|
|
13
13
|
import com.luggmaps.events.MarkerDragEvent
|
|
14
14
|
import com.luggmaps.events.MarkerPressEvent
|
|
15
15
|
import com.luggmaps.extensions.dispatchEvent
|
|
@@ -38,7 +38,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
|
|
|
38
38
|
private set
|
|
39
39
|
|
|
40
40
|
var delegate: LuggMarkerViewDelegate? = null
|
|
41
|
-
var marker:
|
|
41
|
+
var marker: Marker? = null
|
|
42
42
|
|
|
43
43
|
var anchorX: Float = 0.5f
|
|
44
44
|
private set
|
|
@@ -8,6 +8,7 @@ import com.google.android.gms.maps.model.Polyline
|
|
|
8
8
|
|
|
9
9
|
interface LuggPolylineViewDelegate {
|
|
10
10
|
fun polylineViewDidUpdate(polylineView: LuggPolylineView)
|
|
11
|
+
fun polylineViewDidDrop(polylineView: LuggPolylineView)
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
data class AnimatedOptions(val duration: Long = 2150L, val easing: String = "linear", val trailLength: Float = 1f, val delay: Long = 0L)
|
|
@@ -67,8 +68,8 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
fun onDropViewInstance() {
|
|
71
|
+
delegate?.polylineViewDidDrop(this)
|
|
70
72
|
delegate = null
|
|
71
|
-
polyline?.remove()
|
|
72
73
|
polyline = null
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -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
|
|
@@ -599,6 +598,10 @@ class GoogleMapProvider(private val context: Context) :
|
|
|
599
598
|
syncPolylineView(polylineView)
|
|
600
599
|
}
|
|
601
600
|
|
|
601
|
+
override fun polylineViewDidDrop(polylineView: LuggPolylineView) {
|
|
602
|
+
teardownPolyline(polylineView)
|
|
603
|
+
}
|
|
604
|
+
|
|
602
605
|
// endregion
|
|
603
606
|
|
|
604
607
|
// region PolygonViewDelegate
|
|
@@ -692,12 +695,12 @@ class GoogleMapProvider(private val context: Context) :
|
|
|
692
695
|
val map = googleMap ?: return
|
|
693
696
|
|
|
694
697
|
val position = LatLng(markerView.latitude, markerView.longitude)
|
|
695
|
-
val options =
|
|
698
|
+
val options = MarkerOptions()
|
|
696
699
|
.position(position)
|
|
697
700
|
.title(markerView.title)
|
|
698
701
|
.snippet(markerView.description)
|
|
699
702
|
|
|
700
|
-
val marker = map.addMarker(options)
|
|
703
|
+
val marker = map.addMarker(options) ?: return
|
|
701
704
|
marker.setAnchor(markerView.anchorX, markerView.anchorY)
|
|
702
705
|
marker.zIndex = markerView.zIndex
|
|
703
706
|
marker.rotation = markerView.rotate
|
|
@@ -715,9 +718,8 @@ class GoogleMapProvider(private val context: Context) :
|
|
|
715
718
|
}
|
|
716
719
|
}
|
|
717
720
|
|
|
718
|
-
//
|
|
719
|
-
//
|
|
720
|
-
// marker uses a transparent bitmap matching the content size so taps still trigger onMarkerClick.
|
|
721
|
+
// Live marker: content view is added to the wrapper and positioned via screen projection.
|
|
722
|
+
// The underlying marker uses a transparent bitmap matching the content size so taps still trigger onMarkerClick.
|
|
721
723
|
private fun showLiveMarker(markerView: LuggMarkerView) {
|
|
722
724
|
val wrapper = wrapperView ?: return
|
|
723
725
|
|
|
@@ -775,8 +777,12 @@ class GoogleMapProvider(private val context: Context) :
|
|
|
775
777
|
}
|
|
776
778
|
|
|
777
779
|
override fun removePolylineView(polylineView: LuggPolylineView) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
+
teardownPolyline(polylineView)
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
private fun teardownPolyline(polylineView: LuggPolylineView) {
|
|
784
|
+
pendingPolylineViews.remove(polylineView)
|
|
785
|
+
polylineAnimators.remove(polylineView)?.destroy()
|
|
780
786
|
polylineView.polyline?.remove()
|
|
781
787
|
polylineView.polyline = null
|
|
782
788
|
}
|
|
@@ -814,6 +820,8 @@ class GoogleMapProvider(private val context: Context) :
|
|
|
814
820
|
private fun addPolylineViewToMap(polylineView: LuggPolylineView) {
|
|
815
821
|
val map = googleMap ?: return
|
|
816
822
|
|
|
823
|
+
polylineAnimators.remove(polylineView)?.destroy()
|
|
824
|
+
|
|
817
825
|
val options = PolylineOptions()
|
|
818
826
|
.width(polylineView.strokeWidth.dpToPx())
|
|
819
827
|
.zIndex(polylineView.zIndex)
|
|
@@ -249,7 +249,7 @@ class PolylineAnimator {
|
|
|
249
249
|
// Clear spans before setting points to prevent IndexOutOfBoundsException
|
|
250
250
|
// when the new points list is shorter than what existing spans reference
|
|
251
251
|
poly.color = strokeColors.firstOrNull() ?: Color.BLACK
|
|
252
|
-
poly.points =
|
|
252
|
+
poly.points = reusablePoints
|
|
253
253
|
|
|
254
254
|
if (strokeColors.size > 1) {
|
|
255
255
|
val segmentCount = reusablePoints.size - 1
|