Enhanced functionality to support more KML elements was added in the ArcGIS Silverlight/WPF/Windows Phone API's at version 2.3. This brings the KML level of functionality very close to that of the KML specification used in Google Maps.
KML is an XML tag based syntax that holds geographic information (geometric shapes, symbology, and attributes) in a file with the .kml extension. The KmlLayer also support the KMZ specification which is essentially a set of zipped KML files, folders, and other documents (e.g. images, icons, html documents, etc. ) into a single file with the .kmz extension. To view the contents of a KMZ file, rename the file with the extension .zip and use a ZIP program to explode the contents onto a hard drive location.
KmlLayer is a GroupLayer
The KmlLayer is of Type
Note: The KML elements of <Folder>, <Document>, and <NetworkLink> become child KmlLayers (which can be recursive in nature depending on the KML/KMZ file) and are parsed into the ArcGIS Layer types noted in the prior table. Additionally, a KmlLayer can contain other KmlLayers (which again can be recursive).
Drilling into individual Layers and their subsequent atomic level Types of a KmlLayer GroupLayer is accomplished via the
Windows Phone specific issues
WPF specific issues
Accessing KML/KMZ on the local hard drive
Accessing a KmlLayer is unique in that ArcGIS Server is not required to view geographic information. Since the KmlLayer is based upon a KML or KMZ file, all that is required is a web server to host the KML/KMZ file. NOTE: ArcGIS Server has the ability to host geographic web services created in ArcMap as native KML/KMZ files.
Developers who wish to test the KmlLayer functionality using KML/KMZ files locally on their development machine have several options depending on the API platform that they are developing on.
In Silverlight:
Option #1: Developers can place the KML/KMZ file in the ClientBin directory of the test web site that is generated when creating a Silverlight application using Visual Studios built in web server (i.e. the directory that has the path: ..\[APPLICATION_NAME].Web\ClientBin). This option is the easiest method for testing KML/KMZ files when there is no web browser security issues because all of the KML/KMZ functionality is self contained. See the code example in the
NOTE: If the KML/KMZ file has hyperlinks (i.e. they begin with http://) to resources (such as other KML/KMZ files) to locations outside of your local network, IT WILL BE REQUIRED to use Option #2 for local testing of KML/KMZ files. Some common KML tags (or nested sub-tags) that can use external hyperlinks outside of your local network include the following: <href>, <Style>, <Icon>, <IconStyle>, <StyleMap>, <NetworkLink>, and <styleUrl>. Additionally, if you get a Security Exception or unhandled exception 4004 errors in Visual Studio during your Silverlight application debugging, you will most likely need to use Option #2 instead.
Option #2: If the developer has installed a web server on the same computer as Visual Studio (for example: Internet Information Server (IIS)), then they can place the KML/KMZ file in an application directory of their local web server (i.e. http://localhost). Using this option has the additional requirements of:
See the code example in the
In WPF:
Option #1: Because WPF does not have the same security restrictions as Silverlight, developers can place a KML/KMZ file anywhere on the local hard drive and provide the file path as the KmlLayer.Url (example: Url="C:\TEST_KML_FILES\Test.kml").
Option #2: If developers want to use a local web server (like IIS) to place their KML/KMZ files for testing, they are free to do so just like in Silverlight (example: Url="http://localhost/TEST_KML_FILES/Test.kml"). NOTE: WPF does not use proxies so the use of KmlLayer.ProxyUrl is not necessary (even though the local KML file may have resource links (i.e. http://) to locations outside of the local network).
In Windows Phone:
Option #1: If developers want to use a local web server (like IIS) to place their KML/KMZ files for testing, they are free to do so just like in Silverlight (example: Url="http://localhost/TEST_KML_FILES/Test.kml"). NOTE: Windows Phone does not use proxies so the use of KmlLayer.ProxyUrl is not necessary (even though the local KML file may have resource links (i.e. http://) to locations outside of the local network).
Supported KML Tags
The following table lists the KML elements supported by the KmlLayer class, and provides additional notes for elements that are conditionally supported.