ArcGIS Runtime SDK for .NET (WPF)实现三维场景

实现三维场景准备工作

三维地图被称为场景。为在ArcGIS中实现三维场景展示,首先需安装Esri公司ArcGIS_Runtime_SDK_DotNet_100_2_1地图SDK。并在项目中引用Esri.ArcGISRuntime.dll。

创建三维场景

您可以使用XAML在设计时定义场景及其包含的图层,也可以在后台代码中创建场景并设置和修改其属性。

XAML中实现加载场景图层

以下XAML使用SceneView和Scene展示场景图层。


    
        
            
                
            
        
    

后台代码实现场景展示

下面的代码将一个容器元素(网格控件)添加到页面中,称为MyGrid。 后台代码创建一个包含单层场景的SceneView。 场景设置SceneView的Scene属性,并添加到Grid控件中。

XMAL代码


    
       
    

C#后台代码

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 MapSence
{
    /// 
    /// MainWindow.xaml 的交互逻辑
    /// 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            // create a new SceneView
            var mySceneView = new Esri.ArcGISRuntime.Controls.SceneView();
            // create a new Scene
            var myScene = new Esri.ArcGISRuntime.Controls.Scene();
            // create a new layer (give the layer an ID so it can be found later)
            var uri = new Uri("http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");
            var baseLayer = new Esri.ArcGISRuntime.Layers.ArcGISTiledMapServiceLayer(uri);
            baseLayer.ID = "BaseMap";
            // add the layer to the Scene
            myScene.Layers.Add(baseLayer);
            // add the Scene to the SceneView
            mySceneView.Scene = myScene;
            // add the SceneView to the grid
            MyGrid.Children.Add(mySceneView);
        }
    }
}

总结

场景既可在XMAL中实现也可在后台代码中实现,相对比较灵活。可参考:点击打开链接。

你可能感兴趣的:(C#地图,ArcGIS)