0

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;
}
rbrundritt
  • 16,570
  • 2
  • 21
  • 46
NoWar
  • 36,338
  • 80
  • 323
  • 498
  • I don’t understand well about your issue. Could you please explain in detail what "on fly" means? – dear_vv Jun 15 '21 at 01:13
  • @AryaDing-MSFT Hey! On fly means that `dataSource` get predefined PNG and `tileSource` or `tileSource.Layer` or `UWP MapControl` has no possibility to setup custom opacity. So should be a way to do it. So If user wants change custom opacity for tiles like 0.4 how he can do ut on fly so developer should provide a way tochange opacity for predefined tiles by user request. – NoWar Jun 15 '21 at 01:41

1 Answers1

1

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.

Duncan Lawler
  • 1,772
  • 8
  • 13