本文整理汇总了C#中MKMapView.SetRegion方法的典型用法代码示例。如果您正苦于以下问题:C# MKMapView.SetRegion方法的具体用法?C# MKMapView.SetRegion怎么用?C# MKMapView.SetRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MKMapView
的用法示例。
在下文中一共展示了MKMapView.SetRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
mapView.Delegate = new MyDelegate();
View = mapView;
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var secondViewModel = (SecondViewModel)ViewModel;
var hanAnnotation = new ZombieAnnotation(secondViewModel.Han);
mapView.AddAnnotation(hanAnnotation);
mapView.SetRegion(MKCoordinateRegion.FromDistance(
new CLLocationCoordinate2D(secondViewModel.Han.Location.Lat, secondViewModel.Han.Location.Lng),
20000,
20000), true);
var button = new UIButton(UIButtonType.RoundedRect);
button.Frame = new RectangleF(10, 10, 300, 40);
button.SetTitle("move", UIControlState.Normal);
Add(button);
var set = this.CreateBindingSet<SecondView, Core.ViewModels.SecondViewModel>();
set.Bind(hanAnnotation).For(a => a.Location).To(vm => vm.Han.Location);
set.Bind(button).For("Title").To(vm => vm.Han.Location);
set.Apply();
}
示例2: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
mapView.Delegate = new MyDelegate();
View = mapView;
base.ViewDidLoad();
var firstViewModel = (FirstViewModel) ViewModel;
var helenAnnotation = new ZombieAnnotation(firstViewModel.Helen);
var keithAnnotation = new ZombieAnnotation(firstViewModel.Keith);
mapView.AddAnnotation(helenAnnotation);
mapView.AddAnnotation(keithAnnotation);
mapView.SetRegion(MKCoordinateRegion.FromDistance(
new CLLocationCoordinate2D(firstViewModel.Helen.Location.Lat, firstViewModel.Helen.Location.Lng),
20000,
20000), true);
var button = new UIButton(UIButtonType.RoundedRect);
button.Frame = new RectangleF(10, 10, 300, 40);
button.SetTitle("move", UIControlState.Normal);
Add(button);
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
set.Bind(button).To(vm => vm.MoveCommand);
set.Bind(helenAnnotation).For(a => a.Location).To(vm => vm.Helen.Location);
set.Bind(keithAnnotation).For(a => a.Location).To(vm => vm.Keith.Location);
set.Apply();
}
示例3: GeocoderViewControllerAdapter
public GeocoderViewControllerAdapter(MvxViewController viewController, MKMapView mapView, Action<string> addressChanged)
: base(viewController)
{
_geocoder = new CLGeocoder ();
_addressChanged = addressChanged;
mapView.RegionChanged += MapView_RegionChanged;
mapView.SetRegion (new MapKit.MKCoordinateRegion (new CoreLocation.CLLocationCoordinate2D (45.5316085, -73.6227476), new MapKit.MKCoordinateSpan (0.01, 0.01)), animated: true);
}
示例4: DidUpdateUserLocation
public void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation)
{
Console.WriteLine("Weak Lat: {0}, Long: {1}, Alt: {2}", userLocation.Coordinate.Latitude, userLocation.Coordinate.Longitude, userLocation.Location.Altitude);
currLocation = userLocation.Coordinate;
if (firstLaunch) {
mapView.SetRegion(MKCoordinateRegion.FromDistance(currLocation, 250, 250), true);
firstLaunch = false;
}
else
mapView.SetCenterCoordinate(currLocation, true);
}
示例5: CreateMapView
void CreateMapView()
{
if (_mapView != null)
return;
_mapView = new MKMapView {ShowsUserLocation = true, GetViewForAnnotation = GetViewForAnnotation};
View = _mapView;
var visibleRegion = BuildVisibleRegion(_centerCoordinate);
_mapView.SetRegion(visibleRegion, animated: true);
}
示例6: MapOverlay
public MapOverlay()
: base(new RectangleF (0, 0, 144, 144))
{
map = new MKMapView (Bounds) {
AutoresizingMask = UIViewAutoresizing.FlexibleDimensions,
ShowsUserLocation = true,
MapType = MKMapType.Satellite,
};
map.SetRegion (MKCoordinateRegion.FromDistance (new CLLocationCoordinate2D (47,-122), 1, 1), false);
map.UserTrackingMode = MKUserTrackingMode.FollowWithHeading;
Alpha = 0.5f;
AddSubview (map);
}
示例7: ZoomToUserLocation
void ZoomToUserLocation(MKMapView mapView, MKUserLocation l)
{
var span = new MKCoordinateSpan
{
LatitudeDelta = 0.1,
LongitudeDelta = 0.1,
};
var region = new MKCoordinateRegion
{
Center = l.Coordinate,
Span = span,
};
mapView.SetRegion (region, true);
}
示例8: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
// Create the 'Shows' tab.
dvc1 = new DialogViewController (null) {
Root = new RootElement ("") {
new Section (), new Section (), new Section (),
new Section () {
new StringElement ("House of Cards"),
new StringElement ("Game of Thrones"),
new StringElement ("Person of Interest")
}
}
};
// Create the 'Games' tab.
dvc2 = new DialogViewController (null) {
Root = new RootElement ("") {
new Section (), new Section (), new Section (),
new Section () {
new StringElement ("Braid"),
new StringElement ("Super Meat Boy"),
new StringElement ("Fez")
}
}
};
// Create the 'Atlanta' tab.
var mapView = new MKMapView (UIScreen.MainScreen.Bounds);
var atlanta = new MKCoordinateRegion (new CLLocationCoordinate2D (33.748893, -84.388046), new MKCoordinateSpan (0.35, 0.35));
mapView.SetRegion (atlanta, false);
mapViewController = new UIViewController ();
mapViewController.View.Bounds = UIScreen.MainScreen.Bounds;
mapViewController.View.AddSubview (mapView);
// Create and display the floating tab bar controller.
ftbc = new FloatingTabBarController () {
TabTitles = new List<string> () { "Shows", "Games", "Atlanta" },
ViewControllers = new List<UIViewController> () { dvc1, dvc2, mapViewController }
};
window.RootViewController = ftbc;
window.MakeKeyAndVisible ();
return true;
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
var map = new MKMapView(new RectangleF(20, 166, 280, 192));
this.View.Add(map);
map.ShowsUserLocation = true;
map.MapType = MKMapType.Standard;
map.Delegate = new MapViewDelegate();
var location = new CLLocationCoordinate2D(ViewModel.Latitude, ViewModel.Longitude);
//map.SetCenterCoordinate(location, true);
map.SetRegion(new MKCoordinateRegion(location, new MKCoordinateSpan(0.1, 0.1)), true);
var annotation = new MyAnnotation(
location
, ViewModel.SharedTextSource.GetText("AppTitle")
, ViewModel.Name);
map.AddAnnotationObject(annotation);
Button1.SetImage(UIImage.FromFile("ConfResources/Images/appbar.link.png"), UIControlState.Normal);
Button2.SetImage(UIImage.FromFile("ConfResources/Images/appbar.phone.png"), UIControlState.Normal);
Button3.SetImage(UIImage.FromFile("ConfResources/Images/appbar.feature.email.rest.png"), UIControlState.Normal);
this.AddBindings(new Dictionary<object, string>()
{
{Label1,"Text Name"},
{Button1,"Title Address"},
{Button2,"Title Phone"},
{Button3,"Title Email"},
});
this.AddBindings(new Dictionary<object, string>()
{
{Button1,"TouchUpInside WebPageCommand"},
{Button2,"TouchUpInside PhoneCommand"},
{Button3,"TouchUpInside EmailCommand"},
});
NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.DoShareGeneral()), false);
}
示例10: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
mapView.Delegate = new MyDelegate();
View = mapView;
base.ViewDidLoad();
var thirdViewModel = (ThirdViewModel)ViewModel;
_zombieManager = new ZombieManager(mapView);
mapView.SetRegion(MKCoordinateRegion.FromDistance(
new CLLocationCoordinate2D(51.4, 0.4),
50000,
50000), true);
var set = this.CreateBindingSet<ThirdView, Core.ViewModels.ThirdViewModel>();
set.Bind(_zombieManager).For(z => z.ItemsSource).To(vm => vm.Yarp);
set.Apply();
}
示例11: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
mapView.Delegate = new MyDelegate();
View = mapView;
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var thirdViewModel = (ThirdViewModel)ViewModel;
_zombieManager = new ZombieManager(mapView);
mapView.SetRegion(MKCoordinateRegion.FromDistance(
new CLLocationCoordinate2D(51.4, 0.4),
50000,
50000), true);
var set = this.CreateBindingSet<ThirdView, Core.ViewModels.ThirdViewModel>();
set.Bind(_zombieManager).For(z => z.ItemsSource).To(vm => vm.Yarp);
set.Apply();
}
示例12: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
mapView = new MKMapView()
{
ShowsUserLocation = true
};
labelDistance = new UILabel()
{
Frame = new RectangleF (0, 0, 320, 49),
Lines = 2,
BackgroundColor = UIColor.Black,
TextColor = UIColor.White
};
var segmentedControl = new UISegmentedControl();
var topOfSegement = View.Frame.Height - 120;
segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30);
segmentedControl.InsertSegment("Map".GetText(), 0, false);
segmentedControl.InsertSegment("Satellite".GetText(), 1, false);
segmentedControl.InsertSegment("Hybrid".GetText(), 2, false);
segmentedControl.SelectedSegment = 0;
segmentedControl.ControlStyle = UISegmentedControlStyle.Bar;
segmentedControl.TintColor = UIColor.DarkGray;
segmentedControl.ValueChanged += delegate {
if (segmentedControl.SelectedSegment == 0)
mapView.MapType = MonoTouch.MapKit.MKMapType.Standard;
else if (segmentedControl.SelectedSegment == 1)
mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite;
else if (segmentedControl.SelectedSegment == 2)
mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid;
};
mapView.Delegate = new MapViewDelegate(this);
// Set the web view to fit the width of the app.
mapView.SizeToFit();
// Reposition and resize the receiver
mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100);
MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01);
MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span);
mapView.SetRegion(region, true);
ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation
, "CodeCampSDQ"
, "INTEC"
);
mapView.AddAnnotationObject(a);
locationManager = new CLLocationManager();
locationManager.Delegate = new LocationManagerDelegate(mapView, this);
locationManager.StartUpdatingLocation();
// Add the table view as a subview
View.AddSubview(mapView);
View.AddSubview(labelDistance);
View.AddSubview(segmentedControl);
// Add the 'info' button to flip
var flipButton = UIButton.FromType(UIButtonType.InfoLight);
flipButton.Frame = new RectangleF(290,17,20,20);
flipButton.Title (UIControlState.Normal);
flipButton.TouchDown += delegate {
_mfvc.Flip();
};
View.AddSubview(flipButton);
}
示例13: BuildView
//.........这里部分代码省略.........
if (CurrentDisplayMode == DisplayMode.Bikes)
{
valueToCheck = mapAnnotation.Bike.BikesAvailable;
} else {
valueToCheck = mapAnnotation.Bike.DocksAvailable;
}
if ((valueToCheck < 5 && valueToCheck != -1)) {
if (valueToCheck == 0)
{
pinView.PinColor = MKPinAnnotationColor.Red;
} else {
pinView.PinColor = MKPinAnnotationColor.Purple;
}
} else {
pinView.PinColor = MKPinAnnotationColor.Green;
}
mapAnnotation.PinView = pinView;
pinView.CanShowCallout = true;
return pinView;
}
if (annotation is CSRouteAnnotation)
{
var routeAnnotation = annotation as CSRouteAnnotation;
MKAnnotationView annotationView = null;
if (annotationView == null)
{
routeView = new CSRouteView(new RectangleF (0,0, mapView.Frame.Size.Width, mapView.Frame.Size.Height));
routeView.Annotation = routeAnnotation;
routeView.MapView = mapViewForAnnotation;
annotationView = routeView;
}
return annotationView;
}
return null;
};
List<MKAnnotation> locations = new List<MKAnnotation>();
double minLon = 200, minLat = 200, maxLon = -200, maxLat = -200;
foreach(var bike in BikeLocation.AllBikes)
{
if (bike.Location.Longitude < minLon) minLon = bike.Location.Longitude;
if (bike.Location.Latitude < minLat) minLat = bike.Location.Latitude;
if (bike.Location.Longitude < maxLon) maxLon = bike.Location.Longitude;
if (bike.Location.Latitude > maxLat) maxLat = bike.Location.Latitude;
locations.Add(new CycleAnnotation(bike));
}
if (locations.Count > 0)
{
mapView.AddAnnotation(locations.ToArray());
var tl = new CLLocationCoordinate2D(-90, 180);
var br = new CLLocationCoordinate2D(90, -180);
foreach(MKAnnotation an in mapView.Annotations)
{
tl.Longitude = Math.Min(tl.Longitude, an.Coordinate.Longitude);
tl.Latitude = Math.Max(tl.Latitude, an.Coordinate.Latitude);
br.Longitude = Math.Max(br.Longitude, an.Coordinate.Longitude);
br.Latitude = Math.Min(br.Latitude, an.Coordinate.Latitude);
}
var center = new CLLocationCoordinate2D {
Latitude = tl.Latitude - (tl.Latitude - br.Latitude) *0.5,
Longitude = tl.Longitude - (tl.Longitude - br.Longitude) *0.5
};
var span = new MKCoordinateSpan
{
LatitudeDelta = Math.Abs(tl.Latitude - br.Latitude) *0.5,
LongitudeDelta = Math.Abs(tl.Longitude - br.Longitude) *0.5
};
MKCoordinateRegion region = new MKCoordinateRegion (center, span );
region = mapView.RegionThatFits(region);
mapView.SetRegion(region, true);
}
mapView.ShowsUserLocation = true;
View.AddSubview(mapView);
}
}
示例14: DidUpdateUserLocation
/// <summary>
/// Center the map when the user is located
/// </summary>
public override void DidUpdateUserLocation (MKMapView mapView, MKUserLocation userLocation)
{
if (userLocation != null) {
var span = new MKCoordinateSpan (15, 15);
var region = new MKCoordinateRegion (userLocation.Coordinate, span);
mapView.SetRegion (region, true);
}
}
示例15: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
mapView = new MKMapView()
{
ShowsUserLocation = true
};
labelDistance = new UILabel()
{
Frame = new RectangleF (0, 0, 320, 49),
Lines = 2,
BackgroundColor = UIColor.Black,
TextColor = UIColor.White
};
var segmentedControl = new UISegmentedControl();
var topOfSegement = View.Frame.Height - 120;
segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30);
segmentedControl.InsertSegment("Map", 0, false);
segmentedControl.InsertSegment("Satellite", 1, false);
segmentedControl.InsertSegment("Hybrid", 2, false);
segmentedControl.SelectedSegment = 0;
segmentedControl.ControlStyle = UISegmentedControlStyle.Bar;
segmentedControl.TintColor = UIColor.DarkGray;
if(UIDevice.CurrentDevice.CheckSystemVersion(6,0))
segmentedControl.InsertSegment ("Directions", 3, false);
segmentedControl.ValueChanged += delegate {
if (segmentedControl.SelectedSegment == 0)
mapView.MapType = MonoTouch.MapKit.MKMapType.Standard;
else if (segmentedControl.SelectedSegment == 1)
mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite;
else if (segmentedControl.SelectedSegment == 2)
mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid;
else if (segmentedControl.SelectedSegment == 3) {
var conferenceMapItem = new MKMapItem(new MKPlacemark(ConferenceLocation, null));
conferenceMapItem.Name = "MonkeySpace";
var conferenceHotel = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(42.36346, -71.0863), null));
conferenceHotel.Name = "MonkeySpace Hotel";
var mapItems = new MKMapItem[] { conferenceMapItem, conferenceHotel };
MKMapItem.OpenMaps(mapItems, new MKLaunchOptions() {
DirectionsMode = MKDirectionsMode.Walking
});
}
};
mapView.Delegate = new MapViewDelegate(this);
// Set the web view to fit the width of the app.
mapView.SizeToFit();
// Reposition and resize the receiver
mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100);
MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01);
MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span);
mapView.SetRegion(region, true);
ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation
, "MonkeySpace"
, "NERD Center"
);
mapView.AddAnnotationObject(a);
locationManager = new CLLocationManager();
locationManager.Delegate = new LocationManagerDelegate(mapView, this);
locationManager.StartUpdatingLocation();
// Add the table view as a subview
View.AddSubview(mapView);
View.AddSubview(labelDistance);
View.AddSubview(segmentedControl);
// Add the 'info' button to flip
var flipButton = UIButton.FromType(UIButtonType.InfoLight);
flipButton.Frame = new RectangleF(290,17,20,20);
flipButton.Title (UIControlState.Normal);
flipButton.TouchDown += delegate {
_mfvc.Flip();
};
View.AddSubview(flipButton);
}