示例#1
0
        /// <summary>${WP_mapping_HeatMapLayer_constructor_None_D}</summary>
        public HeatMapLayer()
        {
            heatPoints = new HeatPointCollection();
            heatPoints.CollectionChanged += new NotifyCollectionChangedEventHandler(heatPoints_CollectionChanged);
            fullBounds = Rectangle2D.Empty;

            //设置GradientStops的默认值
            GradientStopCollection stops = new GradientStopCollection();
            stops.Add(new GradientStop() { Color = Color.FromArgb(0, 0, 0, 0), Offset = 0 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0xff, G = 0x42, B = 0x00 }, Offset = 0.75 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0xff, G = 0xff, B = 0x00 }, Offset = .5 });
            stops.Add(new GradientStop() { Color = new Color() { A = 0xff, R = 0x1a, G = 0xa4, B = 0x03 }, Offset = .25 });
            GradientStops = stops;

            //初始化后台线程
            worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
            worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
        }
        //将查询结果加入HeatMapLayer图层中
        private void service_ProcessCompleted(object sender, QueryEventArgs e)
        {
            if (e.Result == null)
            {
                return;
            }

            hpCollection = new HeatPointCollection();
            hpCollectionGeoRadius = new HeatPointCollection();
            if (e.Result.Recordsets != null)
            {
                foreach (Recordset item in e.Result.Recordsets)
                {
                    foreach (var item1 in item.Features)
                    {
                        HeatPoint heatPoint = new HeatPoint()
                        {
                            X = item1.Geometry.Bounds.Center.X,
                            Y = item1.Geometry.Bounds.Center.Y,
                            Value = 10,
                        };
                        HeatPoint heatPointGeoRadius = new HeatPoint()
                        {
                            X = item1.Geometry.Bounds.Center.X,
                            Y = item1.Geometry.Bounds.Center.Y,
                            Value = 10,
                            GeoRadius = 3

                        };
                        hpCollectionGeoRadius.Add(heatPointGeoRadius);
                        hpCollection.Add(heatPoint);
                    }
                }
            }
            layer.HeatPoints = hpCollection;
            layer.Radius = (int)sliderRadius.Value;
            layer.Intensity = sliderIntensity.Value;
        }