Coordinate Converters
By default all of built-in RadMap providers (Bing Maps, OpenStreetMap) use the standard Mercator projection. When reading shape files with different projections, then you can use a coordinate converter. To do this, set the CoordinateConverter
property of MapShapeReader
.
The RadMap contains two built-in converters which convert coordinates from EPSG:27700 and EPSG:3857 to EPSG:4326 projection.
- OSGB36Converter
- EPSG900913Converter
The converter (OSGB36Converter/ EPSG900913Converter) can be specified by setting it to the MapShapeReader.CoordinateConverter property.
Example 1: Setting CoordinateConverter property
<dataVisualization:RadMap>
<dataVisualization:RadMap.Providers>
<telerikMap:OpenStreetMapProvider />
</dataVisualization:RadMap.Providers>
<telerikMap:VisualizationLayer >
<telerikMap:VisualizationLayer.Reader>
<telerikMap:AsyncShapeFileReader >
<telerikMap:AsyncShapeFileReader.CoordinateConverter>
<telerikMap:EPSG900913Converter />
</telerikMap:AsyncShapeFileReader.CoordinateConverter>
</telerikMap:AsyncShapeFileReader>
</telerikMap:VisualizationLayer.Reader>
</telerikMap:VisualizationLayer>
</dataVisualization:RadMap>
Custom Coordinate Converter
The API of the RadMap allows you to use a custom coordinate converter by implementing the ICoordinateConverter interface.
Example 2: Implement ICoordinateConverter
public class CustomCoordinateConverter : ICoordinateConverter
{
public LocationCollection ConvertBack(LocationCollection collection)
{
return new LocationCollection();
}
public LocationCollection ConvertTo(LocationCollection collection)
{
return new LocationCollection();
}
public Location FromLocation(Location location)
{
return new Location();
}
public Location ToLocation(object coordinates)
{
return new Location();
}
public string ToString(Location location)
{
return location.ToString();
}
}
Example 3: Setting CustomCoordinateConverter in XAML
<dataVisualization:RadMap>
<dataVisualization:RadMap.Providers>
<telerikMap:OpenStreetMapProvider />
</dataVisualization:RadMap.Providers>
<telerikMap:VisualizationLayer >
<telerikMap:VisualizationLayer.Reader>
<telerikMap:AsyncShapeFileReader >
<telerikMap:AsyncShapeFileReader.CoordinateConverter>
<local:CustomCoordinateConverter />
</telerikMap:AsyncShapeFileReader.CoordinateConverter>
</telerikMap:AsyncShapeFileReader>
</telerikMap:VisualizationLayer.Reader>
</telerikMap:VisualizationLayer>
</dataVisualization:RadMap>