ActiveReports 9 > ActiveReports User Guide > How To > Page Report/RDL Report How To > Work with Report Controls and Data Regions > Work with Map > Work with Layers > Use a Tile Layer > Add a Custom Tile Provider |
You can add and configure a Custom Tile Provider in the Map control using the IMapTileProvider and IMapTile interfaces.
The IMapTileProvider interface contains detailed settings that are required to communicate with the tile server, whereas the IMapTile interface represents a single tile of a Map's tile layer that fetches the tile image based on the configurations in the IMapTileProvider interface.
Adding a custom tile provider also requires making some modifications in the Grapecity.ActiveReports.config file. Follow these steps to learn how to set a custom tile provider:
To write the code in Visual Basic.NET
VB code. Paste on TOP |
Copy Code
|
---|---|
Imports System Imports System.Collections.Specialized Imports GrapeCity.ActiveReports.Extensibility.Rendering.Components.Map |
VB code. Paste BELOW the Imports statements |
Copy Code
|
---|---|
Namespace MyClassLib Public Class MyTileProvider Implements IMapTileProvider ' Tile provider settings, like ApiKey, Language, Style and etc. Public Property Settings() As NameValueCollection ' Add your code here. End Property ' Get instance of tile by specifying tile coordinates and details. Public Sub GetTile(key As MapTileKey, success As Action(Of IMapTile), [error] As Action(Of Exception)) ' Add your code here. End Sub End Class |
To write the code in C#
C# code. Paste on TOP |
Copy Code
|
---|---|
using System; using System.Collections.Specialized; using GrapeCity.ActiveReports.Extensibility.Rendering.Components.Map; |
C# code. Paste BELOW the Using statements |
Copy Code
|
---|---|
namespace MyClassLib { public Class MyTileProvider :IMapTileProvider {// Tile provider settings, like ApiKey, Language, Style and etc. public NameValueCollection Settings { get; private set;} // Get instance of tile by specifying tile coordinates and details. public void GetTile(MapTileKey key, Action<IMapTile> success, Action<Exception> error); // Add your code here. } } |
To write the code in Visual Basic.NET
VB code. Paste on TOP |
Copy Code
|
---|---|
Imports System.IO Imports GrapeCity.ActiveReports.Extensibility.Rendering.Components.Map |
VB code. Paste BELOW the Imports statements |
Copy Code
|
---|---|
Namespace MyClassLib Public Class MyMapTile Implements IMapTile ' Gets the tile identifier Public Property Id() As MapTileKey ' Add your code here End Property ' Gets the tile image stream. Public Property Image() As Stream ' Add your code here. End Property End Class End Namespace |
To write the code in C#
C# code. Paste on TOP |
Copy Code
|
---|---|
using System.IO; using GrapeCity.ActiveReports.Extensibility.Rendering.Components.Map; |
C# code. Paste BELOW the Using statements |
Copy Code
|
---|---|
namespace MyClassLib public class MyMapTile : IMapTile { // Gets the tile identifier. public MapTileKey Id { get; private set; } // Gets the tile image stream. public Stream Image { get; private set; } // Add your code here. } } |
To write the code in Visual Basic.NET
VB code. Paste on TOP |
Copy Code
|
---|---|
Imports System.IO Imports System.Net |
VB code. Paste BELOW the Imports statements |
Copy Code
|
---|---|
Namespace MyClassLib Module StringExtensions Public Sub CopyTo(ByVal input As Stream, ByVal output As Stream) 'Add your code here End Sub Private Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T 'Add your code here End Function End Module Friend NotInheritable Class WebRequestHelper Private Sub New() End Sub ' Load raw data into MemoryStream from specified Url. Public Shared Function DownloadData(url As String, timeoutMilliseconds As Integer) As Stream 'Add your code here End Function 'oad raw data into MemoryStream from specified Url. Public Shared Sub DownloadDataAsync(url As String, timeoutMilliseconds As Integer, success As Action(Of MemoryStream), [error] As Action(Of Exception)) 'Add your code here End Sub Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T 'Add your code here End Function End Class End Namespace |
To write the code in C#
C# code. Paste on TOP |
Copy Code
|
---|---|
using System.IO; using System.Net; |
C# code. Paste BELOW the Using statements |
Copy Code
|
---|---|
namespace MyClassLib { internal static class WebRequestHelper { // Load raw data into MemoryStream from specified Url. public static Stream DownloadData(string url, int timeoutMilliseconds) {//Add your code here } public static void DownloadDataAsync(string url, int timeoutMilliseconds, Action<MemoryStream> success, Action<Exception> error) {//Add your code here } public static void CopyTo(this Stream input, Stream output) {//Add your code here } } } |
Caution: Grapecity.ActiveReports.config file should always be placed inside the same folder as the EndUserDesigner.exe file for displaying a tile layer on a Map. |
Paste between the <Configuration></Configuration> tags. |
Copy Code
|
---|---|
<!-- Register and configure custom tile provider. --> <MapTileProvider Name="Custom" DisplayName="Custom Provider" type="YourTileProvider, AssemblyName, Version = x.x.x.x"> <Settings> <add key="ApiKey" value="API Key" /> </Settings> </MapTileProvider> |
Note: Replace YourTileProvider with fully qualified class name and AssemblyName with the name of the assembly created after implementing IMapTileProvider and IMapTile interfaces. |