Draw MAPX map from the database (2)
Topic: Mapx Delphi Database Map Layer Style Font
I published a article "Database MapX Map" on April 15, 2004, I received a large number of readers, because of busy, I can't reply one by one, here I am sincere apologize! Thanks to this article thanks to me, thank you for your support.
Here is a more efficient way to draw MAPX maps from the database, I have established the following data table in the database:
Table Name: xUnit
ID: String // Used to uniquely identify each primitive, or number of digital types
Name: String // Name of the element
X: Floating point number / / element horizontal coordinate
Y: Floating point number / / element longitudinal coordinates
Code list:
// AQXUnit is a TadoQuery, where the SQL statement is "Select * from xUnit".
Procedure tfrmmain.drawlayerfromdb;
VAR
Oblayer: bindlayer;
Searchlayer: Layer;
DS: DataSet;
Begin
// Use this process must ensure that the AQXUnit table has been opened!
IF not aqxunit.active dam
Begin
GiveMsg ('system base table is not open!'); // Call custom prompt method
EXIT;
END;
// Create bindlayer, very annoying half-half-half Han, no way, will not translate ^ _ ^
Oblayer: = COBINDLAYER.CREATE
Oblayer.Layername: = 'artemis';
Oblayer.LayerType: = mibindlayertypexy; // must use this parameter to bind XY coordinates
Oblayer.refcolumn1: = 'x'; // The first parameter must be specified as an abscissa
Oblayer.refcolumn2: = 'y'; // Longitudinal
// Add a data set
DS: = MapMain.DataSets.Add (12, // Dataset type, this is Midatasetado, namely ADO dedicated
AQXUNIT.Recordset, // Use this method to get the _recordset type in ADO
'DS_SK', // Data Set Name
'Id', // Incoming the name of the field ID in the XUnit table
EMPTYPARAM,
Oblayer, // Bindlayer
EMPTYPARAM,
EMPTYPARAM;
// will set various properties of the new layer
Searchlayer: = MapMain.Layers.Item ('artemis');
//font color
Searchlayer.labelproperties.Style.TextFontColor: = MicolorPurple;
Searchlayer.labelproperties.style.textFonthalo: = true;
Searchlayer.labelproperties.style.textFontbackColor: = MicolorWhite;
/ / Set the label displayed by the element
Searchlayer.Labelproperties.DataSet: = DS;
Searchlayer.labelproperties.Datafield: = ds.fields.Item ('name');
Searchlayer.labelproperties.labelzoom: = true; // Set the scope of the layer zoom
Searchlayer.zoommin: = 0;
Searchlayer.Zoommax: = 200;
Searchlayer.Zoomlayer: = true;
// Set the scope of the label zoom
Searchlayer.labelproperties.labelzoommin: = 0;
Searchlayer.Labelproperties.labelzoommax: = 200;
Searchlayer.Labelproperties.labelzoom: = true;
// Automatic tag
Searchlayer.autolabel: = True;
END;
This method should be much faster than the method mentioned above, haha ~~
Yang Yutian yangyutian@hotmail.com
July 13, 2004