8
votes

I am using MapBox to display a custom map of a specific area. In MapBox: my specific area is yellow and the rest of the map is transparent (see following image).

In MapBox

What I want to achieve: I want to put a MapControl over a Background Image. So when the tiles of the map are transparents, I can see the background image.

The problem I have: In my UWP app, the specific area of the map is displayed correctly (yellow) but the rest of the map is black thus the background image is hidden by the map.

There is no problem with MapBox because the generated tiles are transparent. I think the problem is in my app.

I tried to set the background of the MapControl to Transparent with no success.

XAML

<Image x:Name="background" 
       Stretch="UniformToFill"
       HorizontalAlignment="Stretch"
       VerticalAlignment="Stretch"/>

<maps:MapControl x:Name="MyMap" 
                 Background="Transparent"
                 HorizontalAlignment="Stretch" 
                 VerticalAlignment="Stretch"
                 MapServiceToken="TOKEN"/>

C#

HttpMapTileDataSource leaflet = new HttpMapTileDataSource(
            "URL_TO_MAPBOX_API");

MapTileSource mts = new MapTileSource(leaflet);
mts.IsTransparencyEnabled = true;
mts.AllowOverstretch = true;
mts.IsFadingEnabled = false;
this.MyMap.TileSources.Add(mts);
this.MyMap.Style = MapStyle.None;

Am I doing something wrong or is it simply not possible?

Thanks for your help

1
Have you tried to change Layer of MapTileSource? For example mts.Layer = MapTileLayer.BackgroundReplacement; - Kuba
Just tried it. Nothing has changed unfortunately :(. Thanks anyway :) - Sudo
Is the background property of MapControl ignored completely? Because if not you could maybe set the background with an ImageBrush property e.g. <MapsControl.Background><ImageBrush .../></MapsControl.Background> - DevAttendant
Well, the background property is not ignored, I can see at the beginning when the MapControl is loading. Just before the tiles appear. I did try setting the background property with an ImageBrush with no luck. - Sudo
How I achieved this was by putting in two tiles. One with the constant background image or tile (a constant Bitstream colour ) and another one of the tile I wanted to show, when the tiles are loading the constant bitstream colour is shown and when the tiles are loaded, the tile are shown. - iam.Carrot

1 Answers

0
votes

The MapControl is a very complicated control. It uses a SwapChainPanel to interop with Direct X. It would suprise me if what you try to do is possible.