SharpMap bug in TileAsyncLayer

Topics: Data Access, SharpMap v2.0
Jul 9, 2014 at 3:27 AM
Edited Jul 9, 2014 at 3:54 AM
We found a bug,When our system displays the citie's symbol(a image of png format) on the map that uses TileAsyncLayer,The png image are cuted off on the tile boundary.The user can only see half of the symbol.The remaining half of the png symbol is on another tile and isn't show on the map .When the user zoom in, the remaining half of the png symbol maybe show on the map. The same happens when the label display, How to deal with the question? thanks
Coordinator
Jul 9, 2014 at 12:02 PM
To me that seems to be an issue with the tiles, not the TileAsyncLayer.
Jul 9, 2014 at 3:42 PM
Hi FObermaier , thanks for your reply.
you are right, I'm tracking the code. Could you give me some advice to deal with this issue ?
thanks very much!
Coordinator
Jul 9, 2014 at 9:34 PM
jasonLau wrote:
Hi FObermaier , thanks for your reply.
you are right, I'm tracking the code. Could you give me some advice to deal with this issue ?
thanks very much!
Are you creating the tiles yourself with SharpMap?
Jul 10, 2014 at 2:39 AM
Hi

I am using SharpMapTileSource (which in WinFormSamples demo) as TileAsyncLayer's TileSource , It also use BruTile .


Create tile method like this:
        private Image CreateTile(TileInfo info)        
        {
            lock (synclock)
            {
                Size size = new Size(this.Schema.Width, this.Schema.Height);

                Map map = new Map(size) { BackColor = Color.Transparent };

                map.Layers.AddCollection(this.layers);

                Extent ext = info.Extent;

                Envelope bbox = new Envelope(ext.MinX, ext.MaxX, ext.MinY, ext.MaxY);

                map.ZoomToBox(bbox);

              
                //save tile image  to  check
                //Image img = map.GetMap();
               // img.Save("Images//test.png", ImageFormat.Png);

                return map.GetMap();
            }
        }
best regards !
Coordinator
Jul 10, 2014 at 8:21 AM
Edited Jul 10, 2014 at 8:29 AM
You need to create a belt/cordon around the tile you want to render. S.th. like this:
private Image CreateTile(TileInfo info)        
{
    lock (synclock)
    {
        Size size = new Size(3 * this.Schema.Width, 3 * this.Schema.Height);

        Map map = new Map(size) { BackColor = Color.Transparent };

        map.Layers.AddCollection(this.layers);

        Extent ext = info.Extent;

        Envelope bbox = new Envelope(
            ext.MinX - ext.Width, ext.MaxX + ext.Max, 
            ext.MinY - ext.Height, ext.MaxY + ext.Height);

        map.ZoomToBox(bbox);

        var img = new System.Drawing.Bitmap(
            new System.Drawing.Size(this.Schema.Width, this.Schema.Height));
        using(var g = System.Drawing.Graphics.FromImage(img))
        {
            g.DrawImage(map.GetMap(), 
                new System.Drawing.Rectangle(0, 0, this.Schema.Width, this.Schema.Height),
                new System.Drawing.Rectangle(this.Schema.Width, this.Schema.Height, this.Schema.Width, this.Schema.Height),
                System.Drawing.GraphicsUnit.Pixels);
        }
        return img;
    }
}
Marked as answer by jasonLau on 7/10/2014 at 7:24 AM
Jul 10, 2014 at 10:09 AM
Hi, FObermaier

it 's good

thank you very much!!