彩票走势图

好消息!地理信息系统Map Suite新增CAD图形读取

原创|行业资讯|编辑:郝浩|2013-08-01 11:07:41.000|阅读 447 次

概述:地理信息系统Map Suite为响应广大用户的需求,在最新版中新增CAD (*.dwg、*.dxf)图形显示功能!Map Suite 7.0.46.0及以上的任何版本均适用。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

地理信息系统Map Suite为响应广大用户的需求,在最新版中新增CAD (*.dwg、*.dxf)图形显示功能!使用Map Suite 7.0.46.0及以上版本中包含的新的CadFeatureLayer,可以将CAD图形以及图形样式(无论是图形自带还是你自定义的样式均可)嵌入到你的地图中。

Map Suite's new CAD FeatureLayer

以下示例代码介绍了在Map Suite项目中如何使用CadFeatureLayer。该示例运行的前提是必须安装7.0.46.0版本的Map Suite。CadFeatureLayer适用于任何版本的Map Suite,包括WPF Desktop Edition、WinForms Desktop Edition、Web Edition、MVC Edition和Silverlight Edition。

说明:以下代码全部基于C#开发语言,如果你想使用其他的开发语言,你可以自行下载一个免费工具进行代码转换。

    using System;

    using System.Drawing;

    using System.IO;

    using System.Windows.Forms;

    using ThinkGeo.MapSuite.Core;

     

    public partial class Sample : Form

    {

        private MapEngine mapEngine;

        private Bitmap bitmap;

        private RectangleShape fullExtent;

     

        public Sample()

        {

            InitializeComponent();

        }

     

        private void DisplayASimpleMap_Load(object sender, EventArgs e)

        {

            mapEngine = new MapEngine();

            mapEngine.ShowLogo = true;

     

            string[] dwgFiles = Directory.GetFiles(@"..\..\Data\");

            foreach (string dwgFile in dwgFiles)

            {

                sampleFileListBox.Items.Add(Path.GetFileName(dwgFile));

            }

            // Display the first file in the list

            sampleFileListBox.SelectedIndex = 0;

        }

     

        private void sampleFileListBox_SelectedIndexChanged(object sender, EventArgs e)

        {

            CadFeatureLayer layer = new CadFeatureLayer(@"..\..\Data\" + sampleFileListBox.SelectedItem.ToString());

     

            // Render the data using embedded style in the CAD file

            if (radioButtonEmbeddedStyle.Checked)

            {

                layer.StylingType = CadStylingType.EmbeddedStyling;

            }

            // Render the data using a customized style

            else

            {

                layer.StylingType = CadStylingType.StandardStyling;

                layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 2, true);

                layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Blue, 8);

                layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Yellow);

                layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            }

     

            mapEngine.StaticLayers.Clear();

            mapEngine.StaticLayers.Add(layer);

     

            Cursor = Cursors.WaitCursor;

            layer.Open();

            fullExtent = ExtentHelper.GetDrawingExtent(layer.GetBoundingBox(), map.Width, map.Height);

            mapEngine.CurrentExtent = fullExtent;

            DrawImage();

            Cursor = Cursors.Default;

        }

     

        private void radioButtonStandardStyle_CheckedChanged(object sender, EventArgs e)

        {

            CadFeatureLayer layer = ((CadFeatureLayer)mapEngine.StaticLayers[0]);

            if (radioButtonStandardStyle.Checked)

            {

                layer.StylingType = CadStylingType.StandardStyling;

                layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Equator1;

                layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City7;

                layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;

                layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            }

            else

            {

                layer.StylingType = CadStylingType.EmbeddedStyling;

            }

            DrawImage();

        }

     

        private void DrawImage()

        {

            bitmap = new Bitmap(map.Width, map.Height);

            mapEngine.OpenAllLayers();

            mapEngine.DrawStaticLayers(bitmap, GeographyUnit.Meter);

            mapEngine.CloseAllLayers();

     

            map.Image = bitmap;

        }

     

        private void ToolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)

        {

            switch (e.Button.Tag.ToString())

            {

                case "Zoom In":

                    mapEngine.CurrentExtent.ScaleDown(50);

                    break;

                case "Zoom Out":

                    mapEngine.CurrentExtent.ScaleUp(50);

                    break;

                case "Full Extent":

                     mapEngine.CurrentExtent = fullExtent;

                    break;

                case "Pan Left":

                    mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Left, 20);

                    break;

                case "Pan Right":

                    mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Right, 20);

                    break;

                case "Pan Up":

                    mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Up, 20);

                    break;

                case "Pan Down":

                    mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Down, 20);

                    break;

                default:

                    break;

            }

            DrawImage();

        }

     

        private void map_ClientSizeChanged(object sender, EventArgs e)

        {

            if (map.Width > bitmap.Width || map.Height > bitmap.Height)

            {

                bitmap = new Bitmap(map.Width, map.Height);

                double scale = new ZoomLevelSet().GetZoomLevel(mapEngine.CurrentExtent, map.Width, GeographyUnit.Meter).Scale;

                mapEngine.CurrentExtent = ExtentHelper.SnapToZoomLevel((RectangleShape)mapEngine.CurrentExtent.CloneDeep(), GeographyUnit.Meter, map.Width, map.Height, new ZoomLevelSet());

                mapEngine.CurrentExtent = ExtentHelper.ZoomToScale(scale, mapEngine.CurrentExtent, GeographyUnit.Meter, map.Width, map.Height);

                DrawImage();

            }

        }

    }

立即下载Map Suite 7.0.46.0版>>


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP