程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 在C#中應用MapObjects(渲染效果)

在C#中應用MapObjects(渲染效果)

編輯:關於C語言
以前用MapX,裡面有專題圖,挺好。經過幾天的試驗,我把MapObjects中的各種渲染效果(類似MapX專題圖,但不一樣)都試了試,下面附上源代碼,如果那位有不懂的地方請自己琢磨,哈哈…



代碼如下:



using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;



namespace DbInMo

{

/// <summary>

/// Form1 的摘要說明。

/// </summary>

public class 渲染示例 : System.Windows.Forms.Form

{

private AxMapObjects2.AxMap map;

private System.Windows.Forms.Button 直方圖;

private System.Windows.Forms.Button 餅圖;

private System.Windows.Forms.Button 點密度;

private System.Windows.Forms.Button 按值渲染;

private System.Windows.Forms.Button 分類渲染;

private System.Windows.Forms.Button Z值渲染;

private System.Windows.Forms.Button 組渲染;

private System.Windows.Forms.Button 退出;

private System.Windows.Forms.Panel 操作板;

private System.Windows.Forms.Button 刪除所有渲染;

private System.Windows.Forms.Panel panel1;

private System.Windows.Forms.Button 全圖;

private System.Windows.Forms.Button 拖動;

private System.Windows.Forms.Button 縮小;

private System.Windows.Forms.Button 放大;

private System.Windows.Forms.Panel 分隔符;

private System.Windows.Forms.Button 標注渲染;

/// <summary>

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

/// </summary>

private System.ComponentModel.Container components = null;



public 渲染示例()

{

//

// 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(渲染示例));

this.map = new AxMapObjects2.AxMap();

this.操作板 = new System.Windows.Forms.Panel();

this.直方圖 = new System.Windows.Forms.Button();

this.餅圖 = new System.Windows.Forms.Button();

this.點密度 = new System.Windows.Forms.Button();

this.按值渲染 = new System.Windows.Forms.Button();

this.分類渲染 = new System.Windows.Forms.Button();

this.Z值渲染 = new System.Windows.Forms.Button();

this.組渲染 = new System.Windows.Forms.Button();

this.退出 = new System.Windows.Forms.Button();

this.標注渲染 = new System.Windows.Forms.Button();

this.刪除所有渲染 = new System.Windows.Forms.Button();

this.panel1 = new System.Windows.Forms.Panel();

this.全圖 = new System.Windows.Forms.Button();

this.拖動 = new System.Windows.Forms.Button();

this.縮小 = new System.Windows.Forms.Button();

this.放大 = new System.Windows.Forms.Button();

this.分隔符 = new System.Windows.Forms.Panel();

((System.ComponentModel.ISupportInitialize)(this.map)).BeginInit();

this.操作板.SuspendLayout();

this.SuspendLayout();

//

// map

//

this.map.Dock = System.Windows.Forms.DockStyle.Fill;

this.map.Location = new System.Drawing.Point(0, 0);

this.map.Name = "map";

this.map.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("map.OcxState")));

this.map.Size = new System.Drawing.Size(616, 429);

this.map.TabIndex = 0;

this.map.MouseDownEvent += new AxMapObjects2._DMapEvents_MouseDownEventHandler(this.map_MouseDownEvent);

//

// 操作板

//

this.操作板.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.操作板.Controls.Add(this.刪除所有渲染);

this.操作板.Controls.Add(this.panel1);

this.操作板.Controls.Add(this.全圖);

this.操作板.Controls.Add(this.拖動);

this.操作板.Controls.Add(this.縮小);

this.操作板.Controls.Add(this.放大);

this.操作板.Controls.Add(this.分隔符);

this.操作板.Controls.Add(this.標注渲染);

this.操作板.Controls.Add(this.退出);

this.操作板.Controls.Add(this.組渲染);

this.操作板.Controls.Add(this.Z值渲染);

this.操作板.Controls.Add(this.分類渲染);

this.操作板.Controls.Add(this.按值渲染);

this.操作板.Controls.Add(this.點密度);

this.操作板.Controls.Add(this.餅圖);

this.操作板.Controls.Add(this.直方圖);

this.操作板.Dock = System.Windows.Forms.DockStyle.Right;

this.操作板.Location = new System.Drawing.Point(496, 0);

this.操作板.Name = "操作板";

this.操作板.Size = new System.Drawing.Size(120, 429);

this.操作板.TabIndex = 1;

//

// 直方圖

//

this.直方圖.Dock = System.Windows.Forms.DockStyle.Top;

this.直方圖.Location = new System.Drawing.Point(0, 0);

this.直方圖.Name = "直方圖";

this.直方圖.Size = new System.Drawing.Size(116, 24);

this.直方圖.TabIndex = 0;

this.直方圖.Text = "直方圖";

this.直方圖.Click += new System.EventHandler(this.直方圖_Click);

//

// 餅圖

//

this.餅圖.Dock = System.Windows.Forms.DockStyle.Top;

this.餅圖.Location = new System.Drawing.Point(0, 24);

this.餅圖.Name = "餅圖";

this.餅圖.Size = new System.Drawing.Size(116, 24);

this.餅圖.TabIndex = 1;

this.餅圖.Text = "餅圖";

this.餅圖.Click += new System.EventHandler(this.餅圖_Click);

//

// 點密度

//

this.點密度.Dock = System.Windows.Forms.DockStyle.Top;

this.點密度.Location = new System.Drawing.Point(0, 48);

this.點密度.Name = "點密度";

this.點密度.Size = new System.Drawing.Size(116, 23);

this.點密度.TabIndex = 2;

this.點密度.Text = "點密度";

this.點密度.Click += new System.EventHandler(this.點密度_Click);

//

// 按值渲染

//

this.按值渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.按值渲染.Location = new System.Drawing.Point(0, 71);

this.按值渲染.Name = "按值渲染";

this.按值渲染.Size = new System.Drawing.Size(116, 23);

this.按值渲染.TabIndex = 3;

this.按值渲染.Text = "按值渲染";

this.按值渲染.Click += new System.EventHandler(this.按值渲染_Click);

//

// 分類渲染

//

this.分類渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.分類渲染.Location = new System.Drawing.Point(0, 94);

this.分類渲染.Name = "分類渲染";

this.分類渲染.Size = new System.Drawing.Size(116, 23);

this.分類渲染.TabIndex = 4;

this.分類渲染.Text = "分類渲染";

this.分類渲染.Click += new System.EventHandler(this.分類渲染_Click);

//

// Z值渲染

//

this.Z值渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.Z值渲染.Location = new System.Drawing.Point(0, 117);

this.Z值渲染.Name = "Z值渲染";

this.Z值渲染.Size = new System.Drawing.Size(116, 23);

this.Z值渲染.TabIndex = 5;

this.Z值渲染.Text = "Z值渲染";

this.Z值渲染.Click += new System.EventHandler(this.Z值渲染_Click);

//

// 組渲染

//

this.組渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.組渲染.Location = new System.Drawing.Point(0, 140);

this.組渲染.Name = "組渲染";

this.組渲染.Size = new System.Drawing.Size(116, 23);

this.組渲染.TabIndex = 6;

this.組渲染.Text = "組渲染";

this.組渲染.Click += new System.EventHandler(this.組渲染_Click);

//

// 退出

//

this.退出.Dock = System.Windows.Forms.DockStyle.Bottom;

this.退出.Location = new System.Drawing.Point(0, 402);

this.退出.Name = "退出";

this.退出.Size = new System.Drawing.Size(116, 23);

this.退出.TabIndex = 7;

this.退出.Text = "退出";

this.退出.Click += new System.EventHandler(this.退出_Click);

//

// 標注渲染

//

this.標注渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.標注渲染.Location = new System.Drawing.Point(0, 163);

this.標注渲染.Name = "標注渲染";

this.標注渲染.Size = new System.Drawing.Size(116, 23);

this.標注渲染.TabIndex = 7;

this.標注渲染.Text = "標注渲染";

this.標注渲染.Click += new System.EventHandler(this.標注渲染_Click);

//

// 刪除所有渲染

//

this.刪除所有渲染.Dock = System.Windows.Forms.DockStyle.Top;

this.刪除所有渲染.Location = new System.Drawing.Point(0, 319);

this.刪除所有渲染.Name = "刪除所有渲染";

this.刪除所有渲染.Size = new System.Drawing.Size(116, 23);

this.刪除所有渲染.TabIndex = 22;

this.刪除所有渲染.Text = "刪除所有渲染";

this.刪除所有渲染.Click += new System.EventHandler(this.刪除所有渲染_Click);

//

// panel1

//

this.panel1.Dock = System.Windows.Forms.DockStyle.Top;

this.panel1.Location = new System.Drawing.Point(0, 299);

this.panel1.Name = "panel1";

this.panel1.Size = new System.Drawing.Size(116, 20);

this.panel1.TabIndex = 21;

//

// 全圖

//

this.全圖.Dock = System.Windows.Forms.DockStyle.Top;

this.全圖.Location = new System.Drawing.Point(0, 276);

this.全圖.Name = "全圖";

this.全圖.Size = new System.Drawing.Size(116, 23);

this.全圖.TabIndex = 20;

this.全圖.Text = "全圖";

this.全圖.Click += new System.EventHandler(this.全圖_Click);

//

// 拖動

//

this.拖動.Dock = System.Windows.Forms.DockStyle.Top;

this.拖動.Location = new System.Drawing.Point(0, 253);

this.拖動.Name = "拖動";

this.拖動.Size = new System.Drawing.Size(116, 23);

this.拖動.TabIndex = 19;

this.拖動.Text = "拖動";

this.拖動.Click += new System.EventHandler(this.拖動_Click);

//

// 縮小

//

this.縮小.Dock = System.Windows.Forms.DockStyle.Top;

this.縮小.Location = new System.Drawing.Point(0, 230);

this.縮小.Name = "縮小";

this.縮小.Size = new System.Drawing.Size(116, 23);

this.縮小.TabIndex = 18;

this.縮小.Text = "縮小";

this.縮小.Click += new System.EventHandler(this.縮小_Click);

//

// 放大

//

this.放大.Dock = System.Windows.Forms.DockStyle.Top;

this.放大.Location = new System.Drawing.Point(0, 207);

this.放大.Name = "放大";

this.放大.Size = new System.Drawing.Size(116, 23);

this.放大.TabIndex = 17;

this.放大.Text = "放大";

this.放大.Click += new System.EventHandler(this.放大_Click);

//

// 分隔符

//

this.分隔符.Dock = System.Windows.Forms.DockStyle.Top;

this.分隔符.Location = new System.Drawing.Point(0, 186);

this.分隔符.Name = "分隔符";

this.分隔符.Size = new System.Drawing.Size(116, 21);

this.分隔符.TabIndex = 16;

//

// 渲染示例

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClIEntSize = new System.Drawing.Size(616, 429);

this.Controls.Add(this.操作板);

this.Controls.Add(this.map);

this.Name = "渲染示例";

this.Text = "渲染示例";

this.WindowState = System.Windows.Forms.FormWindowstate.Maximized;

((System.ComponentModel.ISupportInitialize)(this.map)).EndInit();

this.操作板.ResumeLayout(false);

this.ResumeLayout(false);



}

