@@ -293,11 +293,9 @@ class GoogleMapsViewImpl(
293293 userInterfaceStyle?.let {
294294 googleMap?.mapColorScheme = it
295295 }
296- minZoomLevel?.let {
297- googleMap?.setMinZoomPreference(it.toFloat())
298- }
299- maxZoomLevel?.let {
300- googleMap?.setMaxZoomPreference(it.toFloat())
296+ mapZoomConfig?.let {
297+ googleMap?.setMinZoomPreference(it.min?.toFloat() ? : 2.0f )
298+ googleMap?.setMaxZoomPreference(it.max?.toFloat() ? : 21.0f )
301299 }
302300 }
303301
@@ -340,56 +338,34 @@ class GoogleMapsViewImpl(
340338 set(value) {
341339 field = value
342340 onUi {
343- value?.let { v ->
344- googleMap?.uiSettings?.apply {
345- v.allGesturesEnabled?.let { setAllGesturesEnabled(it) }
346- v.compassEnabled?.let { isCompassEnabled = it }
347- v.indoorLevelPickerEnabled?.let { isIndoorLevelPickerEnabled = it }
348- v.mapToolbarEnabled?.let { isMapToolbarEnabled = it }
349- v.myLocationButtonEnabled?.let {
350- googleMap?.setLocationSource(locationHandler)
351- isMyLocationButtonEnabled = it
352- }
353- v.rotateEnabled?.let { isRotateGesturesEnabled = it }
354- v.scrollEnabled?.let { isScrollGesturesEnabled = it }
355- v.scrollDuringRotateOrZoomEnabled?.let {
356- isScrollGesturesEnabledDuringRotateOrZoom = it
357- }
358- v.tiltEnabled?.let { isTiltGesturesEnabled = it }
359- v.zoomControlsEnabled?.let { isZoomControlsEnabled = it }
360- v.zoomGesturesEnabled?.let { isZoomGesturesEnabled = it }
361- }
341+ googleMap?.uiSettings?.apply {
342+ setAllGesturesEnabled(value?.allGesturesEnabled ? : true )
343+ isCompassEnabled = value?.compassEnabled ? : false
344+ isIndoorLevelPickerEnabled = value?.indoorLevelPickerEnabled ? : false
345+ isMapToolbarEnabled = value?.mapToolbarEnabled ? : false
346+
347+ val myLocationEnabled = value?.myLocationButtonEnabled ? : false
348+ googleMap?.setLocationSource(if (myLocationEnabled) locationHandler else null )
349+ isMyLocationButtonEnabled = myLocationEnabled
350+
351+ isRotateGesturesEnabled = value?.rotateEnabled ? : true
352+ isScrollGesturesEnabled = value?.scrollEnabled ? : true
353+ isScrollGesturesEnabledDuringRotateOrZoom =
354+ value?.scrollDuringRotateOrZoomEnabled ? : true
355+ isTiltGesturesEnabled = value?.tiltEnabled ? : true
356+ isZoomControlsEnabled = value?.zoomControlsEnabled ? : false
357+ isZoomGesturesEnabled = value?.zoomGesturesEnabled ? : false
362358 }
363- ? : run {
364- googleMap?.uiSettings?.apply {
365- setAllGesturesEnabled(true )
366- isCompassEnabled = false
367- isIndoorLevelPickerEnabled = false
368- isMapToolbarEnabled = false
369- isMyLocationButtonEnabled = false
370- googleMap?.setLocationSource(null )
371- isRotateGesturesEnabled = true
372- isScrollGesturesEnabled = true
373- isScrollGesturesEnabledDuringRotateOrZoom = true
374- isTiltGesturesEnabled = true
375- isZoomControlsEnabled = false
376- isZoomGesturesEnabled = false
377- }
378- }
379359 }
380360 }
381361
382362 @SuppressLint(" MissingPermission" )
383363 var myLocationEnabled: Boolean? = null
384364 set(value) {
365+ field = value
385366 onUi {
386367 try {
387- value?.let {
388- googleMap?.isMyLocationEnabled = it
389- }
390- ? : run {
391- googleMap?.isMyLocationEnabled = false
392- }
368+ googleMap?.isMyLocationEnabled = value ? : false
393369 } catch (se: SecurityException ) {
394370 onLocationError?.invoke(RNLocationErrorCode .PERMISSION_DENIED )
395371 } catch (ex: Exception ) {
@@ -403,37 +379,23 @@ class GoogleMapsViewImpl(
403379 set(value) {
404380 field = value
405381 onUi {
406- value?.let {
407- googleMap?.isBuildingsEnabled = it
408- }
409- ? : run {
410- googleMap?.isBuildingsEnabled = false
411- }
382+ googleMap?.isBuildingsEnabled = value ? : false
412383 }
413384 }
414385
415386 var trafficEnabled: Boolean? = null
416387 set(value) {
417388 field = value
418389 onUi {
419- value?.let {
420- googleMap?.isTrafficEnabled = it
421- } ? : run {
422- googleMap?.isTrafficEnabled = false
423- }
390+ googleMap?.isTrafficEnabled = value ? : false
424391 }
425392 }
426393
427394 var indoorEnabled: Boolean? = null
428395 set(value) {
429396 field = value
430397 onUi {
431- value?.let {
432- googleMap?.isIndoorEnabled = it
433- }
434- ? : run {
435- googleMap?.isIndoorEnabled = false
436- }
398+ googleMap?.isIndoorEnabled = value ? : false
437399 }
438400 }
439401
@@ -449,64 +411,37 @@ class GoogleMapsViewImpl(
449411 set(value) {
450412 field = value
451413 onUi {
452- value?.let {
453- googleMap?.mapColorScheme = it
454- } ? : run {
455- googleMap?.mapColorScheme = MapColorScheme .FOLLOW_SYSTEM
456- }
414+ googleMap?.mapColorScheme = value ? : MapColorScheme .FOLLOW_SYSTEM
457415 }
458416 }
459417
460- var minZoomLevel : Double ? = null
418+ var mapZoomConfig : RNMapZoomConfig ? = null
461419 set(value) {
462420 field = value
463421 onUi {
464- value?.let {
465- googleMap?.setMinZoomPreference(it.toFloat())
466- } ? : run {
467- googleMap?.setMinZoomPreference(2.0f )
468- }
469- }
470- }
471-
472- var maxZoomLevel: Double? = null
473- set(value) {
474- field = value
475- onUi {
476- value?.let {
477- googleMap?.setMaxZoomPreference(it.toFloat())
478- } ? : run {
479- googleMap?.setMaxZoomPreference(21.0f )
480- }
422+ googleMap?.setMinZoomPreference(value?.min?.toFloat() ? : 2.0f )
423+ googleMap?.setMaxZoomPreference(value?.max?.toFloat() ? : 21.0f )
481424 }
482425 }
483426
484427 var mapPadding: RNMapPadding ? = null
485428 set(value) {
486429 field = value
487- value?.let {
488- onUi {
489- googleMap?.setPadding(
490- it.left.dpToPx().toInt(),
491- it.top.dpToPx().toInt(),
492- it.right.dpToPx().toInt(),
493- it.bottom.dpToPx().toInt(),
494- )
495- }
496- } ? : run {
497- googleMap?.setPadding(0 , 0 , 0 , 0 )
430+ onUi {
431+ googleMap?.setPadding(
432+ value?.left?.dpToPx()?.toInt() ? : 0 ,
433+ value?.top?.dpToPx()?.toInt() ? : 0 ,
434+ value?.right?.dpToPx()?.toInt() ? : 0 ,
435+ value?.bottom?.dpToPx()?.toInt() ? : 0 ,
436+ )
498437 }
499438 }
500439
501440 var mapType: Int? = null
502441 set(value) {
503442 field = value
504443 onUi {
505- value?.let {
506- googleMap?.mapType = it
507- } ? : run {
508- googleMap?.mapType = 1
509- }
444+ googleMap?.mapType = value ? : 1
510445 }
511446 }
512447
0 commit comments