Application of MapObjects2.2 in C # (Dynamic Load Map)

zhaozj2021-02-16  104

Application of MapObjects2.2 in C # (Dynamic Load Map)

Keywords: mapobjects 2.2 C #

This article realizes the function of dynamically loaded maps, nonsense, and the function is implemented.

Loading process code:

Using system;

Using system.drawing;

Using system.collections;

Using system.componentmodel;

Using system.windows.forms;

Using system.data;

Namespace loadingmap

{

///

/// Form1 summary description.

///

Public Class Form1: System.Windows.Forms.form

{

Private AxmapObjects2.axmap axmap1;

///

/// The required designer variable.

///

Private system.componentmodel.Container Components = NULL;

Public Form1 ()

{

//

// Windows Form Designer Support

//

InitializationComponent ();

//

// Todo: Add any constructor code after INITIALIZECOMPONENT call

//

}

///

/// Clean all the resources being used.

///

Protected Override Void Dispose (Bool Disposing)

{

IF (Disposing)

{

IF (Components! = NULL)

{

Components.dispose ();

}

}

Base.dispose (Disposing);

}

#Region Windows Form Designer Generated Code

///

/// Designer supports the required method - do not use the code editor to modify

/// This method is content.

///

Private vidinitiRizeComponent ()

{

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))))));

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);

}

#ndregion

///

/// The main entry point for the application.

///

[Stathread]

Static void main ()

{

Application.run (New Form1 ());

}

Private Void Form1_Load (Object Sender, System.EventArgs E)

{

/ / Define data connection

MapObjects2.dataconnection DC = new mapObjects2.dataconnectionClass ();

// Define the layer

MapObjects2.maplayer layer = new mapObjects2.maplayerclass ();

// My map file exists in the "g: // //" directory, please replace your map directory.

Dc.Database = "g: // loadmap // bin // debug //";

// Exit when the connection is unsuccessful

IF (! dc.connect ())

{

Messagebox.show ("Did not find a layer data file under the specified folder");

Application.exit ();

}

Else // The connection is successful to load the map

{

/ *

* Map loading order is generally facing, line, point, first loaded on the map of the map

* /

// Load layer State,

Layer.GeodataSet = DC.FindGeodataSet ("States");

AXMAP1.LAYERS.ADD (Layer);

/ / Load layer Rivers,

Layer.GeodataSet = DC.FindGeodataSet ("Rivers");

AXMAP1.LAYERS.ADD (Layer);

/ / Load other layers ...

}

/ / Must be refreshed before you can display

AXMAP1.REFRESH ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-10797.html

New Post(0)