NAXAM / mapbox-xamarin-forms

Mapbox on Xamarin.Forms
Apache License 2.0
73 stars 41 forks source link

Mapbox Xamarin.Forms black map on Android #115

Open Deathgar opened 2 years ago

Deathgar commented 2 years ago

I have created an empty Xamarin.Forms project. Installed all required nugets. Added accessToken to MainActivity.OnCreate. Added a map to the start page and got a black screen.

MainActivity:

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    Com.Mapbox.Mapboxsdk.Mapbox.GetInstance(this, MAPBOX_TOKEN);

    Xamarin.Essentials.Platform.Init(this, savedInstanceState);
    global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
    LoadApplication(new App());
}

MainPage.xaml:

<?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:local="clr-namespace:Naxam.Controls.Forms;assembly=Naxam.Mapbox.Forms"
             x:Class="MapBoxEmpty.MainPage">

    <StackLayout>
        <local:MapView x:Name="map" 
                        VerticalOptions="FillAndExpand" 
                       HorizontalOptions="FillAndExpand"
                        MapStyle="LIGHT" 
        />
    </StackLayout>

</ContentPage>

App: image

What's wrong?

P.s. Haven't looked at iOS.

https://dropmefiles.com/IbcPE

Deathgar commented 2 years ago

The solution was to define the style of map in the page's code-behind file, not in the xaml...