To add map control to your Windows Forms application, install the package and just drag and drop the control from the Visual Studio Toolbox to a Form.
// Somewhere in Form Designer
MapControl mapControl = new MapControl();
Before using the control, you need to specify values for the following control properties:
TileServer
- it defines tiles source used for map control;CacheFolder
- should be specified if you are using web-based tile server.
mapControl.TileServer = new OfflineTileServer();
// If tile server supports file system caching,
// you should specify path to the cache folder.
// Web-based tile servers strongly require file system caching
// to prevent highload of the server.
mapControl.CacheFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MapControl");
// Use tiles from OpenTopoMap (https://opentopomap.org/)
mapControl.TileServer = new OpenTopoMapServer();
That's it! Run the app to see the map control in action.
You may also need to change values of following properties to customize the map control before using:
MinZoomLevel
- minimal zoom value of the map;MinZoomLevel
- maximal zoom value of the map;ZoomLevel
- current zoom level;FitToBounds
- set totrue
if you want the map will not slide over the vertical bounds of the control;BackColor
- to change the color of the control itself;ErrorColor
- color used to draw error messages, for example when a tile was not found;ShowThumbnails
- if you are want to display thumbnails while loading map tiles;ThumbnailText
- text to be displayed when a tile is downloading from the server;ThumbnailForeColor
- thumbnail text color;ThumbnailBackColor
- background of the tile thumbnail;
Other properties are also available, see documenation comments.
See here how to add markers, tracks and polygons on the map.
Instruction how to create own tile server.