windowsforms-devexpress-dot-xtramap-dot-kmlfiledataadapter-390547ac.md
Downloading map data passed through URLs specified by the FileUri property may create security issues. Review the following help topic and learn how to spot, analyze, and prohibit unwanted download requests:
Suppress Control Requests to Download Data from External URLs
Gets or sets a URI that defines the KML file location.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
[DefaultValue(null)]
public Uri FileUri { get; set; }
<DefaultValue(Nothing)>
Public Property FileUri As Uri
| Type | Default | Description |
|---|---|---|
| Uri | null |
A Uri object that specifies a path to a KML file.
|
To load shape data from a KML file do the following.
KmlFileDataAdapter.FileUri property.using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForms_MapControl_KmlFileDataAdapter {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using DevExpress.XtraMap;
using System;
using System.Windows.Forms;
namespace WinForms_MapControl_KmlFileDataAdapter {
public partial class Form1 : Form {
const string filePath = "../../kmlFile.kml";
VectorItemsLayer KmlLayer { get { return (VectorItemsLayer)mapControl1.Layers["KmlLayer"]; } }
public Form1() {
InitializeComponent();
#region #KmlFileDataAdapter
// Create a KML file data adapter.
Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);
KmlLayer.Data = new KmlFileDataAdapter() {
FileUri = new Uri(baseUri, filePath)
};
#endregion #KmlFileDataAdapter
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms
Namespace WinForms_MapControl_KmlFileDataAdapter
Friend NotInheritable Class Program
Private Sub New()
End Sub
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
End Namespace
Imports DevExpress.XtraMap
Imports System
Imports System.Windows.Forms
Namespace WinForms_MapControl_KmlFileDataAdapter
Partial Public Class Form1
Inherits Form
Private Const filePath As String = "../../kmlFile.kml"
Private ReadOnly Property KmlLayer() As VectorItemsLayer
Get
Return CType(mapControl1.Layers("KmlLayer"), VectorItemsLayer)
End Get
End Property
Public Sub New()
InitializeComponent()
' #Region "#KmlFileDataAdapter"
' Create a KML file data adapter.
Dim baseUri As New Uri(System.Reflection.Assembly.GetEntryAssembly().Location)
KmlLayer.Data = New KmlFileDataAdapter() With {.FileUri = New Uri(baseUri, filePath)}
' #End Region ' #KmlFileDataAdapter
End Sub
End Class
End Namespace
See Also