MapX references layers and creates instances.

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.