I want GMap.NET to overlay images with tiles on the map.

Asked 1 years ago, Updated 1 years ago, 74 views

Creating Windows Forms applications using GMap.NET.I use OpenStreetMap for the map, and I can draw the map.

I would like to overlay the image with tiles on the drawn map, but I don't know how to do it.It is possible to overlay non-tile images, but I would like to draw them with tiles because they become rough when I zoom in.

c# openstreetmap

2022-09-29 22:30

1 Answers

GMapOverlay It seems that you can draw freely by inheriting the class and overriding OnRender.I haven't checked the operation, but I think it looks like this.

internal class CustomOverlay:GMapOverlay,IDisposable
{
    private Bitmap_Image;

    internal CustomOverlay (Bitmap image)
    {
        _Image=image;
    }

    public override void OnRender (Graphics g)
    {
        using(vartb=newTextureBrush(_Image,WrapMode.Tile/*,TODO:size image*/))
        {
            g.FillRectangle(tb,Control.ClientRectangle);//TODO:positioning
        }
     }

    // Implementation of the following IDisposable patterns:
    public new voiddispose()
    {
        Dispose(true);
        GC.SuppressFinalize (this);
    }
    private void disposition (bool disposition)
    {
        base.Dispose();
        if(disposing)
        {
            using(_Image){}
        }
        _Image=null;
    }
    voidIDisposable.Dispose()
    {
        Dispose();
    }
    ~CustomOverlay()
    {
        Dispose (false);
    }
}


2022-09-29 22:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.