mapbox-xamarin-forms
mapbox-xamarin-forms copied to clipboard
Mapbox Xamarin.Forms black map on Android
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:
What's wrong?
P.s. Haven't looked at iOS.
https://dropmefiles.com/IbcPE
The solution was to define the style of map in the page's code-behind file, not in the xaml...