国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

MapObjects2.2 在C#中的應用(動態加載地圖)

2024-07-21 02:25:41
字體:
來源:轉載
供稿:網友
mapobjects2.2 在c#中的應用(動態加載地圖)



關鍵字:mapobjects 2.2 c#



本篇文章實現了動態加載地圖的功能,廢話少說,功能實現見代碼。





加載過程代碼:



using system;

using system.drawing;

using system.collections;

using system.componentmodel;

using system.windows.forms;

using system.data;



namespace loadmap

{

/// <summary>

/// form1 的摘要說明。

/// </summary>

public class form1 : system.windows.forms.form

{

private axmapobjects2.axmap axmap1;

/// <summary>

/// 必需的設計器變量。

/// </summary>

private system.componentmodel.container components = null;



public form1()

{

//

// windows 窗體設計器支持所必需的

//

initializecomponent();



//

// todo: 在 initializecomponent 調用后添加任何構造函數代碼

//

}



/// <summary>

/// 清理所有正在使用的資源。

/// </summary>

protected override void dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.dispose();

}

}

base.dispose( disposing );

}



#region windows 窗體設計器生成的代碼

/// <summary>

/// 設計器支持所需的方法 - 不要使用代碼編輯器修改

/// 此方法的內容。

/// </summary>

private void initializecomponent()

{

system.resources.resourcemanager resources = new system.resources.resourcemanager(typeof(form1));

this.axmap1 = new axmapobjects2.axmap();

((system.componentmodel.isupportinitialize)(this.axmap1)).begininit();

this.suspendlayout();

//

// axmap1

//

this.axmap1.dock = system.windows.forms.dockstyle.fill;

this.axmap1.location = new system.drawing.point(0, 0);

this.axmap1.name = "axmap1";

this.axmap1.ocxstate = ((system.windows.forms.axhost.state)(resources.getobject("axmap1.ocxstate")));

this.axmap1.size = new system.drawing.size(600, 357);

this.axmap1.tabindex = 0;

//

// form1

//

this.autoscalebasesize = new system.drawing.size(6, 14);

this.clientsize = new system.drawing.size(600, 357);

this.controls.add(this.axmap1);

this.name = "form1";

this.text = "form1";

this.load += new system.eventhandler(this.form1_load);

((system.componentmodel.isupportinitialize)(this.axmap1)).endinit();

this.resumelayout(false);



}

#endregion



/// <summary>

/// 應用程序的主入口點。

/// </summary>

[stathread]

static void main()

{

application.run(new form1());

}



private void form1_load(object sender, system.eventargs e)

{

//定義數據連接

mapobjects2.dataconnection dc = new mapobjects2.dataconnectionclass();

//定義圖層

mapobjects2.maplayer layer = new mapobjects2.maplayerclass();

//我的地圖文件都存在了"g://loadmap//bin//debug//"目錄下,請替換為自己的地圖目錄

dc.database = "g://loadmap//bin//debug//";

//連接不成功就退出

if(!dc.connect())

{

messagebox.show("在指定的文件夾下沒找到圖層數據文件");

application.exit();

}

else//連接成功了就加載地圖

{

/*

* 地圖加載順序一般是面、線、點,先加載的在地圖的最下

*/

//加載圖層states,

layer.geodataset = dc.findgeodataset("states");

axmap1.layers.add(layer);

//加載圖層rivers,

layer.geodataset = dc.findgeodataset("rivers");

axmap1.layers.add(layer);

//加載其它圖層...

}

//必須進行刷新后才能顯示

axmap1.refresh();

}

}

}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柳林县| 宜丰县| 泾源县| 东乌珠穆沁旗| 武穴市| 调兵山市| 金寨县| 砚山县| 从化市| 永安市| 土默特左旗| 宽城| 佛学| 万年县| 阜宁县| 霍山县| 永仁县| 黄石市| 成武县| 南宫市| 余干县| 乌拉特前旗| 嵊州市| 光山县| 湟中县| 潞城市| 察隅县| 东光县| 瓦房店市| 吉林市| 宁陕县| 涞水县| 南木林县| 皋兰县| 招远市| 秦安县| 西华县| 汝阳县| 南丰县| 交口县| 临汾市|