#endregion



/// <summary>

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

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new 渲染示例());

}



/// <summary>

/// 退出系統

/// </summary>

private void 退出_Click(object sender, System.EventArgs e)

{

this.Close();

}



/// <summary>

/// 圖表渲染,值方圖

/// </summary>

private void 直方圖_Click(object sender, System.EventArgs e)

{

//直方圖的例子中使用Lakers圖層

//

//定義圖標渲染變量

MapObjects2.ChartRenderer cr = new MapObjects2.ChartRendererClass();

//設置渲染類型為直方圖

cr.ChartType = MapObjects2.ChartTypeConstants.moBar;

//設置直方圖顯示的字段個數為兩個,就是直方圖顯示兩個柱子

cr.FIEldCount = 2;

//設置第一個字段,請參看lakes.dbf

cr.set_FIEld(0,"SURF_ELEV");

//設置這個直方圖的柱子顏色為紅色

cr.set_Color(0,(uint)MapObjects2.ColorConstants.moRed);

//設置第二個柱子

cr.set_FIEld(1,"DEPTH");

cr.set_Color(1,(uint)MapObjects2.ColorConstants.moGreen);

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("lakes"));

lyr.Renderer = cr;

//使用Refresh()刷新老也是刷新不好,正沒辦法。。。,設為全圖倒是不錯的注意,^_^

