New to Telerik UI for WinFormsStart a free 30-day trial

Provides map tile services using OpenStreetMap as the data source, implementing both IMapProvider and IMapTileProvider interfaces for map rendering and tile management.

Definition

Namespace:Telerik.WinControls.UI

Assembly:Telerik.WinControls.RadMap.dll

Syntax:

C#
public class OpenStreetMapProvider : IMapProvider, ICloneable, IMapTileProvider

Inheritance: objectOpenStreetMapProvider

Implements: ICloneableIMapProviderIMapTileProvider

Constructors

Initializes a new instance of the OpenStreetMapProvider class with default tile downloader and memory cache provider.

C#
public OpenStreetMapProvider()

Fields

C#
protected Dictionary<string, List<TileInfo>> cacheLoadReference
C#
protected object lockObj

Properties

Gets or sets the cache provider used for storing and retrieving downloaded map tiles to improve performance and reduce network requests.

C#
public IMapCacheProvider CacheProvider { get; set; }

Implements: IMapTileProvider.CacheProvider

Gets or sets a value indicating whether tile caching is enabled for this provider to store downloaded tiles locally.

C#
public bool EnableCaching { get; set; }

Implements: IMapTileProvider.EnableCaching

Gets the unique identifier for this map provider instance.

C#
public string Id { get; }

Implements: IMapProvider.Id

Gets or sets the URL template used for downloading OpenStreetMap tiles, supporting placeholder tokens for coordinates and zoom level.

C#
public string ImageUrl { get; set; }

Gets or sets a value indicating whether this OpenStreetMapProvider has completed its initialization process.

C#
public bool Initialized { get; protected set; }

Gets or sets the maximum zoom level supported by this OpenStreetMap provider.

C#
public int MaxZoomLevel { get; set; }

Implements: IMapProvider.MaxZoomLevel

Gets or sets the minimum zoom level supported by this OpenStreetMap provider.

C#
public int MinZoomLevel { get; set; }

Implements: IMapProvider.MinZoomLevel

Gets the settings that control tile rendering behavior.

C#
public MapTileProviderSettings Settings { get; }

Implements: IMapTileProvider.Settings

Gets or sets the tile downloader responsible for asynchronously downloading map tiles from OpenStreetMap servers.

C#
public IMapTileDownloader TileDownloader { get; set; }

Implements: IMapTileProvider.TileDownloader

Gets the size of map tiles used by this provider, typically 256x256 pixels for OpenStreetMap.

C#
public Size TileSize { get; }

Implements: IMapTileProvider.TileSize

Methods

Creates a deep copy of this OpenStreetMapProvider instance with identical configuration settings.

C#
public virtual object Clone()
Returns:

object

A new OpenStreetMapProvider object that is a copy of this instance.

Implements: ICloneable.Clone()

Generates a unique cache key string for storing and retrieving tile images based on tile coordinates and zoom level.

C#
protected virtual string GetCacheKey(int tileX, int tileY, int zoomLevel)
Parameters:tileXint

The X coordinate of the tile.

tileYint

The Y coordinate of the tile.

zoomLevelint

The zoom level of the tile.

Returns:

string

A string representing the unique cache key for the specified tile.

Retrieves the visual elements representing map tiles for the current viewport, converting cached tile data to renderable map elements.

C#
public IEnumerable<MapVisualElement> GetContent(IMapViewport viewport)
Parameters:viewportIMapViewport

The IMapViewport defining the current view area and settings.

Returns:

IEnumerable<MapVisualElement>

An enumerable collection of MapVisualElement objects representing the visible map tiles.

Implements: IMapProvider.GetContent(IMapViewport)

Gets the list of supported map views for this provider, returning null as OpenStreetMap uses a standard view.

C#
public List<MapViewInfo> GetSupportedViews()
Returns:

List<MapViewInfo>

A list of MapViewInfo objects, or null if standard views are used.

Implements: IMapProvider.GetSupportedViews()

