MapObject control used by the layers

zhaozj2021-02-16  48

MapObject control used by the layers

Author: Zhangsong Wei

Zswying@163.com

Sometimes some fixed data is fabricated into a layer, and the speed of the program can be improved, and it is convenient to use. Below I will make a simple description of the production method of the layer.

Suppose we have to draw some latitude latitude coordinates on the map, then we must first have an array of latitude latitude coordinates: M_Lonarray, M_LATARRAY, both Carray . Then we add some member variables in CMYVIEW:

CMODATACONNECTION PMOCON;

CMOTABLEDESC DESC;

CMOMAPLAYER LAYER;

CMOPOINT M_POINT;

Ok, it's time to add a function to create a new layer, add a function in the view class: CreateNewLayer ().

Bool cmyview :: CreateNewLayer ()

{

IF (! pmocon.createdispatch ("mapobjects2.dataconnection)))))))

Return False;

IF (! desc.createdispatch ("mapobjects2.tabledesc")))

Return False;

Variant vt;

vt.vt = vt_bool;

vt.boolval = variant_false;

PMocon.SetDatabase ((lpctstr) "E: // Demo // latitude latitude layer"); // Set the layer save directory

IF (! pmocon.connect ())

Return False;

/ / Set the number of fields and properties of the layer, set two, one is Number, one is name. Represents the number and name of the point.

Desc.setfieldcount (2);

Desc.setfieldType (0, MString);

DESC.SETFIELDNAME (0, "Number");

DESC.SETFIELDLENGTH (0, 10);

DESC.SETFIELDTYPE (1, MString);

Desc.setfieldName (1, "name");

Desc.SetfieldLength (1, 10);

// Create a new layer, set the name, type, and field.

CmogeodataSet Geodataset (Pmocon.AddgeodataSet ("latitude latitude layer", MOSHAPETYPEPOINT,

(LPDISPATCH) DESC, VT, VT);

IF (! ") (" MapObjects2.maplayer)))))))))

Return False;

// Set the recording set of the layer

Layer.setGeodataset (GeodataSet);

CMORECORDSET RECS (Layer.GetRecords ());

CMOFIELDS FIELDS (Recs.Getfields ());

For (INT i = 0; i

{

Recs.addnew ();

m_point.setx (m_ lonarray.getat (i));

m_point.sety (m_ latarray.getat (i));

SetValue (Fields, "Shape", M_Point);

SetValue (Fields, "Number", M_Number.Getat (i)); // Need to define CStringArray M_NumBerSetValue (Fields, "Name", M_chname.Getat (i)); // Need to define CSTRIGNARRAY M_NAME

Recs.Update ();

}

// Set the color of the point and join the map.

Layer.getsymbol (). setColor (Molightyellow);

Cmolayers Layers (M_Map.getlayers ());

Layers.Add (layer);

Return True;

}

Ok, call it to try the effect.

I am a limited level, welcome everyone to criticize.

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

New Post(0)