Xamarin.Forms
Xamarin.Forms copied to clipboard
[Bug] The tile layer image for OpenStreetMap was not displayed in Xamarin.Forms UWP when the tile layer URI is added to the Image control
Description
I was trying to display the image of tile layer for OpenStreetMap using the Image control in the UWP platform, but the tile layer was displayed or displayed blank.
Steps to Reproduce
- Create a new Xamarin.Forms application.
- In the MainPage.xaml, add a simple image control.
- In the MainPage.xaml.cs, initialize a new BitMapImage control and set the OSM tile layer's URI to its UriSource property. Then set the BitMapImage to the Image.Source.
- Run the application.
Expected Behavior
The image of the OSM tile should be displayed.
Actual Behavior
The image of the OSM tile was not displayed.
Example Code Snippet
In MainPage.xaml
<Page
x:Class="BitmapImageDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BitmapImageDemo"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Image x:Name="image"
Stretch="Uniform" />
</Grid>
</Page>
In MainPage.xaml.cs
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.UriSource = new Uri("https://tile.openstreetmap.org/1/1/0.png", UriKind.RelativeOrAbsolute);
image.Width = bitmapImage.DecodePixelWidth = 256;
image.Height = bitmapImage.DecodePixelHeight = 256;
image.Source = bitmapImage;
}
}
Your can also find/download the example sample from the following github link.
Basic Information
- In Android and iOS the image of the OSM tile got displayed. Issue occurred only in UWP.