Exemplo n.º 1
0
        protected virtual JsonObjectBuilder ToJsonObjectBuilder(){
            var json = new JsonObjectBuilder();

            var pointsBuilder = new JsonArrayBuilder();
            foreach (var point in this.Points)
            {
                pointsBuilder.Add(point.Render());
            }
            json.Append("points", pointsBuilder.Render());

            if (this.LineWeight.HasValue)
            {
                json.Append("lineweight", this.LineWeight);
            }

            if (!string.IsNullOrEmpty(this.LineColor))
            {
                json.Append("linecolor", "'" + this.LineColor + "'");
            }

            if (this.LineOpacity.HasValue)
            {
                json.Append("lineopacity", this.LineOpacity);
            }

            // Special values that are for Bing Maps, give a better default behavior
            json.Append("B_showicon", false);

            return json;
        }
Exemplo n.º 2
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var response = context.HttpContext.Response;
            response.ContentType = "application/json";

            var json = new JsonObjectBuilder();

            json.Append("code", 200);

            if (this.Pushpins != null)
            {
                if (this.Pushpins.Count() > 0)
                {
                    var pushpinsJson = new JsonArrayBuilder();
                    foreach (var pin in this.Pushpins)
                    {
                        pushpinsJson.Add(pin);
                    }
                    json.Append("pushpins", pushpinsJson);
                }
            }

            if (this.Polylines != null)
            {
                if (this.Polylines.Count() > 0)
                {
                    var polylinesJson = new JsonArrayBuilder();
                    foreach (var pin in this.Polylines)
                    {
                        polylinesJson.Add(pin);
                    }
                    json.Append("polylines", polylinesJson);
               }
            }

            if (this.Polygons != null)
            {
                if (this.Polygons.Count() > 0)
                {
                    var polygonsJson = new JsonArrayBuilder();
                    foreach (var pin in this.Polygons)
                    {
                        polygonsJson.Add(pin);
                    }
                    json.Append("polygons", polygonsJson);
               }
            }

            response.Write(json.Render());
        }