/// <summary>
        /// Initializes a new KML <c>&lt;Document&gt;</c> element.
        /// </summary>
        /// <param name="xml">The XML element the document should be based on.</param>
        /// <param name="namespaces">The XML namespace.</param>
        protected KmlDocument(XElement xml, XmlNamespaceManager namespaces) : base(xml, namespaces)
        {
            NetworkLink = xml.GetElement("kml:NetworkLink", namespaces, KmlNetworkLink.Parse);

            List <KmlStyleSelector> selectors = new List <KmlStyleSelector>();

            List <KmlFeature> features = new List <KmlFeature>();

            foreach (XElement child in xml.Elements())
            {
                switch (child.Name.LocalName)
                {
                case "Style":
                    selectors.Add(KmlStyle.Parse(child, namespaces));
                    break;

                case "StyleMap":
                    selectors.Add(KmlStyleMap.Parse(child, namespaces));
                    break;

                case "Document":
                    features.Add(KmlDocument.Parse(child, namespaces));
                    break;

                case "Folder":
                    features.Add(KmlFolder.Parse(child, namespaces));
                    break;

                case "NetworkLink":
                    features.Add(KmlNetworkLink.Parse(child, namespaces));
                    break;

                case "Placemark":
                    features.Add(KmlPlacemark.Parse(child, namespaces));
                    break;

                case "GroundOverlay":
                case "PhotoOverlay":
                case "ScreenOverlay":
                    // currently not supported
                    break;
                }
            }

            StyleSelectors = new KmlStyleSelectorCollection(selectors);
            Features       = new KmlFeatureCollection(features);
        }
Example #2
0
 /// <summary>
 /// Initializes a new empty KML <c>&lt;Folder&gt;</c> element.
 /// </summary>
 /// <param name="xml">The XML element the folder should be based on.</param>
 /// <param name="namespaces">The XML namespace.</param>
 protected KmlFolder(XElement xml, XmlNamespaceManager namespaces)
 {
     Id       = xml.GetAttributeValue("id");
     Name     = xml.GetElementValue("kml:name", namespaces);
     Features = xml.GetElements("kml:Placemark", namespaces, KmlPlacemark.Parse);
 }
Example #3
0
 /// <summary>
 /// Initializes a new empty KML <c>&lt;Folder&gt;</c> element containing the specified <paramref name="features"/>.
 /// </summary>
 /// <param name="features">An array of features to add to the folder.</param>
 public KmlFolder(IEnumerable <KmlFeature> features)
 {
     Features = new KmlFeatureCollection(features);
 }
Example #4
0
 /// <summary>
 /// Initializes a new empty KML <c>&lt;Folder&gt;</c> element containing the specified <paramref name="placemarks"/>.
 /// </summary>
 /// <param name="placemarks">An array of placemarks to add to the folder.</param>
 public KmlFolder(IEnumerable <KmlPlacemark> placemarks)
 {
     Features = new KmlFeatureCollection(placemarks);
 }
 /// <summary>
 /// Initializes a new KML <c>&lt;Document&gt;</c> element containing the specified <paramref name="features"/>.
 /// </summary>
 /// <param name="features">An array of features to add to the document.</param>
 public KmlDocument(params KmlFeature[] features)
 {
     StyleSelectors = new KmlStyleSelectorCollection();
     Features       = features ?? new KmlFeatureCollection();
 }
 /// <summary>
 /// Initializes a new empty KML <c>&lt;Document&gt;</c> element.
 /// </summary>
 public KmlDocument()
 {
     StyleSelectors = new KmlStyleSelectorCollection();
     Features       = new KmlFeatureCollection();
 }