代码如下 麻烦看看是什么问题:
using HWS.Forms.Common;
using HWS.Forms.Common.Map;
using HWS.Forms.DataAccess.Model.Entity;
using Newtonsoft.Json;
using SuperMap.Data;
using SuperMap.Realspace;
using SuperMap.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
bind();
}
public void bind()
{
SceneControl sceneControl = new SceneControl();
Workspace workspace = new SuperMap.Data.Workspace(this.components);
workspace.Description = "";
workspace.DesktopInfo = "";
sceneControl.Action = SuperMap.UI.Action3D.Pan;
sceneControl.BackColor = System.Drawing.Color.White;
//sceneControl.ControlMode = SuperMap.Realspace.ControlMode3D.Normal;
//sceneControl.InteractionMode = SuperMap.UI.InteractionMode3D.Default;
sceneControl.IsAlwaysActive = false;
sceneControl.IsAlwaysUpdate = false;
sceneControl.IsCursorCustomized = false;
sceneControl.IsDynamicSelection = false;
sceneControl.IsFPSVisible = false;
sceneControl.IsKeyboardNavigationEnabled = false;
sceneControl.IsMouseNavigationEnabled = true;
sceneControl.IsStatusBarShowAltitude = false;
sceneControl.IsStatusBarVisible = true;
sceneControl.IsWaitCursorEnabled = false;
sceneControl.LayerIDUnit = 8;
sceneControl.Location = new System.Drawing.Point(0, 28);
sceneControl.Name = "sceneControl";
sceneControl.Size = new System.Drawing.Size(800, 424);
sceneControl.SnapMode = SuperMap.Realspace.SnapMode3D.NONE;
sceneControl.SnapTolerance = 10;
sceneControl.TabIndex = 2;
sceneControl.TrackMode = SuperMap.UI.TrackMode3D.Edit;
sceneControl.Scene.LatLonGrid.IsVisible = false;
sceneControl.Dock = DockStyle.Fill;
this.Controls.Add(sceneControl);
DatasourceConnectionInfo info = new DatasourceConnectionInfo();
info.Server = ":memory:";
info.EngineType = EngineType.UDB;
workspace.Datasources.Create(info);
Datasets datasets = workspace.Datasources[0].Datasets;
DatasetVectorInfo vectorInfo = new DatasetVectorInfo();
vectorInfo.Name = "point";
vectorInfo.Type = DatasetType.Point3D;
DatasetVector datasetVector = datasets.Create(vectorInfo);
Dataset dataset = datasets["point"];
Recordset recordset = null;
try
{
recordset = datasetVector.GetRecordset(false, CursorType.Dynamic);
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("0", "test1");
Point3D point3D = new Point3D(100, 31, 1);
GeoPoint3D geoPoint3D = new GeoPoint3D();
geoPoint3D.Position = point3D;
recordset.AddNew(geoPoint3D, dic);
recordset.Update();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
// recordset 使用完毕后必须 Dispose
// The recordset must be disposed after using
if (recordset != null)
{
recordset.Dispose();
}
}
Layer3DSettingVector settingPoint = new Layer3DSettingVector();
settingPoint.Style.AltitudeMode = AltitudeMode.RelativeToUnderground;
settingPoint.Style.BottomAltitude = -15;
sceneControl.Scene.Layers.Add(dataset, settingPoint,true);
}
}
}