Class OpenStreetMapProvider
Provides map tile services using OpenStreetMap as the data source, implementing both IMapProvider and IMapTileProvider interfaces for map rendering and tile management.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.RadMap.dll
Syntax
public class OpenStreetMapProvider : IMapProvider, ICloneable, IMapTileProvider
Constructors
OpenStreetMapProvider()
Initializes a new instance of the OpenStreetMapProvider class with default tile downloader and memory cache provider.
Declaration
public OpenStreetMapProvider()
Fields
cacheLoadReference
Declaration
protected Dictionary<string, List<TileInfo>> cacheLoadReference
Field Value
|
System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.List<TileInfo>>
|
lockObj
Declaration
protected object lockObj
Field Value
|
System.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
public IMapCacheProvider CacheProvider { get; set; }
Property Value
|
IMapCacheProvider
|
Implements
EnableCaching
Gets or sets a value indicating whether tile caching is enabled for this provider to store downloaded tiles locally.
Declaration
public bool EnableCaching { get; set; }
Property Value
|
System.Boolean
|
Implements
Id
Gets the unique identifier for this map provider instance.
Declaration
public string Id { get; }
Property Value
|
System.String
|
Implements
ImageUrl
Gets or sets the URL template used for downloading OpenStreetMap tiles, supporting placeholder tokens for coordinates and zoom level.
Declaration
public string ImageUrl { get; set; }
Property Value
|
System.String
|
Initialized
Gets or sets a value indicating whether this OpenStreetMapProvider has completed its initialization process.
Declaration
public bool Initialized { get; protected set; }
Property Value
|
System.Boolean
|
MaxZoomLevel
Gets or sets the maximum zoom level supported by this OpenStreetMap provider.
Declaration
public int MaxZoomLevel { get; set; }
Property Value
|
System.Int32
|
Implements
MinZoomLevel
Gets or sets the minimum zoom level supported by this OpenStreetMap provider.
Declaration
public int MinZoomLevel { get; set; }
Property Value
|
System.Int32
|
Implements
TileDownloader
Gets or sets the tile downloader responsible for asynchronously downloading map tiles from OpenStreetMap servers.
Declaration
public IMapTileDownloader TileDownloader { get; set; }
Property Value
|
IMapTileDownloader
|
Implements
TileSize
Gets the size of map tiles used by this provider, typically 256x256 pixels for OpenStreetMap.
Declaration
public Size TileSize { get; }
Property Value
|
System.Drawing.Size
|
Implements
Methods
Clone()
Creates a deep copy of this OpenStreetMapProvider instance with identical configuration settings.
Declaration
public virtual object Clone()
Returns
|
System.Object
A new OpenStreetMapProvider object that is a copy of this instance. |
Implements
GetCacheKey(Int32, Int32, Int32)
Generates a unique cache key string for storing and retrieving tile images based on tile coordinates and zoom level.
Declaration
protected virtual string GetCacheKey(int tileX, int tileY, int zoomLevel)
Parameters
|
System.Int32
tileX
The X coordinate of the tile. |
|
System.Int32
tileY
The Y coordinate of the tile. |
|
System.Int32
zoomLevel
The zoom level of the tile. |
Returns
|
System.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
public IEnumerable<MapVisualElement> GetContent(IMapViewport viewport)
Parameters
|
IMapViewport
viewport
The IMapViewport defining the current view area and settings. |
Returns
|
System.Collections.Generic.IEnumerable<MapVisualElement>
An enumerable collection of MapVisualElement objects representing the visible map tiles. |
Implements
GetSupportedViews()
Gets the list of supported map views for this provider, returning null as OpenStreetMap uses a standard view.
Declaration
public List<MapViewInfo> GetSupportedViews()
Returns
|
System.Collections.Generic.List<MapViewInfo>
A list of MapViewInfo objects, or null if standard views are used. |
Implements
GetTile(Int32, Int32, Int32)
Constructs the complete URL for retrieving a specific map tile from OpenStreetMap servers based on tile coordinates and zoom level.
Declaration
public Uri GetTile(int tileMatrixX, int tileMatrixY, int zoomLevel)
Parameters
|
System.Int32
tileMatrixX
The X coordinate of the tile in the tile matrix. |
|
System.Int32
tileMatrixY
The Y coordinate of the tile in the tile matrix. |
|
System.Int32
zoomLevel
The zoom level for the requested tile. |
Returns
|
System.Uri
A System.Uri object representing the complete URL for the tile request. |
GetTileImage(Int32, Int32, Int32)
Synchronously retrieves a map tile image for the specified coordinates and zoom level, utilizing cache when available.
Declaration
public Image GetTileImage(int tileMatrixX, int tileMatrixY, int zoomLevel)
Parameters
|
System.Int32
tileMatrixX
The X coordinate of the tile in the tile matrix. |
|
System.Int32
tileMatrixY
The Y coordinate of the tile in the tile matrix. |
|
System.Int32
zoomLevel
The zoom level for the requested tile. |
Returns
|
System.Drawing.Image
An System.Drawing.Image object containing the tile image data. |
Implements
GetTileInfoImage(TileInfo)
Initiates the asynchronous loading of tile image data, either from cache or by downloading from OpenStreetMap servers.
Declaration
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
public void Initialize()
Implements
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
protected virtual void OnFileLoadAsyncComplete(string fileName, byte[] content)
Parameters
|
System.String
fileName
The cache key identifier for the loaded file. |
|
System.Byte[]
content
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
protected virtual void OnInitializationComplete(EventArgs e)
Parameters
|
System.EventArgs
e
An System.EventArgs that contains the event data. |
OnInitializationError(InitializationErrorEventArgs)
Raises the InitializationError event when an error occurs during provider initialization.
Declaration
protected virtual void OnInitializationError(InitializationErrorEventArgs e)
Parameters
|
InitializationErrorEventArgs
e
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
protected virtual void OnProviderUpdated(EventArgs e)
Parameters
|
System.EventArgs
e
An System.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
protected virtual void OnTileDownloadComplete(object sender, TileInfoEventArgs e)
Parameters
|
System.Object
sender
The source of the event. |
|
TileInfoEventArgs
e
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
public void SetView(MapViewInfo view)
Parameters
|
MapViewInfo
view
The MapViewInfo representing the desired map view. |
Implements
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
public void ViewportChanged(IMapViewport viewport, ViewportChangeAction action)
Parameters
|
IMapViewport
viewport
The IMapViewport representing the current view settings and visible area. |
|
ViewportChangeAction
action
The ViewportChangeAction indicating the type of viewport change that occurred. |
Implements
Events
InitializationComplete
Occurs when the provider initialization process is completed successfully.
Declaration
public event EventHandler InitializationComplete
Event Type
|
System.EventHandler
|
Implements
InitializationError
Occurs when an error is encountered during the provider initialization process.
Declaration
public event InitializationErrorEventHandler InitializationError
Event Type
|
InitializationErrorEventHandler
|
Implements
ProviderUpdated
Occurs when the provider content is updated, typically after new tiles are loaded or downloaded.
Declaration
public event EventHandler ProviderUpdated
Event Type
|
System.EventHandler
|