Share via


PositionOrigin Structure

 

Represents the anchor point of UIElement, such as an image, at a Location on a MapLayer.

Namespace:   Microsoft.Maps.MapControl.WPF
Assembly:  Microsoft.Maps.MapControl.WPF (in Microsoft.Maps.MapControl.WPF.dll)

Syntax

[TypeConverterAttribute(typeof(PositionOriginConverter))]
public struct PositionOrigin
[TypeConverterAttribute((PositionOriginConverter^::typeid))]
public value struct PositionOrigin
[<Sealed>]
[<TypeConverterAttribute(typeof(PositionOriginConverter))>]
type PositionOrigin = struct end
<TypeConverterAttribute(GetType(PositionOriginConverter))>
Public Structure PositionOrigin

Constructors

Name Description
System_CAPS_pubmethod PositionOrigin(Double, Double)

Initializes a new instance of the PositionOrigin class.

Properties

Name Description
System_CAPS_pubproperty X

Gets or sets the x-axis position of the position origin.

System_CAPS_pubproperty Y

Gets or sets the y-axis position of the position origin.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

Determines whether the specified object is equal to this position origin.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethod Equals(PositionOrigin)

Determines whether the specified position origin is equal to this position origin.

System_CAPS_pubmethod GetHashCode()

Retrieves the hash code for this position origin.(Overrides ValueType.GetHashCode().)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from ValueType.)

Fields

Name Description
System_CAPS_pubfieldSystem_CAPS_static BottomCenter

Specifies the bottom center of the position.

System_CAPS_pubfieldSystem_CAPS_static BottomLeft

Specifies the bottom left of the position.

System_CAPS_pubfieldSystem_CAPS_static BottomRight

Specifies the bottom right of the position.

System_CAPS_pubfieldSystem_CAPS_static Center

Specifies the center of the position.

System_CAPS_pubfieldSystem_CAPS_static CenterLeft

Specifies the center left of the position.

System_CAPS_pubfieldSystem_CAPS_static CenterRight

Specifies the center right of the position.

System_CAPS_pubfieldSystem_CAPS_static TopCenter

Specifies the top center of the position.

System_CAPS_pubfieldSystem_CAPS_static TopLeft

Specifies the top left of the position.

System_CAPS_pubfieldSystem_CAPS_static TopRight

Specifies the top right of the position.

Operators

Name Description
System_CAPS_puboperatorSystem_CAPS_static Equality(PositionOrigin, PositionOrigin)

Determines whether two position origin objects are equal.

System_CAPS_puboperatorSystem_CAPS_static Inequality(PositionOrigin, PositionOrigin)

Determines whether two position origins are not equal.

Remarks

This property defines the anchor point of a UIElement by specifying an enumeration value or providing a pair of coordinate values between 0 and 1 where (0,0) is the top-left coordinate and (1,1) is the bottom-right coordinate.

Examples

The following example shows how to add an image to a map layer and set the anchor point of the image by using the PositionOrigin property. For the complete code, see Adding Media to the Map.

private void addImageToMap(object sender, RoutedEventArgs e)
{
    MapLayer imageLayer = new MapLayer();


    Image image = new Image();
    image.Height = 150;
    //Define the URI location of the image
    BitmapImage myBitmapImage = new BitmapImage();
    myBitmapImage.BeginInit();
    myBitmapImage.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/commons/d/d4/Golden_Gate_Bridge10.JPG");
    // To save significant application memory, set the DecodePixelWidth or  
    // DecodePixelHeight of the BitmapImage value of the image source to the desired 
    // height or width of the rendered image. If you don't do this, the application will 
    // cache the image as though it were rendered as its normal size rather then just 
    // the size that is displayed.
    // Note: In order to preserve aspect ratio, set DecodePixelWidth
    // or DecodePixelHeight but not both.
    //Define the image display properties
    myBitmapImage.DecodePixelHeight = 150;
    myBitmapImage.EndInit();
    image.Source = myBitmapImage;
    image.Opacity = 0.6;
    image.Stretch = System.Windows.Media.Stretch.None;

    //The map location to place the image at
    Location location = new Location() { Latitude = 37.8197222222222, Longitude = -122.478611111111 };
    //Center the image around the location specified
    PositionOrigin position = PositionOrigin.Center;

    //Add the image to the defined map layer
    imageLayer.AddChild(image, location, position);
    //Add the image layer to the map
    myMap.Children.Add(imageLayer);
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.Maps.MapControl.WPF Namespace

Return to top