Esempio n. 1
0
        /// <summary>
        /// Create circles list
        /// </summary>
        /// <param name="jsRuntime"></param>
        /// <param name="opts">Dictionary of desired Circle keys and CircleOptions values. Key as any type unique key. Not nessary Guid</param>
        /// <returns>new instance of CircleList class will be returned with its Circles dictionary member populated with the corresponding results</returns>
        public static async Task <CircleList> CreateAsync(IJSRuntime jsRuntime, Dictionary <string, CircleOptions> opts)
        {
            JsObjectRef jsObjectRef = new JsObjectRef(jsRuntime, Guid.NewGuid());

            CircleList obj;
            Dictionary <string, JsObjectRef> jsObjectRefs = await JsObjectRef.CreateMultipleAsync(
                jsRuntime,
                "google.maps.Circle",
                opts.ToDictionary(e => e.Key, e => (object)e.Value));

            Dictionary <string, Circle> objs = jsObjectRefs.ToDictionary(e => e.Key, e => new Circle(e.Value));

            obj = new CircleList(jsObjectRef, objs);

            return(obj);
        }
Esempio n. 2
0
        /// <summary>
        /// Create markers list
        /// </summary>
        /// <param name="jsRuntime"></param>
        /// <param name="opts">Dictionary of desired Marker keys and MarkerOptions values. Key as any type unique key. Not nessary Guid</param>
        /// <returns>new instance of MarkerList class will be returned with its Markers dictionary member populated with the corresponding results</returns>
        public static async Task <MarkerList> CreateAsync(IJSRuntime jsRuntime, Dictionary <string, MarkerOptions> opts)
        {
            JsObjectRef jsObjectRef = new JsObjectRef(jsRuntime, Guid.NewGuid());

            MarkerList obj;

            if (opts.Count > 0)
            {
                Dictionary <string, JsObjectRef> jsObjectRefs = await JsObjectRef.CreateMultipleAsync(
                    jsRuntime,
                    "google.maps.Marker",
                    opts.ToDictionary(e => e.Key, e => (object)e.Value));

                Dictionary <string, Marker> objs = jsObjectRefs.ToDictionary(e => e.Key, e => new Marker(e.Value));
                obj = new MarkerList(jsObjectRef, objs);
            }
            else
            {
                obj = new MarkerList(jsObjectRef, null);
            }

            return(obj);
        }