NoWar
NoWar

Reputation: 37633

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

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;
}

Upvotes: 0

Views: 163

Answers (1)

Duncan Lawler
Duncan Lawler

Reputation: 1772

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.

Upvotes: 1

Related Questions