/// <summary>
        /// Method to render the layer
        /// </summary>
        /// <param name="g">The graphics object</param>
        /// <param name="map">The map</param>
        public override void Render(Graphics g, Map map)
        {
            if (!Enabled)
            {
                DisplayPictureBoxes(false);
                return;
            }

            var env = this.ToSource(map.Envelope);

            _provider.Open();
            var points     = _provider.GetObjectIDsInView(env);
            var validBoxes = new HashSet <uint>();

            Monitor.Enter(_renderLock);
            if (points != null && points.Count > 0)
            {
                _mapBox.Invoke(new MethodInvoker(() => _mapBox.SuspendLayout()));
                var gif     = (Bitmap)_animatedGif.Clone();
                var gifSize = gif.Size;
                gif.SelectActiveFrame(FrameDimension.Page, 0);
                foreach (var oid in points)
                {
                    if (!_pictureBoxes.ContainsKey(oid))
                    {
                        //var pic = new PictureBox {Image = _animatedGif, AutoSize = true, Name = string.Format("smpic{0}", oid)};
                        //new MethodInvoker(() =>_mapBox.Controls.Add(pic)).Invoke();
                        var oid1   = oid;
                        var ctname = string.Format("smpic{0}", oid1);
                        _mapBox.Invoke(
                            new MethodInvoker(delegate
                        {
                            var pic = new TransparentPicBox
                            {
                                Image       = (Image)_animatedGif.Clone(),
                                AutoSize    = true,
                                Name        = ctname
                                , Size      = _animatedGif.Size
                                , BackColor = Color.Transparent
                            };

                            //((Bitmap)pic).MakeTransparent(Color.Black);
                            _mapBox.Controls.Add(pic);
                        }));
                        //Thread.Sleep(5);
                        _pictureBoxes.Add(oid, (PictureBox)_mapBox.Controls[ctname]);
                    }

                    var point = this.ToTarget(_provider.GetGeometryByID(oid), map.Factory).Coordinate;
                    var np    = Point.Subtract(Point.Truncate(map.WorldToImage(point)), gifSize);

                    // Draw on the map
                    g.DrawImageUnscaled(gif, new Rectangle(np, gifSize));

                    var picbox = _pictureBoxes[oid];
                    _mapBox.Invoke(new MethodInvoker(delegate
                    {
                        picbox.Location = np;
                        picbox.Visible  = true;
                    }
                                                     ));
                    validBoxes.Add(oid);
                }
            }

            // Close the connection
            _provider.Close();

            // Disable pictureboxes that are not in viewport
            foreach (var picbox in _pictureBoxes)
            {
                if (!validBoxes.Contains(picbox.Key))
                {
                    var p = picbox.Value;
                    _mapBox.Invoke(new MethodInvoker(() => p.Visible = false));
                }
            }

            _mapBox.Invoke(new MethodInvoker(() => _mapBox.ResumeLayout()));
            Monitor.Exit(_renderLock);
            base.Render(g, map);
        }
	    /// <summary>
	    /// Method to render the layer
	    /// </summary>
	    /// <param name="g">The graphics object</param>
	    /// <param name="map">The map</param>
		public override void Render(Graphics g, Map map)
	    {
	        if (!Enabled)
	        {
	            DisplayPictureBoxes(false);
                return;
	        }
            
            var env = this.ToSource(map.Envelope);
            _provider.Open();
            var points = _provider.GetObjectIDsInView(env);
	        var validBoxes = new HashSet<uint>();
            Monitor.Enter(_renderLock);
            if (points != null && points.Count > 0)
	        {
                _mapBox.Invoke(new MethodInvoker(() => _mapBox.SuspendLayout()));
	            var gif = (Bitmap)_animatedGif.Clone();
	            var gifSize = gif.Size;
	            gif.SelectActiveFrame(FrameDimension.Page, 0);
                foreach (var oid in points)
	            {
	                if (!_pictureBoxes.ContainsKey(oid))
	                {
	                    //var pic = new PictureBox {Image = _animatedGif, AutoSize = true, Name = string.Format("smpic{0}", oid)};
	                    //new MethodInvoker(() =>_mapBox.Controls.Add(pic)).Invoke();
	                    var oid1 = oid;
	                    var ctname = string.Format("smpic{0}", oid1);
	                    _mapBox.Invoke(
	                        new MethodInvoker(delegate
	                        {
                                var pic = new TransparentPicBox
	                            {
	                                Image = (Image) _animatedGif.Clone(),
	                                AutoSize = true,
	                                Name = ctname
                                    , Size = _animatedGif.Size
                                    , BackColor = Color.Transparent
                                    
	                            };

                                //((Bitmap)pic).MakeTransparent(Color.Black);
	                            _mapBox.Controls.Add(pic);
	                        }));
	                    //Thread.Sleep(5);
	                    _pictureBoxes.Add(oid, (PictureBox) _mapBox.Controls[ctname]);
	                }

	                var point = this.ToTarget(_provider.GetGeometryByID(oid), map.Factory).Coordinate;
	                var np = Point.Subtract(Point.Truncate(map.WorldToImage(point)), gifSize);

                    // Draw on the map
                    g.DrawImageUnscaled(gif, new Rectangle(np, gifSize));

                    var picbox = _pictureBoxes[oid];
	                _mapBox.Invoke(new MethodInvoker(delegate
	                {
	                    picbox.Location = np;
	                    picbox.Visible = true;
	                }
	                    ));
	                validBoxes.Add(oid);

	            }
	        }

	        // Close the connection
            _provider.Close();

            // Disable pictureboxes that are not in viewport
	        foreach (var picbox in _pictureBoxes)
	        {
	            if (!validBoxes.Contains(picbox.Key))
	            {
	                var p = picbox.Value;
                    _mapBox.Invoke(new MethodInvoker(() =>  p.Visible = false));
	            }
	        }

            _mapBox.Invoke(new MethodInvoker(() => _mapBox.ResumeLayout()));
            Monitor.Exit(_renderLock);
			base.Render(g, map);

		}