Add layer to Map with “autoArrange”

One of the very common operations programmers do in ArcObjects is adding a layer to the Map. To do this there are two ways, one using IMap.AddLayer or IMapLayers.AddLayer.

IMap.AddLayer adds the new layer on the top of all the layers in the map. This is not very useful as we normally want the point layers at the top followed by polyline followed by polygon layers. Adding polygon layers at the top would mask all other layers below.

IMapLayers.AddLayer is preferable because it has an option to autoArrange the newly added layer in the table of contents. If autoArrange is set to TRUE, the layer is added in the proper position as by its weight specified via ILayerPosition::LayerWeight. By default, this means that the layers are sorted by layer type – Annotation layers on top, followed by Point geometry layers, Polyline geometry layers, and at the bottom Polygon geometry layers.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: