简体   繁体   中英

Unable to pan or zoom Xamarin.Forms.GoogleMaps

I am looking to use Xamarin.Forms.GoogleMaps in our application. The maps displays fine and marks the location but we are unable to interact with the map. (ie. pan the map left and right or zoom in/out or play with markers)

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:maps="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps"
    Title="Pick your area"
    Shell.TabBarIsVisible="False">
    <ContentPage.Content>

        <AbsoluteLayout>
            <StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">

                <maps:Map
                    x:Name="locationMap"
                    HasScrollEnabled="True"
                    HasZoomEnabled="True"
                    HeightRequest="300"
                    MapClicked="locationMap_MapClicked"
                    MapLongClicked="locationMap_MapLongClicked"
                    VerticalOptions="Start" />
                <StackLayout
                    Margin="20,5"
                    Orientation="Horizontal"
                    VerticalOptions="Center">
                    <Label
                        Style="{StaticResource SectionHeaders}"
                        Text="Choose from saved locations:"
                        VerticalTextAlignment="Center" />
                    <Picker
                        Title="Pick address"
                        HorizontalOptions="End"
                        ItemDisplayBinding="{Binding Name}"
                        ItemsSource="{Binding SavedAddresses}"
                        SelectedIndexChanged="Picker_SelectedIndexChanged" />
                </StackLayout>


            </StackLayout>

        </AbsoluteLayout>
    </ContentPage.Content>
</ContentPage>

The application is based on

  • Xamarin Forms 4.5.0
  • Xamarin Form GoogleMaps 3.3.0

It is a shell architecture.

If anyone can help us use it, it would be great help.

Thanks in advance

I write Shell and Xamarin Form GoogleMaps demo to test it. Here is running GIF.

在此处输入图像描述

It is running normally, my nuget package version like following sceenshot.(I test it in Android 8.1 and Android 9.0, both of them are Ok)

在此处输入图像描述

Here is demo, you can download it and test it in your emulator, please do not forget to the change api key in your AndroidManifest.xml .

<meta-data android:name="com.google.android.geo.API_KEY" android:value="api key" />

https://github.com/851265601/ShellAndGoogleMapPlugin

Sorry, turns out it was really stupid. There was an absolutely placed control of list view that was in hidden state which prevented interaction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM