程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#中調用mapx5.0

C#中調用mapx5.0

編輯:C#入門知識

這是 我在.net環境中調用mapx5.0控件 的一次test,前幾次網上沒有發現這方面的文章,所以自己
把幾個代碼拿出 來:這裡有些代碼是自動生成的,但只要把幾篇文章的代碼直接拷貝到工程裡 就
能直接運行的。


using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;


namespace gistestbymyself
{
/// <summary>
/// Form1 的摘要說明。
/// </summary>
public class FrmMain : System.Windows.Forms.Form
{


#region 私有變量的聲明
private AxMapXLib.AxMap axMap1;
private AxMapXLib.AxMap axMap2;


private double zoom;
private double centerx;
private double centery;
#endregion


#region Windows 窗體上拖入窗體的控件
/// <summary>
///
/// 窗體信息。
/// </summary>




private System.Windows.Forms.ToolBar toolBar2;
private System.Windows.Forms.ToolBarButton tbfangda;
private System.Windows.Forms.ToolBarButton tbbianxiao;
private System.Windows.Forms.ToolBarButton tbmanyou;
private System.Windows.Forms.ToolBarButton tbbiaozhu;
private System.Windows.Forms.ToolBarButton tbjuli;
private System.Windows.Forms.ToolBarButton tbshuaxin;
private System.Windows.Forms.ToolBarButton tbxiangxi;
private System.Windows.Forms.ToolBarButton tbzuiduan;
private System.Windows.Forms.ToolBarButton tbmianji;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolBarButton tbxuanze;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem mutuceng;
private System.Windows.Forms.ContextMenu comu;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.ContextMenu comu1;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ToolBarButton tbtianjiafuhao;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem15;
private System.Windows.Forms.MenuItem menuItem16;
private System.Windows.Forms.MenuItem menuItem17;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem menuItem21;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItem23;
private System.Windows.Forms.MenuItem menuItem24;
private System.Windows.Forms.MenuItem menuItem25;
private System.Windows.Forms.MenuItem menuItem26;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.MenuItem menuItem27;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton tbadddian;
private System.Windows.Forms.ToolBarButton tbaddxian;
private System.Windows.Forms.ToolBarButton tbaddquxian;
private System.Windows.Forms.ToolBarButton tbaddqumian;
private System.Windows.Forms.ToolBarButton tbshezhi;
private System.Windows.Forms.ToolBarButton tbline;
private System.Windows.Forms.MenuItem menuItem28;
private System.Windows.Forms.MenuItem menuItem29;
private System.Windows.Forms.MenuItem menuItem30;
private System.Windows.Forms.MenuItem menuItem31;
private System.Windows.Forms.MenuItem menuItem32;
private System.Windows.Forms.MenuItem menuItem33;
private System.Windows.Forms.MenuItem menuItem34;
private System.Windows.Forms.MenuItem menuItem35;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;


#endregion


#region FrmMain類的初始化和Form_Load時發生時的動作


public FrmMain()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();


//
// TODO: 在 InitializeComponent 調用後添加任何構造函數代碼
//
this.zoom=axMap1.Zoom; //取得初始化時的地圖比例
this.centerx=axMap1.CenterX;
this.centery=axMap1.CenterY; //取得初始化時的地圖坐標,供刷新時使用


axMap1.CreateCustomTool(10,MapXLib.ToolTypeConstants.miToolTypePoly,MapXLib.CursorConstants.miCrossCursor,null,null,false);
//創建距離工具


axMap1.CreateCustomTool(11,MapXLib.ToolTypeConstants.miToolTypePolygon,MapXLib.CursorConstants.miCrossCursor,null,null,false);
//創建面積工具


}
//*********************************
private void Form1_Load(object sender, System.EventArgs e)
{

axMap1.GeoSet=@"D:....CHINA.GST";

axMap2.GeoSet= Directory.GetCurrentDirectory()+ @"....*.gst";


axMap1.TitleText="中國";
axMap2.TitleText="***";
}


#endregion
//*****************************


#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}



private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmMain));
this.axMap1 = new AxMapXLib.AxMap();
this.axMap2 = new AxMapXLib.AxMap();
this.toolBar2 = new System.Windows.Forms.ToolBar();
this.tbxuanze = new System.Windows.Forms.ToolBarButton();
this.tbfangda = new System.Windows.Forms.ToolBarButton();
this.tbbianxiao = new System.Windows.Forms.ToolBarButton();
this.tbmanyou = new System.Windows.Forms.ToolBarButton();
this.tbbiaozhu = new System.Windows.Forms.ToolBarButton();
this.tbtianjiafuhao = new System.Windows.Forms.ToolBarButton();
this.tbjuli = new System.Windows.Forms.ToolBarButton();
this.tbmianji = new System.Windows.Forms.ToolBarButton();
this.tbshuaxin = new System.Windows.Forms.ToolBarButton();
this.tbxiangxi = new System.Windows.Forms.ToolBarButton();
this.tbzuiduan = new System.Windows.Forms.ToolBarButton();
this.label1 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem22 = new System.Windows.Forms.MenuItem();
this.menuItem23 = new System.Windows.Forms.MenuItem();
this.menuItem24 = new System.Windows.Forms.MenuItem();
this.menuItem25 = new System.Windows.Forms.MenuItem();
this.menuItem26 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();

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