Draw MAPX map from the database

zhaozj2021-02-17  84

Draw MAPX map from the database

Topic: Mapx Delphi Database Map Layer Style Font

This article will take you from the database to draw in Mapx.

1. Establish the following table for storage coordinates in the database:

ID integer // unique number

Name string // Name (label)

X float // map coordinate x

Y float // map coordinate y

Suppose this table is named xUnit

2, edit the Mapx map, add a new Layer, define you want to add a layer display style in the future, then set this layer is not visible, can not be editable, this layer name is assumed to be "Enterprise Unit".

3. Add a MAPX control in your program, named MAP1

4. Add BDE or ADO components to your database and connect to your database, assume that you add Adoconnection1 and Adotable1 and set their related properties to all content in the above table.

5, add the button and add the Click time code in the button as follows:

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

VAR

Lyr: layer; //

FTS: feature; // characteristics

PT: Point; //

MStyle: style; // style

Str: string; // Feature label

X, Y: Double;

Begin

Lyr: = map1.layers.createLayer ('Tempanimate', EmptyParam, 1, EmptyParam, EmptyParam);

// Create a Layer in Map1

Map1.Layers.AnimationLayer: = lyr; // Set to the current layer

lyr.editable: = true; // Edit

PT: = Copoint.create;

MStyle: = COSTYLE.CREATE;

mstyle: = map1.Layers.Item ('Enterprise Unit') .allfeatures.Item (1) .style; // Get the characteristics store stored in the layer "Enterprise Unit"

Lyr.Style: = Map1.Layers.Item ('Enterprise Co., Ltd.). Style; //

Lyr.labelproperties.Style: = map1.Layers.Item ('Enterprise ") .Labelproperties.Style; // Label Style

ADOTABLE1.FIRST;

While not adotable1.eof do

Begin

X: = adotable1.fieldbyName ('x'). Asfloat;

Y: = adotable1.fieldbyname ('y'). asfloat;

Str: = adotable1.fieldbyname ('name'). asstring;

Pt.set_ (x, y);

FTS: = Map1.FeatureFactory.createSymbol (PT, MStyle); // Create Features

fts.keyvalue: = Str; // Task

Lyr.addfeature (fts, emptyparam); // Add feature to layer

ADOTABLE1.NEXT;

END;

lyr.autolabel: = true; // automatic label

Lyr.visible: = true; // visible

Lyr.zoommin: = 0; // Zoom range

Lyr.Zoommax: = 77;

END;

6. Follow the steps we can directly express the data in the database, of course, we just show the feature points, there is no other things such as those areas, other things should be, but I can't use it, haha. . E-mail:

Yangyutian@hotmail.com

April 15, 2004

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

New Post(0)