Maps and layers

Source: Internet
Author: User
Tags imap
Well written, clear thinking after reading
Http://hi.baidu.com/murphy1314/blog/category/Arcengine

[Content ]:
Access Maps and Layers
Traverse maps and layers
Collections
Enumerations
Create a new layer
Use properties of a layer object
Set a data source for a Layer

In the ArcMap application:
Application represents ArcMap,
An Application consists of MxDocument,
An MxDocument consists of multiple maps,
A Map consists of multiple layers,
Layer is the base class of FeatureLayer.
Now, we need to know that a FeatureLayer is associated with 0 or 1 FeatureClass.
Dataset is an abstract base class, Table is an instantiation class, derived from Dataset, and FeatureClass is a child class of Table.
Multiple featureclasses form FeatureDataset.

Access maps:
Access maps by MxDocument
Obtain the current map
Dim pMxDoc as IMxDocument
Set pMxDoc = ThisDocument
Dim pMap as IMap
Set pMap = pMxDoc. FocusMap
Obtain maps (IMaps)
Is a set of Map
Dim pAllMaps as IMaps
Set pAllMaps = pMxDoc. Maps
A map document can contain multiple data boxes, each of which can have different layers and representations.
FocusMap is the data frame pointing to the current activity.

Access Layers:
Access layers with map and MxDocument
Obtain the selected layer (IMxDocument)
Dim pLayer as ILayer
Set pLayer = pMxDoc. SelectLayer
Obtain the specified layer (IMap)
Dim pLayer as ILayer
Set pMap = pMxDoc. FocusMap
Set pLayer = pMap. Layer (3)
Get all layers (IMap)
Enumeration of a Layer
Dim pAllLayers as IEnumLayer
Set pAllLayers = pMap. Layers

Traverse the Maps set:
The set is ordered.
The subscript of the first item is 0.
Dim intIndex as Integer
Dim pMaps as IMaps
Set pMaps = pMxDoc. maps

For intIndex = 0 to pMaps. Count-1
MsgBox pMaps. item (intIndex). Name
Next

Traverse a layer object in a Map object:
The IMaps layer set attribute returns IEnumLayers, which only has two methods: Next and Reset.
It seems that it is a set of fewer attributes and Methods. Next returns ILayer, and the current Reset Pointer Points to top, that is, the front edge of the first item.
Dim pLayer as ILayer
Dim pLayers as IEnumLayers
Set pLayers = pMap. layers

Set pLayer = pLayers. Next;
Set pLayer = pLayers. Next;

Add a new layer to Map:
Layer is an abstract class: cannot be created
Subclasses that can be created: TinLayer, FeatureLayer, and RasterLayer.
Dim pFLayer as ILayer
Set pFLayer = new FeatureLayer
Dim pMxDoc as IMxDocument
Dim pMap as IMap
Set pMxDoc = thisdocument
Set pMap = pMxDoc. focusmap
PMap. AddLayer pFLayer
Because no data source is set, the icon is in the lost data connection status.

Use a layer object:
Attributes of the ILayer interface: Name Visible ShowTips MaximumScale MinimumScale, etc.
IGeoDataSet interface property: Extent SpatialReference

Dim pLayer as ILayer
Set pLayer = pMxDoc. SelectedLayer

PLayer. Name = "Streets"
PLayer. Visible = true
PLayer. ShowTips = false

Set the FeatureLayer Data source:
FeatureClass attribute (IFeatureLayer)
Data Source displayed
To pass the reference (the set keyword must be used)
Dim pFLayer as IFeatureLayer
Set pFLayer = new FeatureLayer
Dim pFClass as IFeatureClass
Set pFClass = pSomeObjLayer. FeatureClass
Set pFLayer. FeatureClass = pFClass

Related Article

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.