map.Refresh();

}

/// <summary>

/// 全圖視野

/// </summary>

private void 全圖_Click(object sender, System.EventArgs e)

{

map.Extent = map.FullExtent;

}

/// <summary>

/// 拖動,只設置圖標

/// </summary>

private void 拖動_Click(object sender, System.EventArgs e)

{

map.MousePointer = MapObjects2.MousePointerConstants.moPan;

}

/// <summary>

/// 縮小,只設置圖標

/// </summary>

private void 縮小_Click(object sender, System.EventArgs e)

{

map.MousePointer = MapObjects2.MousePointerConstants.moZoomOut;

}

/// <summary>

/// 放大,只設置圖標

/// </summary>

private void 放大_Click(object sender, System.EventArgs e)

{

map.MousePointer = MapObjects2.MousePointerConstants.moZoomIn;

}

/// <summary>

/// 鼠標按下時間,處理地圖放大、縮小、拖動等。

/// </summary>

private void map_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)

{

MapObjects2.Rectangle rect;

MapObjects2.Point pt = map.ToMapPoint(e.x,e.y);



if(e.button == 2)//右鍵點擊取消

{

map.MousePointer = MapObjects2.MousePointerConstants.moDefault;

}



if(map.MousePointer == MapObjects2.MousePointerConstants.moPan)//拖動

{

map.Pan();

}

else if(map.MousePointer == MapObjects2.MousePointerConstants.moZoomIn)//放大

{

rect = map.TrackRectangle();



if(rect == null|| (rect.Width < 0.00005) || (rect.Height < 0.00005))

{

rect = map.Extent;

rect.ScaleRectangle(0.6667);

rect.Offset(-(rect.Center.X - pt.X),-(rect.Center.Y - pt.Y));

}

map.Extent = rect;

}

else if(map.MousePointer == MapObjects2.MousePointerConstants.moZoomOut)//縮小

{

rect = map.TrackRectangle();



if ((null == rect) || (rect.Width < 0.00005) || (rect.Height < 0.00005))

{

rect = map.Extent;

rect.ScaleRectangle(1.5);

rect.Offset(-(rect.Center.X - pt.X),-(rect.Center.Y - pt.Y));

}

else

{

double dRate = map.Extent.Width / rect.Width * 10;

rect.ScaleRectangle(dRate);

}



map.Extent = rect;

}

}

