From c30eb39523dcb8ff10595ceb465a3dae08332168 Mon Sep 17 00:00:00 2001 From: amay077 Date: Thu, 26 Oct 2017 21:53:52 +0900 Subject: [PATCH] Fix UiSettings.ZoomControls enabled not processed(also other UiSettings properties) --- .../Logics/UiSettingsLogic.cs | 13 +++++++ .../MapRenderer.cs | 35 ++++++++++--------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/Logics/UiSettingsLogic.cs b/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/Logics/UiSettingsLogic.cs index 217114a3..52a93f2c 100644 --- a/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/Logics/UiSettingsLogic.cs +++ b/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/Logics/UiSettingsLogic.cs @@ -6,6 +6,14 @@ namespace Xamarin.Forms.GoogleMaps.Logics.Android { internal sealed class UiSettingsLogic : BaseUiSettingsLogic { + // These properties are 'null' when call Initialize() + // If 'not null' then set true/false in app's page constructor. + public bool? RotateGesturesEnabled { get; private set; } + public bool? MyLocationButtonEnabled { get; private set; } + public bool? ScrollGesturesEnabled { get; private set; } + public bool? ZoomControlsEnabled { get; private set; } + public bool? ZoomGesturesEnabled { get; private set; } + public override void Initialize() { base.Initialize(); @@ -20,11 +28,13 @@ protected override void OnUpdateCompassEnabled() protected override void OnUpdateRotateGesturesEnabled() { NativeMap.UiSettings.RotateGesturesEnabled = Map.UiSettings.RotateGesturesEnabled; + RotateGesturesEnabled = Map.UiSettings.RotateGesturesEnabled; } protected override void OnUpdateMyLocationButtonEnabled() { NativeMap.UiSettings.MyLocationButtonEnabled = Map.UiSettings.MyLocationButtonEnabled; + MyLocationButtonEnabled = Map.UiSettings.MyLocationButtonEnabled; } protected override void OnUpdateIndoorLevelPickerEnabled() @@ -35,6 +45,7 @@ protected override void OnUpdateIndoorLevelPickerEnabled() protected override void OnUpdateScrollGesturesEnabled() { NativeMap.UiSettings.ScrollGesturesEnabled = Map.UiSettings.ScrollGesturesEnabled; + ScrollGesturesEnabled = Map.UiSettings.ScrollGesturesEnabled; } protected override void OnUpdateTiltGesturesEnabled() @@ -45,11 +56,13 @@ protected override void OnUpdateTiltGesturesEnabled() protected override void OnUpdateZoomControlsEnabled() { NativeMap.UiSettings.ZoomControlsEnabled = Map.UiSettings.ZoomControlsEnabled; + ZoomControlsEnabled = Map.UiSettings.ZoomControlsEnabled; } protected override void OnUpdateZoomGesturesEnabled() { NativeMap.UiSettings.ZoomGesturesEnabled = Map.UiSettings.ZoomGesturesEnabled; + ZoomGesturesEnabled = Map.UiSettings.ZoomGesturesEnabled; } } } diff --git a/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/MapRenderer.cs b/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/MapRenderer.cs index bc771502..4456e036 100644 --- a/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/MapRenderer.cs +++ b/Xamarin.Forms.GoogleMaps/Xamarin.Forms.GoogleMaps.Android/MapRenderer.cs @@ -152,14 +152,14 @@ void OnMapReady(GoogleMap map) map.SetOnMapLongClickListener(this); map.SetOnMyLocationButtonClickListener(this); - _uiSettingsLogic.Initialize(); - UpdateIsShowingUser(); - UpdateHasScrollEnabled(); - UpdateHasZoomEnabled(); - UpdateHasRotationEnabled(); + UpdateIsShowingUser(_uiSettingsLogic.MyLocationButtonEnabled); + UpdateHasScrollEnabled(_uiSettingsLogic.ScrollGesturesEnabled); + UpdateHasZoomEnabled(_uiSettingsLogic.ZoomControlsEnabled, _uiSettingsLogic.ZoomGesturesEnabled); + UpdateHasRotationEnabled(_uiSettingsLogic.RotateGesturesEnabled); UpdateIsTrafficEnabled(); UpdateIndoorEnabled(); UpdateMapStyle(); + _uiSettingsLogic.Initialize(); SetMapType(); SetPadding(); @@ -284,30 +284,33 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE } } - private void UpdateIsShowingUser() + private void UpdateIsShowingUser(bool? initialMyLocationButtonEnabled = null) { - NativeMap.MyLocationEnabled = NativeMap.UiSettings.MyLocationButtonEnabled = Map.IsShowingUser; + NativeMap.MyLocationEnabled = Map.IsShowingUser; + NativeMap.UiSettings.MyLocationButtonEnabled = initialMyLocationButtonEnabled ?? Map.IsShowingUser; } - private void UpdateMyLocationEnabled() + private void UpdateMyLocationEnabled(bool? initialMyLocationEnabled = null) { - NativeMap.MyLocationEnabled = Map.MyLocationEnabled; + NativeMap.MyLocationEnabled = initialMyLocationEnabled ?? Map.MyLocationEnabled; } - private void UpdateHasScrollEnabled() + private void UpdateHasScrollEnabled(bool? initialScrollGesturesEnabled = null) { - NativeMap.UiSettings.ScrollGesturesEnabled = Map.HasScrollEnabled; + NativeMap.UiSettings.ScrollGesturesEnabled = initialScrollGesturesEnabled ?? Map.HasScrollEnabled; } - private void UpdateHasZoomEnabled() + private void UpdateHasZoomEnabled( + bool? initialZoomControlsEnabled = null, + bool? initialZoomGesturesEnabled = null) { - NativeMap.UiSettings.ZoomControlsEnabled = Map.HasZoomEnabled; - NativeMap.UiSettings.ZoomGesturesEnabled = Map.HasZoomEnabled; + NativeMap.UiSettings.ZoomControlsEnabled = initialZoomControlsEnabled ?? Map.HasZoomEnabled; + NativeMap.UiSettings.ZoomGesturesEnabled = initialZoomGesturesEnabled ?? Map.HasZoomEnabled; } - private void UpdateHasRotationEnabled() + private void UpdateHasRotationEnabled(bool? initialRotateGesturesEnabled = null) { - NativeMap.UiSettings.RotateGesturesEnabled = Map.HasRotationEnabled; + NativeMap.UiSettings.RotateGesturesEnabled = initialRotateGesturesEnabled ?? Map.HasRotationEnabled; } private void UpdateIsTrafficEnabled()