amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 349 forks source link

[Android] ZoomControls enabled after orientation changes #578

Open galadril opened 6 years ago

galadril commented 6 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

I've set the ZoomControlsEnabled on the UISettings to false, and the zoom controls are actually gone.. but when i change my rotation from portrait to landscape, the controls are back on the map.

ACTUAL SCREENSHOTS/STACKTRACE

This is the screen on portrait: afbeelding

When i changes to landscape, the controls for zoom are enabled: afbeelding

When i open the page initially in landscape mode, there are no controls on the map.. so it's specific on orientation changes on Android.

EXPECTED BEHAVIOR

Like it's correctly working on iOS, after orientation change from portrait/landscape or visa versa, the control should still use the correct settings. (and stay hidden if ZoomControlsEnabled is set to false)

HOW TO REPRODUCE

  1. We have a map like shown on the example Xaml below. Note we've wrapped ZoomControlsEnabled properties of the UISettings to be able to set them in xaml. We use visual state manager to change between a fixed layout and a layout with gestures enabled. but the control should never been shown

  2. Change your orientation on Android


 // 1 map xaml
           <cntrl:Map
                     AbsoluteLayout.LayoutBounds="0,0,1,1"
                     AbsoluteLayout.LayoutFlags="All"
                     IsTrafficEnabled="False"
                     MapType="Street"
                     MyLocationEnabled="False"
                     ZoomControlsEnabled="False">
                     <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup Name="OrientationStates">
                           <VisualState Name="Portrait">
                              <VisualState.Setters>
                                 <Setter Property="IsEnabled" Value="False" />
                                 <Setter Property="HasZoomEnabled" Value="False" />
                                 <Setter Property="HasScrollEnabled" Value="False" />
                                 <Setter Property="HasRotationEnabled" Value="False" />
                              </VisualState.Setters>
                           </VisualState>
                           <VisualState Name="Landscape">
                              <VisualState.Setters>
                                 <Setter Property="IsEnabled" Value="True" />
                                 <Setter Property="HasZoomEnabled" Value="True" />
                                 <Setter Property="HasScrollEnabled" Value="True" />
                                 <Setter Property="HasRotationEnabled" Value="True" />
                              </VisualState.Setters>
                           </VisualState>
                        </VisualStateGroup>
                     </VisualStateManager.VisualStateGroups>
                  </cntrl:Map>

If you need anymore info, let me know. thanks for this library!

galadril commented 6 years ago

It's related to the VisualState Setter of HasZoomEnabled.. as soon as I keep then one fixed to true or false, instead of variable.. it also doesn't show the controls after rotating.

So i think that setting the HasZoomEnabled to true or false, should maybe also respect the settings that I've already configured for ZoomControlsEnabled ?