/// <summary>

/// 圖表渲染,使用餅圖

/// </summary>

private void 餅圖_Click(object sender, System.EventArgs e)

{

//餅圖的例子中使用Lakers圖層

//過程和直方圖一樣

//

//定義圖標渲染變量

MapObjects2.ChartRenderer cr = new MapObjects2.ChartRendererClass();

//設置渲染類型為餅圖

cr.ChartType = MapObjects2.ChartTypeConstants.moPIE;

//設置餅圖顯示的字段個數為兩個,就是餅圖顯示兩半

cr.FIEldCount = 2;

//設置第一個字段,請參看lakes.dbf

cr.set_FIEld(0,"SURF_ELEV");

//設置這個餅圖的一半顏色為紅色

cr.set_Color(0,(uint)MapObjects2.ColorConstants.moRed);

//設置第二半

cr.set_FIEld(1,"DEPTH");

cr.set_Color(1,(uint)MapObjects2.ColorConstants.moGreen);

//添加到地圖上

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("lakes"));

lyr.Renderer = cr;

//刷新

map.Refresh();

}

/// <summary>

/// 點密度渲染

/// </summary>

private void 點密度_Click(object sender, System.EventArgs e)

{

//點密度的例子中使用lakes圖層

//

//定義點密度渲染變量

MapObjects2.DotDensityRenderer ddr = new MapObjects2.DotDensityRendererClass();

//設置渲染的數據字段,請參看lakes.dbf

ddr.FIEld = "DEPTH";

//點大小

ddr.DotSize = 3;

//點顏色

ddr.DotColor = (uint)MapObjects2.ColorConstants.moBlue;

ddr.DotValue = 1;

ddr.DrawBackground = true;

//添加到地圖上

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("lakes"));

