Beispiel #1
0
        public static XmlElement CreatePlacemark(XmlDocument document, Waypoint wp, bool visible, bool showLabel, bool paddleMarker, bool ssidLabel)
        {
            //Create the main placemark element
            XmlElement xeMain = document.CreateElement("Placemark");

            string color = KmlWriter.EncryptionColor(wp.Extensions.Security);

            //Visibility is default true
            xeMain.AppendChild(CreateElementWithText(document, "visibility", visible ? "1" : "0"));

            //placemark style
            XmlElement xeStyle = document.CreateElement("Style");

            xeStyle.SetAttribute("id", "sn_shaded_dot");

            XmlElement xeIconStyle = document.CreateElement("IconStyle");
            XmlElement xeIcon      = document.CreateElement("Icon");

            xeIcon.AppendChild(CreateElementWithText(document, "href",
                                                     paddleMarker
                                                         ? "http://maps.google.com/mapfiles/kml/paddle/wht-blank.png"
                                                         : "http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png"));
            //Add icon element to iconstyle element
            xeIconStyle.AppendChild(xeIcon);

            xeIconStyle.AppendChild(CreateElementWithText(document, "color", color));
            xeIconStyle.AppendChild(CreateElementWithText(document, "scale", KmlWriter.IconScale(wp.Extensions.Rssi).ToString(CultureInfo.InvariantCulture)));

            //Add element
            xeStyle.AppendChild(xeIconStyle);

            //LabelStyle element
            XmlElement xeLabelStyle = document.CreateElement("LabelStyle");

            xeLabelStyle.AppendChild(CreateElementWithText(document, "color", color));
            xeLabelStyle.AppendChild(CreateElementWithText(document, "scale", showLabel ? "1" : "0"));

            //Add element
            xeStyle.AppendChild(xeLabelStyle);

            //Add Style to main placemark element
            xeMain.AppendChild(xeStyle);

            //Add name element
            xeMain.AppendChild(CreateElementWithText(document, "name", ssidLabel ? wp.Extensions.Ssid + ": " + wp.Extensions.Rssi : wp.Extensions.Rssi.ToString(CultureInfo.InvariantCulture)));

            //Add description element
            xeMain.AppendChild(CreateElementWithText(document, "description", wp.BuildKmlDescription()));
            //Location
            //KML requires Lon,Lat,Alt. It's backwards!
            XmlElement xePoint = document.CreateElement("Point");

            xePoint.AppendChild(CreateElementWithText(document, "coordinates",
                                                      string.Format("{0},{1},{2}",
                                                                    wp.Longitude.ToString(CultureInfo.InvariantCulture.NumberFormat),
                                                                    wp.Latitude.ToString(CultureInfo.InvariantCulture.NumberFormat),
                                                                    wp.Elevation.ToString(CultureInfo.InvariantCulture.NumberFormat))));
            xeMain.AppendChild(xePoint);

            return(xeMain);
        }