国产探花免费观看_亚洲丰满少妇自慰呻吟_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();

}

}

}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云安县| 库伦旗| 屯昌县| 凉山| 康定县| 石城县| 张家口市| 普兰店市| 玉环县| 怀远县| 来凤县| 卓资县| 富阳市| 乌拉特中旗| 屏南县| 金山区| 临桂县| 白城市| 凤山县| 蓬莱市| 东平县| 出国| 兴安县| 大理市| 上蔡县| 喀喇沁旗| 广西| 沙雅县| 广水市| 克东县| 定陶县| 万载县| 凯里市| 连山| 保康县| 江西省| 石狮市| 富宁县| 栖霞市| 枞阳县| 海兴县|