lyr.Renderer = ddr;

//刷新

map.Refresh();

}

/// <summary>

/// 按值渲染

/// </summary>

private void 按值渲染_Click(object sender, System.EventArgs e)

{

//按值渲染的例子中使用country圖層,這裡利用按值渲染,將每個國家用不同的顏色顯示

//

//字符串s變量,很像Delphi中的TStringList,^_^

MapObjects2.Strings strs = new MapObjects2.StringsClass();

//圖層變量,引用country圖層

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)map.Layers.Item("country");

//Recordset對象,我將在以後的文章中陸續講解關於MapObjects2.2中使用數據集變量的內容!!!

//使用方法大致與VB中對數據表的操作差不多。

MapObjects2.Recordset rc = lyr.Records;

//這個循環獲取所有國家的簡稱代碼列表

while(!rc.EOF)

{

strs.Add(rc.FIElds.Item("FIPS_CODE").ValueAsString);

rc.MoveNext();

}

//定義按值渲染對象

MapObjects2.ValueMapRenderer vmr = new MapObjects2.ValueMapRendererClass();

//將其添加到圖層

lyr.Renderer = vmr;

//設置渲染使用的字段,請參看country.dbf文件

vmr.FIEld = "FIPS_CODE";

//渲染的個數

vmr.ValueCount = strs.Count;

//缺省值

vmr.UseDefault = true;

MapObjects2.Symbol sym = vmr.DefaultSymbol;

sym.Color = (uint)MapObjects2.ColorConstants.moYellow;//缺省顏色為黃色

//渲染過程

for(int i=0;i<vmr.ValueCount;i++)

{

vmr.set_Value((short)i,strs.Item((short)i));

}

//刷新

map.Refresh();

}

/// <summary>

/// 分類渲染

/// </summary>

private void 分類渲染_Click(object sender, System.EventArgs e)

{

//分類渲染的例子使用country圖層

//

//圖層變量引用citIEs層

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)(map.Layers.Item("citIEs"));

//定義分類渲染變量

MapObjects2.ClassBreaksRenderer cbr = new MapObjects2.ClassBreaksRendererClass();

//添加到地圖

lyr.Renderer = cbr;

//設置符號類型為點,也可使用其他類型,請自己試驗,方法大概都差不多

cbr.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;

//設置字段,請參看citIEs.dbf文件

cbr.FIEld = "POPULATION";

//Statistics對象經常配合分類渲染使用,他表示用一個Recordset對象的CalculateStatistics方法

// 對一個數值字段的統計計算結果

MapObjects2.Statistics stat = lyr.Records.CalculateStatistics("POPULATION");

//Mean——平均值,StdDev——均方差

double fbv = stat.Mean - (stat.StdDev * 3);

for(int i=0;i<6;i++)

{

if((fbv >= stat.Min)&&fbv <= stat.Max)

{

//分類個數,依次加一

cbr.BreakCount = (short)(cbr.BreakCount + 1);

//設置分類

cbr.set_Break((short)(cbr.BreakCount - 1),fbv);

}

fbv += stat.StdDev;

}

//SizeSymbols方法制定頭尾的大小用來表現點特征大小漸進效果

cbr.SizeSymbols(3,8);

//RampColors方法設置顏色從白色到紅色的漸進顯示

