/// <summary>
        /// This method visits a KML placemark element
        /// </summary>
        /// <param name="elem">KML placemark element</param>
        protected void VisitPlacemark(XmlElement elem)
        {
            if (elem == null)
            {
                return;
            }

            var placemark = new Placemark();

            placemark.Id = GetAttribute(elem, "id");

            // Visits the child nodes
            foreach (XmlNode child in elem.ChildNodes)
            {
                var childName = child.Name.ToLowerInvariant();
                if (childName.Equals("name"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Name = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("description"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Description = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("address"))
                {
                    if (child.HasChildNodes)
                    {
                        placemark.Address = child.ChildNodes[0].InnerText;
                    }
                }
                else if (childName.Equals("lookat") && (child as XmlElement) != null)
                {
                    var numOfGeographiesBefore = Geographies.Count;

                    VisitLookAt(child as XmlElement);

                    var numOfGeographiesAfter = Geographies.Count;

                    if (numOfGeographiesAfter > numOfGeographiesBefore)
                    {
                        // Point found where this placemark looks at

                        placemark.LookAt = Geographies[Geographies.Count - 1];
                        Geographies.RemoveAt(Geographies.Count - 1);
                    }
                }
                else
                {
                    var numOfGeographiesBefore = Geographies.Count;

                    Visit(child);

                    var numOfGeographiesAfter = Geographies.Count;

                    if (numOfGeographiesAfter > numOfGeographiesBefore)
                    {
                        // Found the geography instance which describes this placemark

                        placemark.Geography = Geographies[Geographies.Count - 1];
                    }
                }
            }

            Placemarks.Add(placemark);
        }
Example #2
0
 public void AddPlacemark(KmlPlacemark placemark)
 {
     Placemarks.Add(placemark);
 }