Since Q1 2011 and the newest release of the RadMap several changes were made to the control. Presently it is possible to specify several tile providers that will be displayed one over the other through the RadMap.Providers property. If your Map sources have tile size different from the default one (256x256) then all these sources must use the same tile size. For example if you want to have a satellite source with tile size 300x300 and a road source, the last one must use this tile size as well. If your map source uses a tile size different from the default one then you must override the ConvertTileToZoomLevel and ConvertZoomToTileLevel methods of the TiledMapSource class.
The changes made to the RadMap require slightly different approach for creating a Custom Map Provider than the one used before. This blogpost will demonstrate how to create a custom map provider using the NAVTEQ’s map as source and the latest binaries.
Since all existing custom providers (prior to Q1 2011) show map as a sequence of tiles, they should inherit the TiledMapSource class. TiledMapSource is a base class for map sources that return map tiles (that includes all BingMaps sources: aerial, road, bird’s eye, and all OpensStreetMap sources: Mapnik and Osmarenderer).
In order to create the custom provider with our latest binaries the following properties and methods should be overridden:
· MapProviderBase.SpatialReference (ISpatialReference) - the spatial reference is used for calculating and converting geographical values inside the map control. Usually it is an instance of the MercatorProjection class. Mercator is the projection used by most online maps including Bing Maps, Open Street Maps, Yahoo and etc.
· TiledMapSource.Initialize() - it is called when the provider should be initialized. It should call the RaiseInitializeCompleted method when the respective custom provider is initialized.
· Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY) - the method is used to return the URI of a tile according to tile level (tile level 9 is equal zoom level 1), X (column index) and Y (row index) of tile for level's matrix. The size of level's matrix is (2 ^ zoom level, 2 ^ zoom level).
It is now possible to customize the default set of commands in the MapCommandBar UI for every map provider. You can find more information about this in our help topic.
Telerik XAML Team
Subscribe to be the first to get our expert-written articles and tutorials for developers!