TileLayer opacity

Jun 16, 2011 at 5:50 PM

Can I change opacity for the hole TileLayer?

I am asking because when I group Wmsc and OSM layer into GroupTileLayer I see only one layer. I believe that this is because one layer is

on top of the second layer and because of that, I dont see second one

 

Thanks in advance

Jun 17, 2011 at 8:35 AM
Edited Jun 17, 2011 at 8:39 AM

I think you would have to do sth like that on your client. For example, SharpMap's TileLayer, which is using BruTile, has an System.Drawing(.Imaging?).ImageAttributes field that you can set with the constructor and use to achive transparency for the tiles

Hth FObermaier

Jun 17, 2011 at 10:24 AM

Apperntly that was not the problem. In geoserver, with styler I changed opacity for certain layers and tha result was same. I still can't see OSM layer

My code looks like this

var osmLayer = new TileLayer(new OsmTileSource()) { LayerName = "OSM" };
TileLayer samoborLayer = new TileLayer(new SamoborWmscTileSource()) { LayerName = "mssqlserver:vodovi" };
var groupLayer = new GroupTileLayer(new List<TileLayer> { samoborLayer, osmLayer });
mapControl.Map = CreateMap(groupLayer);

Jun 17, 2011 at 12:01 PM
Edited Jun 17, 2011 at 12:01 PM

ATM, the TileLayer class does not expose the ImageAttributes used internally, and there is no way of setting it, either (which I thought there was).

Please try to either expose the ImageAttributes on TileLayer class (sth like)

public ImageAttributes ImageAttributes
{
    get { return _imageAttributes; }
}

and then build your layers

var osmLayer = new TileLayer(new OsmTileSource()) { LayerName = "OSM" };
osmLayer.ImageAttributes.SetColorMatrix(new ColorMatrix { M33 = 0.3 , } );
...

If this does the trick, please file an issue along with your patchfile on SharpMap's site.

Hth FObermaier

Jun 17, 2011 at 5:55 PM

I am so confused right now with all of this projects, sharpmap, brutile, mapsui... Aaaa.. I dont know what is what and which is for what

I downloaded Mapsui and I am looking at TileLayer.cs and it is different from SharpMaps TileLayer.cs. I am new to this so am not sure what I have to do right now.

Can you help me?

Jun 17, 2011 at 6:06 PM

Sorry, my fault. but I suppose you are better off asking this question in the MapsUI forum.

cheers FObermaier

Jun 24, 2011 at 8:03 AM

hi cob4lt and felix,

sorry for my late reply. 

You are right that there is currently no way to set transparency in the group tile layer. To add such functionality you could look at the method CombineBitmaps in the GroupTileLayer.

Right now combining is done within SharpMap itself. An alternative architecture could be to reuse the renderer for that. But that will be a big change.

This question would fit best in the Mapsui forum. Mapsui is partial port of SharpMap that works in Silverlight. So Mapsui and SharpMap are alternatives to each other. BruTile is a core component for tiling which is used by both.

cheers Paul

Jun 27, 2011 at 1:52 PM
pauldendulk wrote:

You are right that there is currently no way to set transparency in the group tile layer. To add such functionality you could look at the method CombineBitmaps in the GroupTileLayer.

 

In MapsUI I added new Brutile source code and succesfully implement in project. Then I tried what you pointed out, in CombineBitmaps method I (for experiment) 

added Opacity for images. Like this:

var image = new Image {Source = bitmapImage};
image.Opacity = 0.5;

for your example with OsmTileSource and GeodanWorldWmsTileSource is working but when I tried with my own set of data (WMS, WMSC - same) is not.

Difference between my set of data and yours is in Schema, I have my own custom resolutions and you are working with SphericalMercator

Jun 28, 2011 at 7:10 AM
Edited Jun 28, 2011 at 7:11 AM

Your datasets are both in the same schema? Another schema should not be a problem, but they should be compatible schemas to work in a grouptilelayer.

Paul

Jul 1, 2011 at 2:11 PM

I did it! Thank you very much. Now I have OSM as a base layer and my other data as a "overlay" layer