UWP MapControl LocalMapTileDataSource and tile's image custom opacity on fly

138 Views Asked by At

I use LocalMapTileDataSource and would like to apply custom opacity for tile's images. As I found there is no way to make it on fly?

Here is my code.

private void AddLocalMapTileDataSource()
{
     MapZoomLevelRange range;
     range.Min = 8;
     range.Max = 16;
     var dataSource = new LocalMapTileDataSource();
     dataSource.UriRequested += (s, e) =>
     {
          var deferral = e.Request.GetDeferral();
          var qk = TileSystem.TileXYToQuadKey(e.X,e.Y, e.ZoomLevel);
          e.Request.Uri = new Uri($"ms-appx:///Tiles/{qk}.png");
          deferral.Complete();
     };

     var tileSource = new MapTileSource(dataSource)
     {
         ZoomLevelRange = range
     };

     myMap.TileSources.Add(tileSource);
     tileSource.Layer = MapTileLayer.AreaOverlay;
     tileSource.IsTransparencyEnabled = true;
     tileSource.TilePixelSize = 256;
}
1

There are 1 best solutions below

0
Duncan Lawler On BEST ANSWER

When you load a tile from a PNG like this, it reads the opacity from each pixel in the PNG. If you want to change the opacity, you would need to update the PNG alpha values in each pixel. There's currently no way to set a global opacity value on an entire tile layer as this would conflict with the opacity information already present in the bitmap.