diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt index 95398fb6c..688f3a637 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt @@ -1129,8 +1129,15 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie Logger.e("MapView", "setSourceVisibility, map is null") return } - val style = mMap!!.getStyle(); - style!!.styleLayers.forEach { + val style = mMap.getStyle(); + + val styleLayers = style?.styleLayers + if (styleLayers == null) { + Logger.e("MapView", "setSourceVisibility, map.getStyle().styleLayers is null") + return + } + + styleLayers.forEach { val layer = style.getLayer(it.id) if ((layer != null) && match(layer, sourceId, sourceLayerId)) { layer.visibility(