Good evening,
I´m trying to build my own map provider. I have my tiles for an specific country.
How could I project my tiles to their proper coordinates?
Provider is working but with wrong coordinates. Below is my code.
Thank you very much,
Esther
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Text
Imports Telerik.Windows.Controls.Map
Public Class NavteqTilesProvider
Inherits MapProviderBase
Private Const TILE_SIZE As Integer = 256
Private initialized As Boolean
Private m_tileLocation As String
''' <summary>
''' Initializes a new instance of the FileSystemProvider class.
''' </summary>
''' <param name="mode">Map mode.</param>
''' <param name="labelVisible">Is labels visible.</param>
Public Sub New(ByVal tileLocation As String)
MyBase.New(MapMode.Road, True)
Me.m_tileLocation = tileLocation
End Sub
''' <summary>
''' Initializes a new instance of the FileSystemProvider class.
''' </summary>
Public Sub New()
Me.New(Nothing)
End Sub
''' <summary>
''' Gets or sets location of the map tiles.
''' </summary>
Public Property TileLocation() As String
Get
Return Me.m_tileLocation
End Get
Set(ByVal value As String)
Me.m_tileLocation = value
End Set
End Property
' ''' <summary>
' ''' Gets the IsInitialized property.
' ''' Indicates that the provider is initialized.
' ''' </summary>
''' <summary>
''' Gets value which indicates whether labels are supported by the map provider.
''' </summary>
Public Overrides ReadOnly Property IsLabelSupported() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Returns the SpatialReference for the map provider.
''' </summary>
Public Overrides ReadOnly Property SpatialReference() As ISpatialReference
Get
Return New MercatorProjection()
End Get
End Property
''' <summary>
''' Gets list of the supported map modes.
''' </summary>
''' <returns>List of the supported map modes.</returns>
Public Overrides ReadOnly Property SupportedModes() As IEnumerable(Of MapMode)
Get
Dim list As New List(Of MapMode)
list.Add(MapMode.Road)
Return list
End Get
End Property
''' <summary>
''' Gets the image URI.
''' </summary>
''' <param name="tileLevel">Tile level.</param>
''' <param name="tilePositionX">Tile X.</param>
''' <param name="tilePositionY">Tile Y.</param>
''' <returns>URI of image.</returns>
Public Overrides Function GetTile(ByVal tileLevel As Integer, ByVal tilePositionX As Integer, ByVal tilePositionY As Integer) As Uri
Dim zoomLevel As Integer = ConvertTileToZoomLevel(tileLevel)
Dim tileFileName As String = String.Format("map_{0}_{1}_{2}.png", tilePositionX, tilePositionY, zoomLevel)
tileFileName = Path.Combine(Me.TileLocation, tileFileName)
If File.Exists(tileFileName) Then
Return New Uri(tileFileName)
Else
Return Nothing
End If
End Function
''' <summary>
''' Initialize provider.
''' </summary>
Public Overrides Sub Initialize()
Me.initialized = MyBase.IsInitialized
End Sub
''' <summary>
''' Gets value which indicates whether given mode is supported by map provider.
''' </summary>
''' <param name="mode">Map mode to check.</param>
''' <returns>true if given mode is supported. Otherwise - false.</returns>
Public Overrides Function IsModeSupported(ByVal mode As MapMode) As Boolean
Return (mode = MapMode.Road)
End Function
''' <summary>
''' MapModeChanged handler.
''' </summary>
Protected Overrides Sub OnMapModeChanged(ByVal oldMode As MapMode, ByVal newMode As MapMode)
If Not Me.IsSuspended Then
Me.Initialize()
End If
End Sub
End Class
I´m trying to build my own map provider. I have my tiles for an specific country.
How could I project my tiles to their proper coordinates?
Provider is working but with wrong coordinates. Below is my code.
Thank you very much,
Esther
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Text
Imports Telerik.Windows.Controls.Map
Public Class NavteqTilesProvider
Inherits MapProviderBase
Private Const TILE_SIZE As Integer = 256
Private initialized As Boolean
Private m_tileLocation As String
''' <summary>
''' Initializes a new instance of the FileSystemProvider class.
''' </summary>
''' <param name="mode">Map mode.</param>
''' <param name="labelVisible">Is labels visible.</param>
Public Sub New(ByVal tileLocation As String)
MyBase.New(MapMode.Road, True)
Me.m_tileLocation = tileLocation
End Sub
''' <summary>
''' Initializes a new instance of the FileSystemProvider class.
''' </summary>
Public Sub New()
Me.New(Nothing)
End Sub
''' <summary>
''' Gets or sets location of the map tiles.
''' </summary>
Public Property TileLocation() As String
Get
Return Me.m_tileLocation
End Get
Set(ByVal value As String)
Me.m_tileLocation = value
End Set
End Property
' ''' <summary>
' ''' Gets the IsInitialized property.
' ''' Indicates that the provider is initialized.
' ''' </summary>
''' <summary>
''' Gets value which indicates whether labels are supported by the map provider.
''' </summary>
Public Overrides ReadOnly Property IsLabelSupported() As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Returns the SpatialReference for the map provider.
''' </summary>
Public Overrides ReadOnly Property SpatialReference() As ISpatialReference
Get
Return New MercatorProjection()
End Get
End Property
''' <summary>
''' Gets list of the supported map modes.
''' </summary>
''' <returns>List of the supported map modes.</returns>
Public Overrides ReadOnly Property SupportedModes() As IEnumerable(Of MapMode)
Get
Dim list As New List(Of MapMode)
list.Add(MapMode.Road)
Return list
End Get
End Property
''' <summary>
''' Gets the image URI.
''' </summary>
''' <param name="tileLevel">Tile level.</param>
''' <param name="tilePositionX">Tile X.</param>
''' <param name="tilePositionY">Tile Y.</param>
''' <returns>URI of image.</returns>
Public Overrides Function GetTile(ByVal tileLevel As Integer, ByVal tilePositionX As Integer, ByVal tilePositionY As Integer) As Uri
Dim zoomLevel As Integer = ConvertTileToZoomLevel(tileLevel)
Dim tileFileName As String = String.Format("map_{0}_{1}_{2}.png", tilePositionX, tilePositionY, zoomLevel)
tileFileName = Path.Combine(Me.TileLocation, tileFileName)
If File.Exists(tileFileName) Then
Return New Uri(tileFileName)
Else
Return Nothing
End If
End Function
''' <summary>
''' Initialize provider.
''' </summary>
Public Overrides Sub Initialize()
Me.initialized = MyBase.IsInitialized
End Sub
''' <summary>
''' Gets value which indicates whether given mode is supported by map provider.
''' </summary>
''' <param name="mode">Map mode to check.</param>
''' <returns>true if given mode is supported. Otherwise - false.</returns>
Public Overrides Function IsModeSupported(ByVal mode As MapMode) As Boolean
Return (mode = MapMode.Road)
End Function
''' <summary>
''' MapModeChanged handler.
''' </summary>
Protected Overrides Sub OnMapModeChanged(ByVal oldMode As MapMode, ByVal newMode As MapMode)
If Not Me.IsSuspended Then
Me.Initialize()
End If
End Sub
End Class