本文整理汇总了C#中MKMapView.AddAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# MKMapView.AddAnnotation方法的具体用法?C# MKMapView.AddAnnotation怎么用?C# MKMapView.AddAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MKMapView
的用法示例。
在下文中一共展示了MKMapView.AddAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
RouteViews = new Dictionary<string,CSRouteView>();
// load the points from local resource (file)
var filePath = NSBundle.MainBundle.PathForResource("route", "csv", "MapLineSharp","");
var fileContents = System.IO.File.ReadAllText(filePath);
var pointStrings = fileContents.Split('\n');
var points = new List<CLLocation>();
foreach (var ps in pointStrings)
{
// break the string down into latitude and longitude fields
var latLonArr = ps.Split(',');
double latitude = Convert.ToDouble(latLonArr[0]);
double longitude = Convert.ToDouble(latLonArr[1]);
CLLocation currentLocation = new CLLocation(latitude, longitude);
points.Add(currentLocation);
}
//
// Create our map view and add it as as subview.
//
_mapView = new MKMapView();
_mapView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height);
View.AddSubview(_mapView);
_mapView.Delegate = new MapViewDelegate(this);
// CREATE THE ANNOTATIONS AND ADD THEM TO THE MAP
// first create the route annotation
CSRouteAnnotation routeAnnotation = new CSRouteAnnotation(points);
_mapView.AddAnnotation(routeAnnotation);
CSMapAnnotation annotation = null;
annotation = new CSMapAnnotation (points[0].Coordinate, CSMapAnnotationType.Start, "Start Point");
_mapView.AddAnnotation (annotation);
annotation = new CSMapAnnotation (points[points.Count - 1].Coordinate, CSMapAnnotationType.End, "End Point");
_mapView.AddAnnotation (annotation);
//TODO:create the image annotation
_mapView.SetRegion (routeAnnotation.Region, false);
}
示例3: MapController
public MapController(Entity entity)
{
try {
Entity = entity;
Title = Entity.EntityTypeName;
_map = new MKMapView ();
_pin = new Pin(Entity);
_map.Frame = View.Bounds;
_map.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
_map.AddAnnotation(_pin);
_map.Region = new MKCoordinateRegion (_pin.Coordinate, new MKCoordinateSpan (0.01, 0.01));
View.AddSubview (_map);
_map.SelectAnnotation(_pin, true);
} catch (Exception error) {
Log.Error (error);
}
}
示例4: LoadView
public override void LoadView ()
{
// Set title of screen to game title
Title = Game.Title;
// Create MapView and add to Container View
map = new MKMapView (UIScreen.MainScreen.Bounds);
View = map;
// Center map on current location
map.DidUpdateUserLocation += (sender, e) => {
if (map.UserLocation != null) {
CLLocationCoordinate2D coords = map.UserLocation.Coordinate;
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coords.Latitude));
map.Region = new MKCoordinateRegion(coords, span);
}
};
map.ShowsUserLocation = true;
map.ZoomEnabled = true;
map.ShowsPointsOfInterest = false;
// Add Stockists to map
Game.Stockists.ForEach (shop => map.AddAnnotation (new MKPointAnnotation () {
Title = shop.Title,
Coordinate = new CLLocationCoordinate2D () {
Latitude = shop.Latitude,
Longitude = shop.Longitude
}
}));
}
示例5: 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();
}
示例6: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
// add the map view
var map = new MKMapView(UIScreen.MainScreen.Bounds);
View.Add(map);
// change the map style
map.MapType = MKMapType.Standard;
// enable/disable interactions
// map.ZoomEnabled = false;
// map.ScrollEnabled = false;
// show user location
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
locationManager.RequestAlwaysAuthorization ();
}
map.ShowsUserLocation = true;
// TODO: Step 3d - specify a custom map delegate
// var mapDelegate = new MyMapDelegate();
// map.Delegate = mapDelegate;
// Add a point annotation
map.AddAnnotation(new MKPointAnnotation()
{
Title = "MyAnnotation",
Coordinate = new MonoTouch.CoreLocation.CLLocationCoordinate2D(42.364260, -71.120824)
});
// TODO: Step 3f - add a custom annotation
// map.AddAnnotation(new CustomAnnotation("CustomSpot", new MonoTouch.CoreLocation.CLLocationCoordinate2D(38.364260, -68.120824)));
// TODO: Step 3a - remove old GetViewForAnnotation delegate code to new delegate - we will recreate this next
// Customize annotation view via GetViewForAnnotation delegate
map.GetViewForAnnotation = delegate(MKMapView mapView, NSObject annotation)
{
if (annotation is MKUserLocation)
return null;
MKPinAnnotationView pinView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation(pId);
if (pinView == null)
{
pinView = new MKPinAnnotationView(annotation, pId);
pinView.PinColor = MKPinAnnotationColor.Green;
pinView.CanShowCallout = true;
// Add accessory views to the pin
pinView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
pinView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("Icon-29.png"));
}
return pinView;
};
}
示例7: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
try{
this.Title = "Ubicación de la tienda";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
//Mostramos la ubicacion del usuario.
mapView.ShowsUserLocation = true;
MKUserLocation usr = mapView.UserLocation;
usr.Title = "Tú estas aqui";
var annotation = new BasicMapAnnotation (new CLLocationCoordinate2D (Double.Parse(tienda.tienda_latitud), Double.Parse(tienda.tienda_longitud)), tienda.tienda_nombre,tienda.tienda_direccion);
mapView.AddAnnotation (annotation);
// establecemos la region a mostrar, poniendo a Chihuahua como region
var coords = new CLLocationCoordinate2D(28.6352778, -106.08888890000003); // Chihuahua
var span = new MKCoordinateSpan(MilesToLatitudeDegrees (10), MilesToLongitudeDegrees (10, coords.Latitude));
// se establece la region.
mapView.Region = new MKCoordinateRegion (coords, span);
//Mostrar los diferentes tipos de mapas
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Mapa", 0, false);
mapTypes.InsertSegment("Satelite", 1, false);
mapTypes.InsertSegment("Ambos", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
} catch(Exception e){
Console.WriteLine (e.ToString());
UIAlertView alert = new UIAlertView () {
Title = "Ups =(", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo."
};
alert.AddButton("Aceptar");
alert.Show ();
}
}
示例8: PlotResultsOnMap
//TODO : Demo 4 - Step 5 - Plot search results on map
private void PlotResultsOnMap (MKMapView mapview, List<MKMapItem> items)
{
foreach (var item in items) {
mapview.AddAnnotation (new MKPointAnnotation () {
Title = item.Name,
Subtitle = item.PhoneNumber ?? "",
Coordinate = new CLLocationCoordinate2D (item.Placemark.Location.Coordinate.Latitude, item.Placemark.Location.Coordinate.Longitude)
});
}
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
// add the map view
var map = new MKMapView(UIScreen.MainScreen.Bounds);
View.Add(map);
// change the map style
map.MapType = MKMapType.Standard;
// enable/disable interactions
// map.ZoomEnabled = false;
// map.ScrollEnabled = false;
// show user location
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
locationManager.RequestWhenInUseAuthorization();
}
map.ShowsUserLocation = true;
// TODO: Step 3d - specify a custom map delegate
var mapDelegate = new MyMapDelegate();
map.Delegate = mapDelegate;
// Add a point annotation
map.AddAnnotation(new MKPointAnnotation()
{
Title = "MyAnnotation",
Coordinate = new MonoTouch.CoreLocation.CLLocationCoordinate2D(42.364260, -71.120824)
});
// TODO: Step 3f - add a custom annotation
map.AddAnnotation(new CustomAnnotation("CustomSpot", new MonoTouch.CoreLocation.CLLocationCoordinate2D(38.364260, -68.120824)));
// TODO: Step 3a - remove old GetViewForAnnotation delegate code to new delegate - we will recreate this next
// [removed]
}
示例10: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "MapView Annotation";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
// create our location and zoom for los angeles
var coords = new CLLocationCoordinate2D(48.857, 2.351); // paris
var span = new MKCoordinateSpan(MilesToLatitudeDegrees (2), MilesToLongitudeDegrees (2, coords.Latitude));
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion (coords, span);
// assign the delegate, which handles annotation layout and clicking
mapView.Delegate = new MapDelegate();
// add a basic annotation
var annotation = new BasicMapAnnotation (new CLLocationCoordinate2D (48.857, 2.351), "Paris", "City of Light");
mapView.AddAnnotation (annotation);
#region Not related to this sample
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new RectangleF((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Road", 0, false);
mapTypes.InsertSegment("Satellite", 1, false);
mapTypes.InsertSegment("Hybrid", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
#endregion
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
try{
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
//Verificar si el dispositivo es un ipad o un iphone para cargar la tabla correspondiente a cada dispositivo
if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){
Title= "Tiendas";
tiendaCercana = new UIBarButtonItem (UIBarButtonSystemItem.Search);
tiendaCercana.Target = this;
this.NavigationItem.RightBarButtonItem = tiendaCercana;
}else {
Title = "Tiendas registradas";
//Creamos el boton para buscar la tienda mas cercana.
tiendaCercana = new UIBarButtonItem();
tiendaCercana.Style = UIBarButtonItemStyle.Plain;
tiendaCercana.Target = this;
tiendaCercana.Title = "Buscar tienda cercana";
this.NavigationItem.RightBarButtonItem = tiendaCercana;
}
//inicializacion del manejador de localizacion.
iPhoneLocationManager = new CLLocationManager ();
//Establecer la precision del manejador de localizacion.
iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
newLocation = e.Locations [e.Locations.Length - 1];
};
List<StoresService> tiendas = storesService.All ();
//mostramos los puntos rojos sobre cada una de las tiendas registradas.
foreach (StoresService tienda in tiendas) {
Console.WriteLine(tienda.nombre +" " + tienda.latitud + " "+tienda.longitud);
double distancia1 = iPhoneLocationManager.Location.DistanceFrom(new CLLocation(Double.Parse(tienda.latitud),Double.Parse(tienda.longitud)))/1000;
var annotation = new BasicMapAnnotation (new CLLocationCoordinate2D (Double.Parse(tienda.latitud), Double.Parse(tienda.longitud)), ""+tienda.nombre+" ("+Math.Round(distancia1,2)+"km)", ""+tienda.direccion);
mapView.AddAnnotation (annotation);
}
//Mostramos la ubicacion del usuario.
mapView.ShowsUserLocation = true;
MKUserLocation usr = mapView.UserLocation;
usr.Title = "Tú estas aqui";
// establecemos la region a mostrar, poniendo a Chihuahua como region
var coords = new CLLocationCoordinate2D(28.6352778, -106.08888890000003); // Chihuahua
var span = new MKCoordinateSpan(MilesToLatitudeDegrees (10), MilesToLongitudeDegrees (10, coords.Latitude));
// se establece la region.
mapView.Region = new MKCoordinateRegion (coords, span);
//Mostrar los diferentes tipos de mapas
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Mapa", 0, false);
mapTypes.InsertSegment("Satelite", 1, false);
mapTypes.InsertSegment("Ambos", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
//Añadimos el evento para buscar tienda mas cercana.
tiendaCercana.Clicked += (sender, e) => {
try{
StoresService tiendac= nearestStore(newLocation,tiendas);
double distancia = newLocation.DistanceFrom(new CLLocation(Double.Parse(tiendac.latitud),Double.Parse(tiendac.longitud)))/1000;
UIAlertView alert = new UIAlertView () {
Title = "Tu tienda mas cercana es:", Message = ""+ tiendac.nombre + "\n "+ tiendac.direccion+"\n"+"Distancia: " + Math.Round(distancia,2) +"km"
};
alert.AddButton("Aceptar");
alert.Show ();
var coords1 = new CLLocationCoordinate2D(Double.Parse(tiendac.latitud), Double.Parse(tiendac.longitud));
var span1 = new MKCoordinateSpan(MilesToLatitudeDegrees (0.2), MilesToLongitudeDegrees (0.2, coords.Latitude));
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion (coords1, span1);
}catch(Exception){
UIAlertView alert = new UIAlertView () {
Title = "Ups =(", Message = "Algo salio mal, por favor intentalo de nuevo."
};
alert.AddButton("Aceptar");
//.........这里部分代码省略.........
示例12: 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);
}
}
示例13: ViewDidLoad
public override void ViewDidLoad () {
base.ViewDidLoad ();
toolbar = new UINavigationBar(new CGRect(0,0,View.Frame.Width,toolbarHeight));
toolbar.SetItems (new UINavigationItem[]{
new UINavigationItem("Map")
}, false);
toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
toolbar.TintColor = AppDelegate.ColorNavBarTint;
Title = Constants.MapPinSubtitle; // "Fira de Barcelona";
TabBarItem.Title = "Map";
// create our location and zoom for los angeles
CLLocationCoordinate2D coords = new CLLocationCoordinate2D (Constants.MapPinLatitude, Constants.MapPinLongitude);
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees (3), MilesToLongitudeDegrees (3, coords.Latitude));
mapView = new MKMapView(new CGRect(0, toolbarHeight, View.Frame.Width, UIScreen.MainScreen.ApplicationFrame.Height - toolbarHeight ));
mapView.ShowsUserLocation = true;
mapView.Frame = new CGRect (0, 0, View.Frame.Width, View.Frame.Height);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth|UIViewAutoresizing.FlexibleHeight;
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion (coords, span);
segmentedControl = new UISegmentedControl();
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 (AppDelegate.IsPhone) {
var topOfSegement = View.Frame.Height - 120;
segmentedControl.Frame = new CGRect(20, topOfSegement, 282, 30);
//segmentedControl.Frame = new CGRect(20, 340, 282, 30);
} else {
// IsPad
var left = (View.Frame.Width / 2) - (282 / 2);
segmentedControl.Frame = new CGRect(left, View.Frame.Height - 130, 282, 30);
segmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
}
segmentedControl.ValueChanged += delegate {
if (segmentedControl.SelectedSegment == 0)
mapView.MapType = MapKit.MKMapType.Standard;
else if (segmentedControl.SelectedSegment == 1)
mapView.MapType = MapKit.MKMapType.Satellite;
else if (segmentedControl.SelectedSegment == 2)
mapView.MapType = MapKit.MKMapType.Hybrid;
};
try {
// add a basic annotation, got a bug report about these lines of code
mapView.AddAnnotation (
new BasicMapAnnotation (coords, Constants.MapPinTitle, Constants.MapPinSubtitle )
);
} catch (Exception mapex) {
ConsoleD.WriteLine ("Not sure if happens " + mapex.Message);
}
View.AddSubview(mapView);
View.AddSubview(toolbar);
View.AddSubview(segmentedControl);
}
示例14: InitializeMap
private void InitializeMap()
{
locationManager = new CLLocationManager ();
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
locationManager.RequestWhenInUseAuthorization ();
}
map = new MKMapView (UIScreen.MainScreen.Bounds);
View.Add (map);
if (CLLocationManager.LocationServicesEnabled) {
map.ShowsUserLocation = true;
}
var centersForDiseaseControlAnnotation = new MKPointAnnotation {
Coordinate = new CLLocationCoordinate2D (CDC.Latitude, CDC.Longitude),
Title = "Centers for Disease Control",
Subtitle = "Zombie Outbreak"
};
map.AddAnnotation (centersForDiseaseControlAnnotation);
Helpers.CenterOnAtlanta (map);
}
示例15: AddBusStopToMap
private void AddBusStopToMap(MKMapView map, BusStop busStop)
{
BusStopMapAnnotation annotation = new BusStopMapAnnotation(busStop);
map.AddAnnotation(annotation);
}