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

            json.Append("url", string.Format("'{0}'", this.Url));

            if (this.AutoLoad.HasValue)
            {
                json.Append("autoload", this.AutoLoad);
            }

            if (!string.IsNullOrEmpty(this.DisplayData))
            {
                json.Append("displaydata", this.DisplayData);
            }
            else
            {
                if (!string.IsNullOrEmpty(this.DataLoaded))
                {
                    json.Append("dataloaded", this.DataLoaded);
                }
            }

            return(json);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        internal virtual JsonObjectBuilder ToJsonObjectBuilder()
        {
            var json = new JsonObjectBuilder();

            json.Append("lat", this.Latitude);
            json.Append("lng", this.Longitude);
            return(json);
        }
Esempio n. 4
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());
        }
Esempio n. 5
0
        protected virtual JsonObjectBuilder ToJsonObjectBuilder()
        {
            //var json = new JsonObjectBuilder();
            //json.Append("lat", this.Position.Latitude);
            //json.Append("lng", this.Position.Longitude);
            var json = this.Position.ToJsonObjectBuilder();

            if (!string.IsNullOrEmpty(this.Title))
            {
                json.Append("title", "\"" + this.Title + "\"");
            }

            if (!string.IsNullOrEmpty(this.Description))
            {
                json.Append("desc", "\"" + this.Description + "\"");
            }

            if (!string.IsNullOrEmpty(this.ImageUrl))
            {
                string strImageUrl = this.ImageUrl;
                if (this.ImageUrl.StartsWith("~"))
                {
                    strImageUrl = VirtualPathUtility.ToAbsolute(this.ImageUrl, HttpContext.Current.Request.ApplicationPath);
                }
                json.Append("imageurl", "'" + strImageUrl + "'");
            }

            if (this.ImageSize != null)
            {
                var jsonImageSize = new JsonObjectBuilder();
                jsonImageSize.Append("w", this.ImageSize.Width);
                jsonImageSize.Append("h", this.ImageSize.Height);
                json.Append("imagesize", jsonImageSize);
            }

            return(json);
        }
Esempio n. 6
0
        protected override JsonObjectBuilder ToJsonObjectBuilder()
        {
            var json = base.ToJsonObjectBuilder();

            json.Append("G_ShowEvent", this.ShowInfoEvent.ToJsonValue());

            if (this.ImageSize != null)
            {
                var jsonImageSize = new JsonObjectBuilder();
                jsonImageSize.Append("w", this.ImageSize.Width);
                jsonImageSize.Append("h", this.ImageSize.Height);
                json.Append("G_ImageSize", jsonImageSize);
            }

            if (this.ImageOffset != null)
            {
                var jsonImageOffset = new JsonObjectBuilder();
                jsonImageOffset.Append("x", this.ImageOffset.X);
                jsonImageOffset.Append("y", this.ImageOffset.Y);
                json.Append("G_ImageOffset", jsonImageOffset);
            }

            return(json);
        }
 public override string BuildObject(JsonObjectBuilder builder, string propertyName) {
     return string.Concat(propertyName, ":", builder.Build(JsonObjectType.Array));
 }
 public void GivenIHaveInstantiatedAJsonObjectBuilder() {
     _jsonObjectBuilder = new JsonObjectBuilder(_reader, new JsonContainerFactory(), new JsonReader(_reader));
 }
 public void GivenIHaveInstantiatedAJsonObjectBuilder()
 {
     _jsonObjectBuilder = new JsonObjectBuilder(_reader, new JsonContainerFactory(), new JsonReader(_reader));
 }
Esempio n. 10
0
        protected virtual void RenderObjectInitializer(TextWriter writer)
        {
            writer.Write("var {0} = null;", this.MapID);
            writer.Write("$(function(){");

            writer.Write("{0}=new {1}('{2}',", this.MapID, this._javascriptObject, this.ContainerID);


            var json = new JsonObjectBuilder(this.CustomInitializerOptions);

            json.Append("id", string.Format("'{0}'", this.MapID));

            if (this.CenterLatitude.HasValue && this.CenterLongitude.HasValue)
            {
                json.Append("lat", this.CenterLatitude).Append("lng", this.CenterLongitude);
            }

            if (this.ZoomLevel.HasValue)
            {
                json.Append("zoom", this.ZoomLevel);
            }

            if (this.IsFixed.HasValue)
            {
                json.Append("fixed", (this.IsFixed.Value ? "true" : "false"));
            }

            var resolvedMapType = this.ResolveMapType();

            if (resolvedMapType != null)
            {
                json.Values["maptype"] = resolvedMapType;
            }

            if (this._loadScripts.Count > 0)
            {
                json.Append("onLoad", string.Format("{0}_onLoadMap", this.ContainerID));
            }

            if (this.Pushpins.Count > 0)
            {
                json.Append("pushpins", this.RenderPushpins());
            }

            if (this.Polylines.Count > 0)
            {
                json.Append("polylines", this.RenderPolylines());
            }

            if (this.Polygons.Count > 0)
            {
                json.Append("polygons", this.RenderPolygons());
            }

            if (this.DynamicMapOptions != null)
            {
                json.Append("dynamicmap", this.DynamicMapOptions.Render());
            }

            writer.Write(json.Render());


            writer.Write(");");

            writer.Write("});");
        }
 public override string BuildObject(JsonObjectBuilder builder, string propertyName)
 {
     return(string.Concat(propertyName, ":", builder.Build(JsonObjectType.Object)));
 }