/// <summary> /// Initializes a new KML <c><Document></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); }
/// <summary> /// Initializes a new KML <c><Document></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><Document></c> element. /// </summary> public KmlDocument() { StyleSelectors = new KmlStyleSelectorCollection(); Features = new KmlFeatureCollection(); }