利用WPF建立自己的3d gis软件(非axhost方式)(一)

链接:https://pan.baidu.com/s/1RmUISY_yRa_e5X8a3THC5Q 
提取码:7qyv 
复制这段内容后打开百度网盘手机App,操作更方便哦

该数据库中只提供 成都市火车南站附近的数据请注意,104.0648,30.61658

而且该公用服务器带宽不大,所以会有些卡顿,建议下载数据库后本地使用,下载后的数据库有些许变化,请联系博主修改一下

你下载了sql包。则设置为自己的设置。

下一步新建一个wpf工程。然后引用SDK中的gislib.dll,NewGisBiao.dll如下图:

下面上代码

<Window x:Class="Teach3DGIS.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Teach3DGIS"
        mc:Ignorable="d"
        Title="MainWindow" Height="768" Width="1024">
    <Canvas x:Name="Root" Height="768" Width="1024">
        
    </Canvas>
</Window>

MainWindow.cs

using GisLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Teach3DGIS
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Init3D();
        }
        GisLib.MTGIS3D gis3d;
        GisLib.MTGIS2 gis2d;
        private void Init3D()
        {
            if (gis3d == null)
            {
                IniRead.IniReadWrite.BiaoManage = new NewGisBiao.Base.BiaoManage(Root);
                gis3d = new MTGIS3D();
                gis3d.TManage = IniRead.IniReadWrite.BiaoManage;
                Root.Children.Add(gis3d);
                Canvas.SetLeft(gis3d, 0);
                Canvas.SetTop(gis3d, 0);
                gis3d.Width = this.Width - 100;
                gis3d.Height = this.Height - 100;


                //高程数据目录及对象初始
                // gis3d.WireLineSelect += Gis3d_WireLineSelect;
                gis3d._HiMain = new GisLib.HiData.HiMang(AppDomain.CurrentDomain.BaseDirectory + "hidatatemp", "hi");

                 IniRead.IniReadWrite.MPareant = gis3d;
            }

        }
    }
}

设置工程 输出目录为SDK所在目录如下图

然后运后就可以得到一个wpf版本的3dgis了:

由于是非axhost方式加入的,所以是完全支持WPF的特性的。我们可以将地图控件旋转一定角度:代码如下:

  RotateTransform u1 = new RotateTransform();
                u1.Angle = 45;
                gis3d.RenderTransformOrigin = new Point(0.5, 0.5);
                gis3d.RenderTransform = u1;

效果如下:

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值