Example #1
0
        public void drawMap(Graphics g, int width, int height, Point center)
        {
            try
            {
                int nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio);
                if (nScale == -1)
                {
                    return;
                }
                LongLat longlat = LongLat.Empty;
                //计算中心点经纬度

                longlat = mapview.OffSet(mapview.ZeroLongLat, mapview.Getlevel(1), center.X, center.Y);
                ImageAttributes imageA = new ImageAttributes();
                longlat = mapview.OffSetZero(-(int)(center.X * tlVectorControl1.ScaleRatio), -(int)(center.Y * tlVectorControl1.ScaleRatio));

                int chose = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("chose"));
                if (chose == 1)
                {
                    g.Clear(Color.White);//ColorTranslator.FromHtml("#EBEAE8")

                    Color color = ColorTranslator.FromHtml("#EBEAE8");
                    imageA.SetColorKey(color, color);
                }
                else if (chose == 2)
                {
                    Color color  = ColorTranslator.FromHtml("#F4F4FB");
                    Color color2 = ColorTranslator.FromHtml("#EFF0F1");//EFF0F1
                    //imageAttributes2.SetColorKey(color, color);
                    //imageAttributes2.SetColorKey(color2, color2);
                    imageA.SetColorKey(color2, color);
                }
                //imageA.
                //g.InterpolationMode = InterpolationMode.HighQualityBicubic;


                mapview.Paint(g, width, height, nScale, longlat.Longitude, longlat.Latitude, imageA);
                //绘制比例尺
                Point p1 = new Point(20, height - 30);
                Point p2 = new Point(20, height - 20);
                Point p3 = new Point(80, height - 20);
                Point p4 = new Point(80, height - 30);

                //g.DrawLines(new Pen(Color.Black, 2), new Point[4] { p1, p2, p3, p4 });
                //string str1 = string.Format("{0}公里", MapViewObj.GetMiles(nScale));
                //g.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, height - 40);
            }
            catch (Exception e1)
            {
            }
        }