New to Telerik UI for WinForms? Download free 30-day trial

KML Reader

RadMap provides support for stunning map overlays through its KML-import feature. Once you have the desired set of features (place marks, images, polygons, textual descriptions, etc.) encoded in KML, you can easily import the data and visualize it through the RadMap control. In this way you can easily visualize complex shapes like country's borders on the map and fill the separate shapes with different colors in order to achieve a sort of grouping.

Figure 1: KML Reader

WinForms RadMap KML Reader

To read your data you have to use a KmlReader.

Using KmlReader


OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
this.radMap1.MapElement.Providers.Add(osmProvider);
this.radMap1.Layers.Clear();
this.radMap1.Layers.Add(new MapLayer("Capitals"));
using (FileStream seatsStream = new FileStream(@"..\..\Resources\cb_2015_us_county_5m.kml", FileMode.Open, FileAccess.Read))
{
List<MapVisualElement> elements = KmlReader.Read(seatsStream);
foreach (MapVisualElement item in elements)
{
item.BorderWidth = 1;
item.BorderColor = Color.Red;
}
        this.radMap1.Layers["Capitals"].AddRange(elements);
}

Dim osmProvider As New OpenStreetMapProvider()
Me.radMap1.MapElement.Providers.Add(osmProvider)
Me.radMap1.Layers.Clear()
Me.radMap1.Layers.Add(New MapLayer("Capitals"))
Using seatsStream As New FileStream("..\..\Resources\cb_2015_us_county_5m.kml", FileMode.Open, FileAccess.Read)
    Dim elements As List(Of MapVisualElement) = KmlReader.Read(seatsStream)
    For Each item As MapVisualElement In elements
        item.BorderWidth = 1
        item.BorderColor = Color.Red
    Next
    Me.radMap1.Layers("Capitals").AddRange(elements)
End Using

Using local images

The KmlReader supports loading images from a local folder. The KmlReader class has two static properties that controls this functionality:

  • UseLocalImages: A boolean property which enables the local image loading.
  • LocalImagesFolder: The folder that contains all images.

See Also

In this article