Class
OpenStreetMapProvider

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:

cs-api-definition
public class OpenStreetMapProvider : IMapProvider, ICloneable, IMapTileProvider

Inheritance: objectOpenStreetMapProvider

Implements: ICloneableIMapProviderIMapTileProvider

Constructors

OpenStreetMapProvider()

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

Declaration

cs-api-definition
public OpenStreetMapProvider()

Fields

cacheLoadReference

Declaration

cs-api-definition
protected Dictionary<string, List<TileInfo>> cacheLoadReference

Field Value

Dictionary<string, List<TileInfo>>

lockObj

Declaration

cs-api-definition
protected object lockObj

Field Value

object

Properties

CacheProvider

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

Declaration

cs-api-definition
public IMapCacheProvider CacheProvider { get; set; }

Property Value

IMapCacheProvider

Implements IMapTileProvider.CacheProvider

EnableCaching

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

Declaration

cs-api-definition
public bool EnableCaching { get; set; }

Property Value

bool

Implements IMapTileProvider.EnableCaching

Id

Gets the unique identifier for this map provider instance.

Declaration

cs-api-definition
public string Id { get; }

Property Value

string

Implements IMapProvider.Id

ImageUrl

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

Declaration

cs-api-definition
public string ImageUrl { get; set; }

Property Value

string

Initialized

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

Declaration

cs-api-definition
public bool Initialized { get; protected set; }

Property Value

bool

MaxZoomLevel

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

Declaration

cs-api-definition
public int MaxZoomLevel { get; set; }

Property Value

int

Implements IMapProvider.MaxZoomLevel

MinZoomLevel

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

Declaration

cs-api-definition
public int MinZoomLevel { get; set; }

Property Value

int

Implements IMapProvider.MinZoomLevel

Settings

Gets the settings that control tile rendering behavior.

Declaration

cs-api-definition
public MapTileProviderSettings Settings { get; }

Property Value

MapTileProviderSettings

Implements IMapTileProvider.Settings

TileDownloader

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

Declaration

cs-api-definition
public IMapTileDownloader TileDownloader { get; set; }

Property Value

IMapTileDownloader

Implements IMapTileProvider.TileDownloader

TileSize

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

Declaration

cs-api-definition
public Size TileSize { get; }

Property Value

Size

Implements IMapTileProvider.TileSize

Methods

Clone()

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

Declaration

cs-api-definition
public virtual object Clone()

Returns

object

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

Implements ICloneable.Clone()

GetCacheKey(int, int, int)

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

Declaration

cs-api-definition
protected virtual string GetCacheKey(int tileX, int tileY, int zoomLevel)

Parameters

tileX

int

The X coordinate of the tile.

tileY

int

The Y coordinate of the tile.

zoomLevel

int

The zoom level of the tile.

Returns

string

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

GetContent(IMapViewport)

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

Declaration

cs-api-definition
public IEnumerable<MapVisualElement> GetContent(IMapViewport viewport)

Parameters

viewport

IMapViewport

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)

GetSupportedViews()

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

Declaration

cs-api-definition
public List<MapViewInfo> GetSupportedViews()

Returns

List<MapViewInfo>

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

Implements IMapProvider.GetSupportedViews()

GetTile(int, int, int)

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

Declaration

cs-api-definition
public Uri GetTile(int tileMatrixX, int tileMatrixY, int zoomLevel)

Parameters

tileMatrixX

int

The X coordinate of the tile in the tile matrix.

tileMatrixY

int

The Y coordinate of the tile in the tile matrix.

zoomLevel

int

The zoom level for the requested tile.

Returns

Uri

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

GetTileImage(int, int, int)

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

Declaration

cs-api-definition
public Image GetTileImage(int tileMatrixX, int tileMatrixY, int zoomLevel)

Parameters

tileMatrixX

int

The X coordinate of the tile in the tile matrix.

tileMatrixY

int

The Y coordinate of the tile in the tile matrix.

zoomLevel

int

The zoom level for the requested tile.

Returns

Image

An Image object containing the tile image data.

Implements IMapTileProvider.GetTileImage(int, int, int)

GetTileInfoImage(TileInfo)

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

Declaration

cs-api-definition
protected virtual void GetTileInfoImage(TileInfo tileInfo)

Parameters

tileInfo

TileInfo

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

Initialize()

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

Declaration

cs-api-definition
public void Initialize()

Implements IMapProvider.Initialize()

OnFileLoadAsyncComplete(string, byte[])

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

Declaration

cs-api-definition
protected virtual void OnFileLoadAsyncComplete(string fileName, byte[] content)

Parameters

fileName

string

The cache key identifier for the loaded file.

content

byte[]

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

OnInitializationComplete(EventArgs)

Raises the InitializationComplete event when provider initialization is successfully completed.

Declaration

cs-api-definition
protected virtual void OnInitializationComplete(EventArgs e)

Parameters

e

EventArgs

An EventArgs that contains the event data.

OnInitializationError(InitializationErrorEventArgs)

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

Declaration

cs-api-definition
protected virtual void OnInitializationError(InitializationErrorEventArgs e)

Parameters

e

InitializationErrorEventArgs

An InitializationErrorEventArgs that contains the error information.

OnProviderUpdated(EventArgs)

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

Declaration

cs-api-definition
protected virtual void OnProviderUpdated(EventArgs e)

Parameters

e

EventArgs

An EventArgs that contains the event data.

OnTileDownloadComplete(object, TileInfoEventArgs)

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

Declaration

cs-api-definition
protected virtual void OnTileDownloadComplete(object sender, TileInfoEventArgs e)

Parameters

sender

object

The source of the event.

e

TileInfoEventArgs

The TileInfoEventArgs containing the downloaded tile information and image data.

SetView(MapViewInfo)

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

Declaration

cs-api-definition
public void SetView(MapViewInfo view)

Parameters

view

MapViewInfo

The MapViewInfo representing the desired map view.

Implements IMapProvider.SetView(MapViewInfo)

ViewportChanged(IMapViewport, ViewportChangeAction)

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

Declaration

cs-api-definition
public void ViewportChanged(IMapViewport viewport, ViewportChangeAction action)

Parameters

viewport

IMapViewport

The IMapViewport representing the current view settings and visible area.

action

ViewportChangeAction

The ViewportChangeAction indicating the type of viewport change that occurred.

Implements IMapProvider.ViewportChanged(IMapViewport, ViewportChangeAction)

Events

InitializationComplete

Occurs when the provider initialization process is completed successfully.

Declaration

cs-api-definition
public event EventHandler InitializationComplete

Event Value

EventHandler

Implements IMapProvider.InitializationComplete

InitializationError

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

Declaration

cs-api-definition
public event InitializationErrorEventHandler InitializationError

Event Value

InitializationErrorEventHandler

Implements IMapProvider.InitializationError

ProviderUpdated

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

Declaration

cs-api-definition
public event EventHandler ProviderUpdated

Event Value

EventHandler

Implements IMapProvider.ProviderUpdated