本文整理汇总了C#中MapView.SetViewpointRotationAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MapView.SetViewpointRotationAsync方法的具体用法?C# MapView.SetViewpointRotationAsync怎么用?C# MapView.SetViewpointRotationAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapView
的用法示例。
在下文中一共展示了MapView.SetViewpointRotationAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Create a variable to hold the yOffset where the MapView control should start
var yOffset = 60;
// Create a new MapView control and provide its location coordinates on the frame
MapView myMapView = new MapView();
myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset);
// Create a new Map instance with the basemap
var myBasemap = Basemap.CreateStreets();
Map myMap = new Map(myBasemap);
// Assign the Map to the MapView
myMapView.Map = myMap;
// Create a label to display the MapView rotation value
UILabel rotationLabel = new UILabel();
rotationLabel.Frame = new CoreGraphics.CGRect(View.Bounds.Width - 60, 8, View.Bounds.Width, 24);
rotationLabel.Text = string.Format("{0:0}°", myMapView.MapRotation);
// Create a slider to control the MapView rotation
UISlider rotationSlider = new UISlider()
{
MinValue = 0,
MaxValue = 360,
Value = (float)myMapView.MapRotation
};
rotationSlider.Frame = new CoreGraphics.CGRect(10, 8, View.Bounds.Width - 100, 24);
rotationSlider.ValueChanged += (Object s, EventArgs e) =>
{
myMapView.SetViewpointRotationAsync(rotationSlider.Value);
rotationLabel.Text = string.Format("{0:0}°", rotationSlider.Value);
};
// Create a UIBarButtonItem where its view is the rotation slider
UIBarButtonItem barButtonSlider = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
barButtonSlider.CustomView = rotationSlider;
// Create a UIBarButtonItem where its view is the rotation label
UIBarButtonItem barButtonLabel = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
barButtonLabel.CustomView = rotationLabel;
// Create a toolbar on the bottom of the display
UIToolbar toolbar = new UIToolbar();
toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height);
toolbar.AutosizesSubviews = true;
// Add the bar button items to an array of UIBarButtonItems
UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonSlider, barButtonLabel };
// Add the UIBarButtonItems array to the toolbar
toolbar.SetItems(barButtonItems, true);
View.AddSubviews(myMapView, toolbar);
}
示例2: Initialize
void Initialize()
{
var layout = new LinearLayout(this) { Orientation = Orientation.Vertical };
// Create a slider (SeekBar) control for selecting an angle
var angleSlider = new SeekBar(this);
// Set a maximum slider value of 180 and a current value of 90 (minimum is always 0)
angleSlider.Max = 180;
angleSlider.Progress = 0;
// When the slider value (Progress) changes, rotate the map
angleSlider.ProgressChanged += async (object s, SeekBar.ProgressChangedEventArgs e) =>
{
if (e.FromUser)
{
// Set rotation asynchronously
await _myMapView.SetViewpointRotationAsync(e.Progress);
// Display the MapView's rotation.
_loadStatusTextView.Text = string.Format("{0:0}°", _myMapView.MapRotation);
}
};
// Create a new Map instance with the basemap
Basemap myBasemap = Basemap.CreateStreets();
Map myMap = new Map(myBasemap);
// Create a new map view control to display the map
_myMapView = new MapView();
_myMapView.Map = myMap;
// Set the current map rotation to match the default slider value
// (no need to await the asynchronous call)
_myMapView.SetViewpointRotationAsync(angleSlider.Progress);
// Add a label to display the MapView's rotation.
_loadStatusTextView = new TextView(this);
layout.AddView(_loadStatusTextView);
// Add the slider and map view to the layout
layout.AddView(angleSlider);
layout.AddView(_myMapView);
// Apply the layout to the app
SetContentView(layout);
}