Share via


ZOrder method

Moves the specified shape in front of or behind other shapes in the Shapes collection or roads on the map; similar to using the Draw menu entries on the Drawing toolbar.

Applies to

Objects: Shape

Syntax

object.ZOrder(ZOrderCmd)

Parameters

Part

Description

object

Required. An expression that returns a Shape object.

ZOrderCmd

Required GeoZOrderCmd. Indicates where to move the specified shape relative to other shapes in the collection, and to roads on the map.

GeoZOrderCmd Value Description
geoBringForward 2 Moves the shape up, or forward, one position in the order
geoBringInFrontOfRoads 4 Moves the shape on top of roads
geoBringToFront 0 Moves the shape to the first position in the order
geoSendBackward 3 Moves the shape down, or back, one position in the order
geoSendBehindRoads 5 Moves the shape behind roads
geoSendToBack 1 Moves the shape to the last position in the order

Remarks

  • To return the position of a shape within a Shapes collection, use the ZOrderPosition property of the Shape object.

Example

[Microsoft Visual Basic 6.0]

Sub BringRectangleForward()

Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc As MapPoint.Location

'Set up application and get a location object
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
Set objLoc = objApp.ActiveMap.GetLocation(0, 0)

'Create two shapes at this location and zoom to this location
Set objMap.Location = objLoc
objMap.Shapes.AddShape geoShapeRectangle, objLoc, 20, 30
objMap.Shapes.AddShape geoShapeRadius, objLoc, 30, 40

'Change the rectangle color, then bring it to the front
objMap.Shapes.Item(1).Line.ForeColor = vbBlue
objMap.Shapes.Item(1).ZOrder geoBringForward

End Sub

[C#]

void BringRectangleForward()
{
MapPoint.Application objApp = new MapPoint.Application();
MapPoint.Map objMap;
MapPoint.Location objLoc;

//Set up application and get a location object
objMap = objApp.ActiveMap;
objApp.Visible = true;
objApp.UserControl = true;
objLoc = objApp.ActiveMap.GetLocation(0, 0, 0.0);

//Create two shapes at this location and zoom to this location
objMap.Location = objLoc;
objMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeRectangle, objLoc, 20, 30);
objMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeRadius, objLoc, 30, 40);

//Declare index as object
object index = 1;
//Fill the shape (make fill visible), then change the fill color
objMap.Shapes.get_Item(ref index).Fill.Visible = true;
//Create an instance of a Color structure and assign Blue - assume System.Drawing.dll is referenced
System.Drawing.Color myColor = System.Drawing.Color.Blue;
//Convert the color object to int
int iBlue = System.Drawing.ColorTranslator.ToOle(myColor);
//Change the rectangle color, then bring it to the front
objMap.Shapes.get_Item(ref index).Line.ForeColor = iBlue;
objMap.Shapes.get_Item(ref index).ZOrder(MapPoint.GeoZOrderCmd.geoBringForward);
}