How to create a new layer? Is the created layer permanent or temporary?
How do I obtain an existing layer object?
How to create an element and set its attributes? And draw it out in the layer?
How to create a new layer? Is the created layer permanent or temporary?
You can use the createlayer method of the layers object.
The createlayer method allows you to create a temporary or permanent Maplnfo table layer. The created table has a column name for tagging and data binding. When you want to add or update a graph element, the name attribute is placed in the name column of the person element.
Original function:
Createlayer (name, [filespec], [position], [keylength], [coordsys])
Parameter description:
Name
Specifies the name of the layer (the User Name of the layer ).
Filespec
Shaping: The Path Name of the layer to be created. The file name should include the files (. Map, · dat, etc.) with the. Tab extension in the same path as the. Tab file. If no file name is specified, a temporary layer is created when the map or OCX is deleted.
Position
Shaping: the initial position in the layer list. If this parameter is omitted, the layers are automatically positioned.AlgorithmThe layers are assigned the order of Layers Based on the layer type.
Keylength
Variant: length of the column to which the element name is added to the table. If omitted, the default value is
Coordsys
Coordsys object, which specifies the coordinate system for storing the new layer. Optional. If omitted, use the map. numericcoordsys attribute.
How do I obtain an existing layer object?
Cmapxlayer layer = m_ctrlmapx.getlayers (). Item ("Scratch layer ");
How to create an element and set its attributes? And draw it out in the layer?
BelowCodeCreates a temporary layer and draws a text-type element in the soil layer.
Cmretrial m_ctrlmapx;
Cmapxlayer m_lyrmapxlayer;
M_lyrmapxlayer = m_ctrlmapx.getlayers (). createlayer ("templayer", null, 1, 32 );
M_ctrlmapx.getlayers (). setanimationlayer (m_lyrmapxlayer );
Cmapxfeature m_ftrmapxfeature;
M_ftrmapxfeature.createdispatch (m_ftrmapxfeature.getclsid ());
M_ftrmapxfeature.attach (m_mapview-> m_ctrlmapx.getdispatch ());
// The attach method is used to associate the coordinate system of a map with an independent graph element.
M_ftrmapxfeature.settype (mifeaturetypetext );
// Set the type to text elements
M_ftrmapxfeature.setcaption ("Hello, my deer ");
M_ftrmapxfeature.setstyle (m_ctrlmapx.getdefadefastyle ());
M_ftrmapxfeature.getpoint (). Set (126.61, 45.3 );
// Set the style and position of the element
// Add to layer
m_lyrmapxlayer.addfeature (m_ftrmapxfeature);