Exemplo n.º 1
0
        /// <summary>
        /// Writes an XML representation of RenderSettings
        /// </summary>
        /// <param name="writer"></param>
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("renderer");

            writer.WriteStartElement("MinZoomLevel");
            writer.WriteString(MinZoomLevel.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            writer.WriteStartElement("MaxZoomLevel");
            writer.WriteString(MaxZoomLevel.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            //writer.WriteStartElement("MinExtentDimension");
            //writer.WriteString(MinLabelExtentDim.ToString());
            //writer.WriteEndElement();


            writer.WriteStartElement("MinRenderLabelZoom");
            writer.WriteString(MinRenderLabelZoom.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();


            writer.WriteStartElement("FieldName");
            writer.WriteString(FieldName);
            writer.WriteEndElement();

            writer.WriteStartElement("Font");
            writer.WriteAttributeString("Size", this.Font.Size.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteAttributeString("Name", this.Font.Name);
            writer.WriteAttributeString("Style", this.Font.Style.ToString());
            writer.WriteFullEndElement();

            writer.WriteStartElement("FontColor");
            if (FontColor.A < 255)
            {
                writer.WriteAttributeString("alpha", FontColor.A.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            writer.WriteString(ColorTranslator.ToHtml(FontColor));
            writer.WriteEndElement();

            writer.WriteStartElement("FillColor");
            if (FillColor.A < 255)
            {
                writer.WriteAttributeString("alpha", FillColor.A.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            writer.WriteString(ColorTranslator.ToHtml(FillColor));
            writer.WriteEndElement();

            writer.WriteStartElement("OutlineColor");
            if (OutlineColor.A < 255)
            {
                writer.WriteAttributeString("alpha", OutlineColor.A.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            writer.WriteString(ColorTranslator.ToHtml(OutlineColor));
            writer.WriteEndElement();

            writer.WriteStartElement("PenWidthScale");
            writer.WriteString(this.PenWidthScale.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            writer.WriteStartElement("MaxPixelPenWidth");
            writer.WriteString(this.MaxPixelPenWidth.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            writer.WriteStartElement("MinPixelPenWidth");
            writer.WriteString(this.MinPixelPenWidth.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            writer.WriteStartElement("FillInterior");
            writer.WriteString(this.FillInterior.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("Selectable");
            writer.WriteString(this.IsSelectable.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("SelectOutlineColor");
            if (SelectOutlineColor.A < 255)
            {
                writer.WriteAttributeString("alpha", SelectOutlineColor.A.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            writer.WriteString(ColorTranslator.ToHtml(SelectOutlineColor));
            writer.WriteEndElement();

            writer.WriteStartElement("SelectFillColor");
            if (SelectFillColor.A < 255)
            {
                writer.WriteAttributeString("alpha", SelectFillColor.A.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            writer.WriteString(ColorTranslator.ToHtml(SelectFillColor));
            writer.WriteEndElement();

            writer.WriteStartElement("LineType");
            writer.WriteString(this.LineType.ToString());
            writer.WriteEndElement();

            if (!string.IsNullOrEmpty(PointImageSymbol) && System.IO.File.Exists(PointImageSymbol))
            {
                writer.WriteStartElement("PointImageSymbol");
                writer.WriteString(PointImageSymbol);
                writer.WriteEndElement();
            }

            writer.WriteStartElement("ShadowText");
            writer.WriteString(this.ShadowText.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("PointSize");
            writer.WriteString(this.PointSize.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();


            writer.WriteStartElement("UseToolTip");
            writer.WriteString(this.UseToolTip.ToString());
            writer.WriteEndElement();

            if (!string.IsNullOrEmpty(this.ToolTipFieldName))
            {
                writer.WriteStartElement("ToolTipFieldName");
                writer.WriteString(this.ToolTipFieldName);
                writer.WriteEndElement();
            }

            writer.WriteStartElement("StringEncoding");
            writer.WriteString(this.StringEncoding.CodePage.ToString(System.Globalization.CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Render all the HTML and Javascript needed to make this control work properly.
        /// </summary>
        /// <param name="output">Unused parameter</param>
        protected override void Render(HtmlTextWriter output)
        {
            StringBuilder script = new StringBuilder();


            //
            // Generate the DIV tag on the page that google maps will use.
            //
            output.Write("<div id=\"{0}\" style=\"width: {1}px; height: {2}px;\"></div>", this.ClientID, this.Width, this.Height);

            //
            // Generate the start of the script needed to populate the map.
            //
            script.Append("<script language=\"javascript\" type=\"text/javascript\">\n" +
                          "    var " + this.ClientObject + " = null;\n" +
                          "    $(window).load(function() {\n" +
                          "        var o = {};\n");
            script.AppendLine("        o.zoom = " + ZoomLevel.ToString() + ";");
            if (MinZoomLevel != -1)
            {
                script.AppendLine("        o.minZoom = " + MinZoomLevel.ToString() + ";");
            }
            if (MaxZoomLevel != -1)
            {
                script.AppendLine("        o.maxZoom = " + MaxZoomLevel.ToString() + ";");
            }
            if (HideControls == true)
            {
                script.AppendLine("        o.disableDefaultUI = true;");
            }
            else
            {
                if (ShowMapType == false)
                {
                    script.AppendLine("        o.mapTypeControl = false;");
                }
                if (ShowPanControls == false)
                {
                    script.AppendLine("        o.panControl = false;");
                }
                if (ShowStreetView == false)
                {
                    script.AppendLine("        o.streetViewControl = false;");
                }
                if (ShowZoomControls == false)
                {
                    script.AppendLine("        o.scaleControl = false;");
                    script.AppendLine("        o.zoomControl = false;");
                }
            }
            if (StaticMap == true)
            {
                script.AppendLine("        o.disableDoubleClickZoom = true");
                script.AppendLine("        o.draggable = false;");
                script.AppendLine("        o.keyboardShortcuts = false;");
                script.AppendLine("        o.mapTypeControl = false;");
                script.AppendLine("        o.minZoom = " + ZoomLevel.ToString() + ";");
                script.AppendLine("        o.maxZoom = " + ZoomLevel.ToString() + ";");
                script.AppendLine("        o.panControl = false;");
                script.AppendLine("        o.scaleControl = false;");
                script.AppendLine("        o.scrollwheel = false;");
                script.AppendLine("        o.streetViewControl = false;");
                script.AppendLine("        o.zoomControl = false;");
            }
            script.Append("        var " + this.ClientObject + " = new GoogleMap(\"" + this.ClientID + "\", new GeoAddress(" + Center.Latitude.ToString() + ", " + Center.Longitude.ToString() + "), \"\", o);\n");

            //
            // Render in all the other elements.
            //
            RenderPlacemarks(script);
            RenderLoaders(script);

            //
            // Generate the final sequence of the script.
            //
            script.Append("    });\n</script>");

            //
            // Register the startup script commands.
            //
            Page.ClientScript.RegisterStartupScript(typeof(Page), this.ClientID, script.ToString());

            //
            // Render child controls.
            //
            commandDiv.RenderControl(output);
            if (HideDownload == false)
            {
                downloadDiv.RenderControl(output);
            }
            if (HideAddToTag == false)
            {
                profileDiv.RenderControl(output);
            }
        }