Skip to content

Commit bc1b1db

Browse files
authored
refactor(android): use regular Marker instead of AdvancedMarker (#71)
* refactor(android): use regular Marker instead of AdvancedMarker iconView is no longer used, so the AdvancedMarker variant is unnecessary. * chore: update clean script
1 parent e02718e commit bc1b1db

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

android/src/main/java/com/luggmaps/LuggMarkerView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import android.view.accessibility.AccessibilityEvent
77
import androidx.core.graphics.createBitmap
88
import androidx.core.view.isNotEmpty
99
import com.facebook.react.views.view.ReactViewGroup
10-
import com.google.android.gms.maps.model.AdvancedMarker
1110
import com.google.android.gms.maps.model.BitmapDescriptor
1211
import com.google.android.gms.maps.model.BitmapDescriptorFactory
12+
import com.google.android.gms.maps.model.Marker
1313
import com.luggmaps.events.MarkerDragEvent
1414
import com.luggmaps.events.MarkerPressEvent
1515
import com.luggmaps.extensions.dispatchEvent
@@ -38,7 +38,7 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
3838
private set
3939

4040
var delegate: LuggMarkerViewDelegate? = null
41-
var marker: AdvancedMarker? = null
41+
var marker: Marker? = null
4242

4343
var anchorX: Float = 0.5f
4444
private set

android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import com.google.android.gms.maps.GoogleMap
1515
import com.google.android.gms.maps.GoogleMapOptions
1616
import com.google.android.gms.maps.MapView
1717
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
2018
import com.google.android.gms.maps.model.BitmapDescriptorFactory
2119
import com.google.android.gms.maps.model.Circle
2220
import com.google.android.gms.maps.model.CircleOptions
@@ -26,6 +24,7 @@ import com.google.android.gms.maps.model.LatLng
2624
import com.google.android.gms.maps.model.LatLngBounds
2725
import com.google.android.gms.maps.model.MapColorScheme
2826
import com.google.android.gms.maps.model.Marker
27+
import com.google.android.gms.maps.model.MarkerOptions
2928
import com.google.android.gms.maps.model.Polygon
3029
import com.google.android.gms.maps.model.PolygonOptions
3130
import com.google.android.gms.maps.model.PolylineOptions
@@ -692,12 +691,12 @@ class GoogleMapProvider(private val context: Context) :
692691
val map = googleMap ?: return
693692

694693
val position = LatLng(markerView.latitude, markerView.longitude)
695-
val options = AdvancedMarkerOptions()
694+
val options = MarkerOptions()
696695
.position(position)
697696
.title(markerView.title)
698697
.snippet(markerView.description)
699698

700-
val marker = map.addMarker(options) as AdvancedMarker
699+
val marker = map.addMarker(options) ?: return
701700
marker.setAnchor(markerView.anchorX, markerView.anchorY)
702701
marker.zIndex = markerView.zIndex
703702
marker.rotation = markerView.rotate
@@ -715,9 +714,8 @@ class GoogleMapProvider(private val context: Context) :
715714
}
716715
}
717716

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.
721719
private fun showLiveMarker(markerView: LuggMarkerView) {
722720
val wrapper = wrapperView ?: return
723721

example/bare/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PODS:
1111
- hermes-engine (0.14.0):
1212
- hermes-engine/Pre-built (= 0.14.0)
1313
- hermes-engine/Pre-built (0.14.0)
14-
- LuggMaps (1.0.0-beta.6):
14+
- LuggMaps (1.0.0-beta.11):
1515
- boost
1616
- DoubleConversion
1717
- fast_float
@@ -3202,7 +3202,7 @@ SPEC CHECKSUMS:
32023202
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
32033203
GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438
32043204
hermes-engine: 3515eff1a2de44b79dfa94a03d1adeed40f0dafe
3205-
LuggMaps: ae94261b276434379240235ff85192dcc541d66c
3205+
LuggMaps: 91958164a9ad4932293c33caf8386a35d478e914
32063206
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
32073207
RCTDeprecation: 2b70c6e3abe00396cefd8913efbf6a2db01a2b36
32083208
RCTRequired: f3540eee8094231581d40c5c6d41b0f170237a81

scripts/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ clean_bare_example() {
7878
cd example/bare/android
7979
./gradlew clean -q
8080
cd ../../..
81-
npx pod-install example/bare
81+
cd example/bare/ios && pod install && cd ../../..
8282
}
8383

8484
clean_expo_example() {

0 commit comments

Comments
 (0)