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 | |
---|---|---|
PositionOrigin(Double, Double) | Initializes a new instance of the PositionOrigin class. |
Properties
Name | Description | |
---|---|---|
X | Gets or sets the x-axis position of the position origin. |
|
Y | Gets or sets the y-axis position of the position origin. |
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified object is equal to this position origin.(Overrides ValueType.Equals(Object).) |
|
Equals(PositionOrigin) | Determines whether the specified position origin is equal to this position origin. |
|
GetHashCode() | Retrieves the hash code for this position origin.(Overrides ValueType.GetHashCode().) |
|
GetType() | (Inherited from Object.) |
|
ToString() | (Inherited from ValueType.) |
Fields
Name | Description | |
---|---|---|
BottomCenter | Specifies the bottom center of the position. |
|
BottomLeft | Specifies the bottom left of the position. |
|
BottomRight | Specifies the bottom right of the position. |
|
Center | Specifies the center of the position. |
|
CenterLeft | Specifies the center left of the position. |
|
CenterRight | Specifies the center right of the position. |
|
TopCenter | Specifies the top center of the position. |
|
TopLeft | Specifies the top left of the position. |
|
TopRight | Specifies the top right of the position. |
Operators
Name | Description | |
---|---|---|
Equality(PositionOrigin, PositionOrigin) | Determines whether two position origin objects are equal. |
|
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