0

I try to make an application with Xamarin.Forms.Maps. I tried to use an official example and I did this:

public MapPage ()
        {
            InitializeComponent();

            var map = new Map(MapSpan.FromCenterAndRadius(new Position(55, 37), Distance.FromKilometers(1)))
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var stack = new StackLayout { Spacing = 0 };
            stack.Children.Add(map);
            Content = stack;
        }

It's a constructor of my MapPage which inherits a ContentPage. But when an application is running it doesn't change an active form to my MapPage. If I comment something and StackLayout doesn't have a map in Children, the form is shown. I show the form from previous on by calling this:

Navigation.PushModalAsync(new MapPage(), true);

Can somebody give me some advice, please?

  • In the App.xml.cs (code behind) make sure `MapPage` is set as the MainPage in the `App` constructor. – pinedax Apr 19 '18 at 18:46

1 Answers1

0

It seems you have not set the Google API key in the AndroidManifest.
You should set it like:

<application android:label="Maps.Android">
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YourKey" />
</application>
Billy Liu - MSFT
  • 2,168
  • 1
  • 8
  • 15