Summary of traversing the Layer Method in mapcontrol

Source: Internet
Author: User

You can use get_layers () in IMAP to traverse the current layer in mapcontrol. This method can filter or classify layers by specifying the UID.

1. Traverse vector layers

Public ienumlayer getfeaturelayers ()
{
UID uid = new uidclass ();
UID. value = "{40a9e885-5533-11d0-98be-00805f7ced21}"; // featurelayer
Ienumlayer layers = frmmap. m_mapctrl.map.get_layers (UID, true );
Return layers;
}

2. traverse the raster layer

Public ienumlayer getrasterlayers ()
{
UID uid = new uidclass ();
UID. value = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}"; // rasterlayer
Ienumlayer layers = frmmap. m_mapctrl.map.get_layers (UID, true );
Return layers;
}

3. Traverse other layers

You only need to modify the UID. Common data types include:

{6ca416b1-e160-11d2-9f4e-00c04f6bc78e} idatalayer (including all types of layers)
{40a9e885-5533-11d0-98be-00805f7ced21} ifeaturelayer
E156D7E5-22AF-11D3-9F99-00C04F6BC78E} igeofeaturelayer
{34b2ef81-f4ac-11d1-a245-080009b6f22b} igraphicslayer
{5ceae408-4c0a-437f-9db3-054d83919850} ifdographicslayer
{0c22a4c7-dafd-11d2-9f46-00c04f6bc78e} icoverageannotationlayer
{EDAD6644-1810-11D1-86AE-0000F8751720} igrouplayer

4. Obtain the layer interface using the layer name

This is a common feature in AE development. It is easy to implement it in combination with the above method.

// Obtain the vector layer interface
Public ifeaturelayer getfeaturelayer (string layername)
{
// Get the layers from the maps
Ienumlayer layers = getfeaturelayers ();
Layers. Reset ();
Ilayer layer = NULL;
While (layer = layers. Next ())! = NULL)
{
If (layer. Name = layername)
Return layer as ifeaturelayer;
}
Return NULL;
}

// Obtain the raster layer interface
Public irasterlayer getrasterlayer (string layername)
{
// Get the layers from the maps
Ienumlayer layers = getrasterlayers ();
Layers. Reset ();
Ilayer layer = NULL;
While (layer = layers. Next ())! = NULL)
{
If (layer. Name = layername)
Return layer as irasterlayer;
}
Return NULL;
}
 

Obtain other layer interfaces, similar to this. This article from 3sdn reprinted please in the form of links to indicate the source URL: http://www.3sdn.net/gis2dev/ AE /2009-08-29/454.html

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.