Constructs the complete URL for retrieving a specific map tile from OpenStreetMap servers based on tile coordinates and zoom level.

C#
public Uri GetTile(int tileMatrixX, int tileMatrixY, int zoomLevel)
Parameters:tileMatrixXint

The X coordinate of the tile in the tile matrix.

tileMatrixYint

The Y coordinate of the tile in the tile matrix.

zoomLevelint

The zoom level for the requested tile.

Returns:

Uri

A Uri object representing the complete URL for the tile request.

Synchronously retrieves a map tile image for the specified coordinates and zoom level, utilizing cache when available.

C#
public Image GetTileImage(int tileMatrixX, int tileMatrixY, int zoomLevel)
Parameters:tileMatrixXint

The X coordinate of the tile in the tile matrix.

tileMatrixYint

The Y coordinate of the tile in the tile matrix.

zoomLevelint

The zoom level for the requested tile.

Returns:

Image

An Image object containing the tile image data.

Implements: IMapTileProvider.GetTileImage(int, int, int)

Initiates the asynchronous loading of tile image data, either from cache or by downloading from OpenStreetMap servers.

C#
protected virtual void GetTileInfoImage(TileInfo tileInfo)
Parameters:tileInfoTileInfo

The TileInfo object containing tile coordinates and metadata for the image request.

Initializes the provider, marking it as ready for tile requests and raising the initialization complete event.

C#
public void Initialize()

Implements: IMapProvider.Initialize()

Handles the completion of asynchronous file loading operations from the cache provider, updating tile content or initiating download if cache miss occurs.

C#
protected virtual void OnFileLoadAsyncComplete(string fileName, byte[] content)
Parameters:fileNamestring

The cache key identifier for the loaded file.

contentbyte[]

The byte array containing the loaded tile image data, or null if not found in cache.

Raises the InitializationComplete event when provider initialization is successfully completed.

C#
protected virtual void OnInitializationComplete(EventArgs e)
Parameters:eEventArgs

An EventArgs that contains the event data.

Raises the InitializationError event when an error occurs during provider initialization.

C#
protected virtual void OnInitializationError(InitializationErrorEventArgs e)
Parameters:eInitializationErrorEventArgs

An InitializationErrorEventArgs that contains the error information.

Raises the ProviderUpdated event when provider content changes, such as when new tiles are available.

C#
protected virtual void OnProviderUpdated(EventArgs e)
Parameters:eEventArgs

An EventArgs that contains the event data.

Handles the completion of tile download operations, updating cache storage and synchronizing tile content across wraparound instances.

C#
protected virtual void OnTileDownloadComplete(object sender, TileInfoEventArgs e)
Parameters:senderobject

The source of the event.

eTileInfoEventArgs

The TileInfoEventArgs containing the downloaded tile information and image data.

Sets the active map view for this provider, currently not implemented for OpenStreetMap.

C#
public void SetView(MapViewInfo view)
Parameters:viewMapViewInfo

The MapViewInfo representing the desired map view.

Implements: IMapProvider.SetView(MapViewInfo)

Responds to viewport changes by calculating and managing the visible tiles required for the current view, handling tile loading and caching operations.

C#
public void ViewportChanged(IMapViewport viewport, ViewportChangeAction action)
Parameters:viewportIMapViewport

The IMapViewport representing the current view settings and visible area.

actionViewportChangeAction

The ViewportChangeAction indicating the type of viewport change that occurred.

Implements: IMapProvider.ViewportChanged(IMapViewport, ViewportChangeAction)

Events

Occurs when the provider initialization process is completed successfully.

C#
public event EventHandler InitializationComplete

Implements: IMapProvider.InitializationComplete

Occurs when an error is encountered during the provider initialization process.

C#
public event InitializationErrorEventHandler InitializationError

Implements: IMapProvider.InitializationError

Occurs when the provider content is updated, typically after new tiles are loaded or downloaded.

C#
public event EventHandler ProviderUpdated

Implements: IMapProvider.ProviderUpdated