Skip to content

Commit

Permalink
fix(android): add camera before styleLoad so defaultSettings can be a…
Browse files Browse the repository at this point in the history
…pplied earlier (#3113)
  • Loading branch information
mfazekas authored Oct 16, 2023
1 parent 093d63d commit 15dd01f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ abstract class AbstractMapFeature(context: Context?) : ReactViewGroup(context) {
protected var mMapView: RNMBXMapView? = null;
private var mWithMapViewCallbacks: Array<((RNMBXMapView) -> Unit)>? = null;

open var requiresStyleLoad = true;

open fun addToMap(mapView: RNMBXMapView) {
mMapView = mapView;
mWithMapViewCallbacks?.forEach { it(mapView) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class RNMBXCamera(private val mContext: Context, private val mManager: RNMBXCame
AbstractMapFeature(
mContext
) {
override var requiresStyleLoad = false

private var hasSentFirstRegion = false
private var mDefaultStop: CameraStop? = null
private var mCameraStop: CameraStop? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
}
}

val addToMap = styleLoaded
val addToMap = styleLoaded || (feature?.requiresStyleLoad == false)

var entry = FeatureEntry(feature, childView, false)
if (addToMap) {
Expand Down Expand Up @@ -541,11 +541,13 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
}
}

private fun addFeaturesToMap() {
private fun addFeaturesToMap(styleLoaded: Boolean = false) {
mFeatures.forEach {
if (!it.addedToMap) {
it.feature?.addToMap(this)
it.addedToMap = true
if (styleLoaded || it.feature?.requiresStyleLoad == false) {
it.feature?.addToMap(this)
it.addedToMap = true
}
}
}
}
Expand Down Expand Up @@ -654,6 +656,7 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
}
}
)
addFeaturesToMap(false)
}
}
}
Expand Down

0 comments on commit 15dd01f

Please sign in to comment.