MapX uses database data to add a special map (three of the series)

zhaozj2021-02-16  106

MapX uses database data to add a special map (three of the series)

Keywords: Mapx Delphi special map

Author: Yang Yutian blue_bat@126.com

This article describes the method of adding a special map in MAPX, where the process grammar about the addition of the topic is described as follows (in the English level, the English letters who can know probably more than 20, really unwilling to open Jinshan The word tyrants give you high quality translation, haha):

Object.add ([Type], [Field], [Name], [ComputeTheme])

Object represents a themes object.

Type Specifies the type of thematic map to create. This takes a ThemeTypeConstants value. This is an optional parameter, and if not specified (or specified as miThemeAuto), MapX will attempt to choose a good default based on the number of fields passed in as Well As What Other Theme Types Are Aready Being Displayed. If Mapx Cannot Choose a Default Theme Type, An Error Is Generated.

Field (s) Specifies the field or fields to thematically map. A field can be specified by name, index, or by a Field object. If you are creating a theme using multiple variables (such as a bar chart or pie chart), pass IN A Fields Collection or an Array Of Field Names, Indexes, or Field Objects. This is an optional parameter, and if not specified, Mapx Uses the first numeric field of the dataset.

Name Specifier The name of the the the the the. This is a string parameter, and if not specified, Mapx generates a name such as statesbysales.

ComputeTheme Boolean. The default value is True which will calculate the theme from the table data. If the value is set to False an invisible theme object will be created with 10 ranges for IndividualValue themes and 5 ranges for Ranged themes. You can then manually set the minimum and maximum values ​​to define the theme with Theme.DataMin and Theme.DataMax. For ranged themes you can manually set the theme ranges or calculate equal size ranges determined by the minimum (Theme.DataMin) and maximum (Theme.DataMax) values There are several things about the style of the topic:

mitHemanged = 0

MitHEMebarchart = 1

mitHemepieChart = 2

mithemegradsymbol = 3

mitHEMedotdensity = 4

MitHemeindividualValue = 5

mitHemeauto = 6

MitHemenne = 9

Specifically, please write the code yourself, haha

Here is some of my code I wrote:

Unit main;

Interface

Uses

Windows, Messages, {一}} sysutils, variants, classes;

Type

Tfrmmain = Class (TFORM)

MapMain: TMAP; {Map Control}

Private

{Private Declarations}

Themeslist: tstringlist; {Name list for saving multiple special pictures}

public

{Public declarations}

Procedure toaddthemes (style: string); {Add special map}

Procedure TodelThemes; {Delete Special Table}

END;

VAR

FRMMAIN: TFRMMAIN;

IMPLEMentation

{$ R * .dfm}

{去 Other function code}

{

Add a special map, parameter style represents a special graph style, Thename represents the legend title title

}

Procedure tfrmmain.toaddthemes (style: integer; thename: string);

Function defaultname: string; {to generate a single name}

Begin

{I used the method to take a current time, twice calling this function should not be less than 0.5 seconds,

So this method can get the only name in this project}

Result: = 'YYT' FORMATDATETIME ('YYYYMMDDHNNSSZZZ', NOW);

END;

VAR

FLDS: Array of String; {Field List}

Oblayer: Bindlayer; {Binding Layer}

DS: DataSet; {MAPX Data Set}

I: integer; {cycle variable} trum: theme; {MapX special map}

Str: String; {Save string}

Begin

{AQThemes can be an adoQuery or adotable, I am using AdoQuery.

The first four fields in this AdoQuery are:

ID (unique number or string, generally numbered),

Name (String, Label of Features),

X (floating point, longitude or horizontal),

Y (latitude or longitudinal coordinates of factors).

Other fields later are digital types to represent relevant data.

◎ Please refer to my article "Draw MAPX Layers from the Database (2)",

URL is http://dev.9cbs.net/Article/31/31719.shtm

}

IF not aqthemes.active kil

Begin

DMDATA.GIVEMSG ('system base table is not open!'); ');

EXIT;

END;

Try

{Take a unique name,}

Str: = defaultname;

{Setting the properties of the binding layer}

Oblayer: = COBINDLAYER.CREATE

Progress.stepplus (2);

Oblayer.Layername: = STR;

Oblayer.LayerType: = mibindlayertypexy;

Oblayer.refcolumn1: = 'x';

Oblayer.refcolumn2: = 'y';

{The following calls and I am using the method of using the MAPX layer (2) "from the database,

Please refer to my article, URL is http://dev.9cbs.net/Article/31/31719.shtm}

DS: = MapMain.DataSets.Add (12,

AQthemes.Recordset,

Str,

'Id',

EMPTYPARAM,

Oblayer,

EMPTYPARAM,

EMPTYPARAM;

{Organizational Topics Data Realistic Data field, stored in the array of strings}

SETLENGTH (FLDS, AQthemes.fields.count - 3);

For i: = 3 to aqthemes.fields.count - 1 do

Begin

FLDS [i - 3]: = aqthemes.fields.fields [i] .fieldname;

END;

{Actually adding a special map process}

THM: = ds.Themes.Add (Style, Flds, defaultname, EMPTYPARAM);

{Set Topics Chart Title}

THM.LGEND.TITLE: = theame;

{Record newly added topic name}

ThemeSlist.Add (STR);

{BTNDELETHEMES is a button on this window to delete a special map.

After adding a special map, it will be displayed. If all the special maps have been deleted}

BtndeleThemes.visible: = true;

Except

Givemsg ('Create a special map failed!'); {Custom Process, give an error prompt}

END;

END;

{

Delete a special map, the method I use is to delete all the topic

}

Procedure Tfrmmain.todeleThemes;

VAR

I: integer; {cycle variable}

Begin

For i: = 0 to themeslist.count-1 do {loop all added special map} Begin

{Delete data set}

MapMain.DataSets.Remove (themeslist.strings [i]);

{Delete special map}

MapMain.Layers.Remove (themeslist.strings [i]);

{If you just want to delete a feature map, you don't have to loop.}

END;

{There is no special picture at this time, will delete the topic button hidden}

BtndeleThemes.visible: = false;

{Clear special map name list}

Themeslist.clear;

END;

// ...

End.

Yang Yuditian Blue_Bat@126.com

August 2, 2004

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

New Post(0)