예제 #1
0
        /// <summary>
        /// Retrieves an instance from script data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static MarkerShape FromScriptData(IDictionary <string, object> data)
        {
            if (data != null)
            {
                var    result = new MarkerShape();
                object value;

                if (data.TryGetValue("coords", out value))
                {
                    result.Coords = (int[])value;
                }
                if (data.TryGetValue("type", out value))
                {
                    MarkerShapeType type;
                    if (Enum.TryParse((string)value, true, out type))
                    {
                        result.Type = type;
                    }
                }

                return(result);
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// Retrieves an instance from script data.
        /// </summary>
        /// <param name="scriptObject">The script object.</param>
        /// <returns></returns>
        public static MarkerOptions FromScriptData(object scriptObject)
        {
            var data = scriptObject as IDictionary <string, object>;

            if (data != null)
            {
                var    result = new MarkerOptions();
                object value;

                if (data.TryGetValue("animation", out value))
                {
                    result.Animation = (MarkerAnimation)(int)value;
                }
                if (data.TryGetValue("clickable", out value))
                {
                    result.Clickable = (bool)value;
                }
                if (data.TryGetValue("cursor", out value))
                {
                    result.Cursor = (string)value;
                }
                if (data.TryGetValue("draggable", out value))
                {
                    result.Draggable = (bool)value;
                }
                if (data.TryGetValue("flat", out value))
                {
                    result.Flat = (bool)value;
                }
                if (data.TryGetValue("icon", out value))
                {
                    result.Icon = MarkerImage.FromScriptData((IDictionary <string, object>)value);
                }
                if (data.TryGetValue("optimized", out value))
                {
                    result.Optimized = (bool)value;
                }
                if (data.TryGetValue("position", out value))
                {
                    result.Position = LatLng.FromScriptData((IDictionary <string, object>)value);
                }
                if (data.TryGetValue("raiseOnDrag", out value))
                {
                    result.RaiseOnDrag = (bool)value;
                }
                if (data.TryGetValue("shadow", out value))
                {
                    result.Shadow = MarkerImage.FromScriptData((IDictionary <string, object>)value);
                }
                if (data.TryGetValue("shape", out value))
                {
                    result.Shape = MarkerShape.FromScriptData((IDictionary <string, object>)value);
                }
                if (data.TryGetValue("title", out value))
                {
                    result.Title = (string)value;
                }
                if (data.TryGetValue("visible", out value))
                {
                    result.Visible = (bool)value;
                }
                if (data.TryGetValue("zIndex", out value))
                {
                    result.ZIndex = (int)value;
                }

                return(result);
            }
            return(null);
        }