cbr.RampColors((uint)MapObjects2.ColorConstants.moWhite,(uint)MapObjects2.ColorConstants.moRed);

//刷新

map.Refresh();

}

/// <summary>

/// Z值渲染

/// </summary>

private void Z值渲染_Click(object sender, System.EventArgs e)

{

//本來想好好搞搞,可是我找不到帶有Z值的地圖,哈哈,認了吧,下面給出基本的語句,有興趣的

//兄弟姐妹們可以自己試試

// MapObjects2.ZRenderer zr = new MapObjects2.ZRendererClass();

// //Z值分成幾部分?

// zr.BreakCount = 2;

// //設置各個部分的分界線

// zr.set_Break(0,100);

// zr.set_Break(1,1000);

// //設置特征類型

// zr.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol;

// MapObjects2.Symbol sym;

// for(short i=0;i<zr.BreakCount;i++)

// {

// //獲取特征

// sym = zr.get_Symbol(i);

// //設置特征屬性,定義一個顏色數組,將不同特征設置不同顏色,效果會明顯些

// sym.Color = (uint)MapObjects2.ColorConstants.moRed;

// sym.Size = 6;

// sym.Style = MapObjects2.MarkerStyleConstants.moTriangleMarker;

// }

// //添加到地圖

// MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)map.Layers.Item("帶有Z值的圖層名稱");

// lyr.Renderer = zr;

// //刷新

// map.Refresh();

}

/// <summary>

/// 組渲染

/// </summary>

private void 組渲染_Click(object sender, System.EventArgs e)

{

//組渲染其實就是組合渲染,一般定義多個渲染方式,然後使用如下的語句進行組合



MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)map.Layers.Item("country");



//標注渲染

MapObjects2.LabelRenderer lr = new MapObjects2.LabelRendererClass();

lr.FIEld = "NAME";

lr.get_Symbol(0).Color = (uint)MapObjects2.ColorConstants.moBlack;

lr.get_Symbol(0).Font.Size = 8;



//按值渲染

MapObjects2.Strings strs = new MapObjects2.StringsClass();

MapObjects2.Recordset rc = lyr.Records;

while(!rc.EOF)

{

strs.Add(rc.FIElds.Item("FIPS_CODE").ValueAsString);

rc.MoveNext();

}

MapObjects2.ValueMapRenderer vmr = new MapObjects2.ValueMapRendererClass();

vmr.FIEld = "FIPS_CODE";

vmr.ValueCount = strs.Count;

vmr.UseDefault = true;

MapObjects2.Symbol sym = vmr.DefaultSymbol;

sym.Color = (uint)MapObjects2.ColorConstants.moYellow;

for(int i=0;i<vmr.ValueCount;i++)

{

vmr.set_Value((short)i,strs.Item((short)i));

}



//將二者組合,添加到圖層

MapObjects2.GroupRenderer gr = new MapObjects2.GroupRendererClass();

gr.Add(vmr);

gr.Add(lr);

lyr.Renderer = gr;

map.Refresh();



}

/// <summary>

/// 刪除所有渲染

/// </summary>

private void 刪除所有渲染_Click(object sender, System.EventArgs e)

{

MapObjects2.MapLayer lyr;



for(int i=0;i<map.Layers.Count;i++)

{

lyr = (MapObjects2.MapLayer)map.Layers.Item(i);

lyr.Renderer = new MapObjects2.LabelRendererClass();

map.Refresh();

}

}

/// <summary>

/// 標注渲染

/// </summary>

private void 標注渲染_Click(object sender, System.EventArgs e)

{

MapObjects2.MapLayer lyr = (MapObjects2.MapLayer)map.Layers.Item("citIEs");

MapObjects2.LabelRenderer lr = new MapObjects2.LabelRendererClass();

lr.FIEld = "NAME";

lr.get_Symbol(0).Color = (uint)MapObjects2.ColorConstants.moBlack;

lr.get_Symbol(0).Font.Size = 8;

lyr.Renderer = lr;

map.Refresh();

}

}

}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved