Getting Started

May 8, 2020 ยท View on GitHub

A good resource for how to use KML in general is the KML Reference from Google; this library has been designed to follow the names of KML elements as closely as possible.

For a quick example of how the library works, see the Basic Usage page or the Extracting information from a Kml file page.

For working with legacy files (for example, files created with an earlier version Google Earth), please see the Legacy Files page. Or for using some of the features offered in Google Earth, take a look at Google Earth compatibility page.

For a simple example of working with the elements inside a KML file, including extracting a specific type, see the Extracting Elements page.

If you need to do some advanced work with KML data, you may want to look at how you can extend the elements.

Although the library targets .NET Standard, you'll need to do a little extra work to get it to work with Unity.

For more examples, please see the Examples folder, which includes:

FileDescription
BalloonFeatures.csDisplays an information balloon text for all the Features in a KML file.
Change.csShows how KML can be updated by an Update element, and how to use the Process extension method to apply the update in code.
Clone.csShows how to copy Elements (an Element can only have one parent and throws an exception if you try to add it to another Element.)
CreateIconStyle.csCreates a simple IconStyle, based on the example given at the IconStyle documentation
CreateKml.csA simple example of creating a KML file from code.
CreateKmz.csA simple example of how to create a KMZ file, which is a compressed archive containing a KML file and related resources for that file.
InlineStyles.csUses the StyleResolver.InlineStyles static method to create a new Element that has the styles inside the Feature, instead of using shared styles and specifying a StyleUrl.
ParseKml.csShows how to use the Parser class to parse a KML file, ignoring any namespaces declared in the XML.
ShowStyles.csIterates over all the styles in a KML file and displays their names in alphabetical order.
SortPlacemarks.csIterates over the placemarks in a file and displays their names in alphabetical order.
SplitStyles.csMoves styles from a Feature to the enclosing Document and then sets the Feature.StyleUrl to reference the new style.