Google.Maps.StaticMaps.StaticMapRequest.GetMarkersStr C# (CSharp) Méthode

GetMarkersStr() private méthode

Builds markers uri parameter(s)
private GetMarkersStr ( ) : string
Résultat string
        private string GetMarkersStr()
        {
            if(this.Markers.Count == 0) return null;

            System.Text.StringBuilder sb = new System.Text.StringBuilder(200);

            string[] markerStrings = new string[this.Markers.Count];
            int markerStringsIndex = 0;

            foreach(MapMarkers current in this.Markers)
            {
                //start with an empty stringbuilder.
                sb.Remove(0, sb.Length);

                //output the size parameter, if it was specified.
                if(current.MarkerSize != MarkerSizes.Unspecified)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                    sb.AppendFormat("size:{0}", current.MarkerSize.ToString().ToLowerInvariant());
                }

                //check for a color specified for the markers and add that style attribute if so
                if(current.Color.Equals(Color.Empty) == false)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);

                    if(current.Color.IsNamedColor && Constants.IsExpectedNamedColor(current.Color.Name))
                    {
                        sb.AppendFormat("color:{0}", current.Color.Name.ToLowerInvariant());
                    }
                    else
                    {
                        sb.AppendFormat("color:0x{0:X6}", (current.Color.ToArgb() & 0x00FFFFFF));
                    }
                }

                //add a label, but if the MarkerSize is MarkerSizes.Tiny then you can't have a label.
                if(string.IsNullOrEmpty(current.Label) == false && current.MarkerSize != MarkerSizes.Tiny)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                    sb.AppendFormat("label:{0}", current.Label);
                }

                //add a custom icon param
                if(string.IsNullOrEmpty(current.IconUrl) == false)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                    sb.AppendFormat("icon:{0}", Uri.EscapeDataString(current.IconUrl));

                    if(current.Shadow != null)
                    {
                        if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                        sb.AppendFormat("shadow:{0}", (current.Shadow == true ? "true" : "false"));
                    }
                }

                //add a custom scale param
                if(current.Scale != null)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                    sb.AppendFormat("scale:{0}", current.Scale.Value);
                }

                //iterate the locations
                foreach(Location loc in current.Locations)
                {
                    if(sb.Length > 0) sb.Append(Constants.PIPE_URL_ENCODED);
                    sb.Append(loc.GetAsUrlParameter());
                }

                markerStrings[markerStringsIndex++] = "markers=" + sb.ToString();
            }

            return string.Join("&", markerStrings);
        }