本文整理汇总了C#中MKMapView类的典型用法代码示例。如果您正苦于以下问题:C# MKMapView类的具体用法?C# MKMapView怎么用?C# MKMapView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MKMapView类属于命名空间,在下文中一共展示了MKMapView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
{
var pin = (MKAnnotationView)mapView.DequeueReusableAnnotation("zombie");
if (pin == null)
{
pin = new MKAnnotationView(annotation, "zombie");
pin.Image = UIImage.FromFile("zombie.png");
pin.CenterOffset = new PointF(0, -30);
}
else
{
pin.Annotation = annotation;
}
var zombieAnnotation = (ZombieAnnotation) annotation;
if (zombieAnnotation.Zombie.IsMale)
{
//pin.PinColor = MKPinAnnotationColor.Purple;
}
else
{
//pin.PinColor = MKPinAnnotationColor.Red;
}
return pin;
}
开发者ID:Jake-a-Lake,项目名称:NPlus1DaysOfMvvmCross,代码行数:26,代码来源:FirstView.cs
示例2: 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();
}
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:32,代码来源:SecondView.cs
示例3: ViewDidLoad
public override void ViewDidLoad()
{
_map = new MKMapView();
foreach(BusStop busStop in _busStops)
{
AddBusStopToMap(_map, busStop);
}
AddBusStopToMap(_map, _busStops[0]);
_map.ShowsUserLocation = true;
_map.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
if(_busStops.Length <= 1)
{
_map.Region = new MKCoordinateRegion(FindCentre(_busStops), new MKCoordinateSpan(0.005, 0.0005));
}
else
{
_map.Region = RegionThatFitsAllStops(_busStops);
}
this.View.AddSubview (_map);
}
开发者ID:runegri,项目名称:MuPP,代码行数:26,代码来源:MapViewController.cs
示例4: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
Title = "MapView";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//mapView.MapType = MKMapType.Standard; // this is the default
//mapView.MapType = MKMapType.Satellite;
//mapView.MapType = MKMapType.Hybrid;
View.AddSubview(mapView);
// create our location and zoom
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(40.77, -73.98); // new york
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(33.93, -118.40); // los angeles
//CLLocationCoordinate2D coords = new CLLocationCoordinate2D(51.509, -0.1); // london
CLLocationCoordinate2D coords = new CLLocationCoordinate2D(48.857, 2.351); // paris
MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
// set the coords and zoom on the map
mapView.Region = new MKCoordinateRegion(coords, span);
}
开发者ID:eduardoguilarducci,项目名称:recipes,代码行数:25,代码来源:MapViewController.cs
示例5: GetViewForAnnotation
MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
{
MKAnnotationView annotationView = null;
if (annotation is MKUserLocation)
return null;
var anno = annotation as MKPointAnnotation;
var customPin = GetCustomPin(anno);
if (customPin == null)
{
throw new Exception("Custom pin not found");
}
annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
if (annotationView == null)
{
annotationView = new CustomMKAnnotationView(annotation, customPin.Id);
annotationView.Image = UIImage.FromFile("pin.png");
annotationView.CalloutOffset = new CGPoint(0, 0);
annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile("monkey.png"));
annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
((CustomMKAnnotationView)annotationView).Id = customPin.Id;
((CustomMKAnnotationView)annotationView).Url = customPin.Url;
}
annotationView.CanShowCallout = true;
return annotationView;
}
开发者ID:berlamont,项目名称:xamarin-forms-samples,代码行数:29,代码来源:CustomMapRenderer.cs
示例6: Initialize
private void Initialize ()
{
Title = Locale.GetText ("");
_mapView = new MKMapView ();
_mapView.AutoresizingMask = UIViewAutoresizing.All;
_mapView.MapType = MKMapType.Standard;
_mapView.ShowsUserLocation = true;
_sgMapType = new UISegmentedControl ();
_sgMapType.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
_sgMapType.Opaque = true;
_sgMapType.Alpha = 0.75f;
_sgMapType.ControlStyle = UISegmentedControlStyle.Bar;
_sgMapType.InsertSegment ("Map", 0, true);
_sgMapType.InsertSegment ("Satellite", 1, true);
_sgMapType.InsertSegment ("Hybrid", 2, true);
_sgMapType.SelectedSegment = 0;
_sgMapType.ValueChanged += (s, e) => {
switch (_sgMapType.SelectedSegment) {
case 0:
_mapView.MapType = MKMapType.Standard;
break;
case 1:
_mapView.MapType = MKMapType.Satellite;
break;
case 2:
_mapView.MapType = MKMapType.Hybrid;
break;
}
};
}
开发者ID:bpug,项目名称:LbkIos,代码行数:31,代码来源:LbkMapViewController.cs
示例7: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
{
// try and dequeue the annotation view
MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);
// if we couldn't dequeue one, create a new one
if (annotationView == null)
annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
else // if we did dequeue one for reuse, assign the annotation to it
annotationView.Annotation = annotation;
// configure our annotation view properties
annotationView.CanShowCallout = true;
(annotationView as MKPinAnnotationView).AnimatesDrop = true;
(annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Red;
annotationView.Selected = true;
Assembly ass = this.GetType ().Assembly;
var annotationImage =
UIImage.FromBundle((annotation as BasicPinAnnotation).ImageAdress);
annotationView.LeftCalloutAccessoryView = new UIImageView(
ResizeImage.MaxResizeImage(annotationImage,(float)40,(float)20));
return annotationView;
}
开发者ID:kosomgua,项目名称:MapCross,代码行数:25,代码来源:MapDelegate.cs
示例8: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
FoundCoords += (object sender, CoordEventArgs e) => {
storageScreenContent.SetCoords(e.Latitude,e.Longitude);
};
map = new MKMapView (UIScreen.MainScreen.Bounds);
View = map;
// create search controller
searchBar = new UISearchBar (new RectangleF (0, 0, View.Frame.Width, 50)) {
Placeholder = "Enter a search query"
};
searchController = new UISearchDisplayController (searchBar, this);
searchController.Delegate = new SearchDelegate (map);
SearchSource source = new SearchSource (searchController, map);
searchController.SearchResultsSource = source;
source.FoundCoords += (object sender, CoordEventArgs e) => {
var handler = FoundCoords;
if(handler != null){
handler(this,e);
}
this.DismissViewController(true,null);
};
View.AddSubview (searchBar);
}
开发者ID:KuroiAme,项目名称:Indexer,代码行数:28,代码来源:AddressLocationFinder.cs
示例9: GetViewForAnnotation
UIButton detailButton; // need class-level ref to avoid GC
/// <summary>
/// This is very much like the GetCell method on the table delegate
/// </summary>
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
{
// try and dequeue the annotation view
MKAnnotationView annotationView = mapView.DequeueReusableAnnotation(annotationIdentifier);
// if we couldn't dequeue one, create a new one
if (annotationView == null)
annotationView = new MKPinAnnotationView(annotation, annotationIdentifier);
else // if we did dequeue one for reuse, assign the annotation to it
annotationView.Annotation = annotation;
// configure our annotation view properties
annotationView.CanShowCallout = true;
(annotationView as MKPinAnnotationView).AnimatesDrop = true;
(annotationView as MKPinAnnotationView).PinColor = MKPinAnnotationColor.Green;
annotationView.Selected = true;
// you can add an accessory view, in this case, we'll add a button on the right, and an image on the left
detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);
detailButton.TouchUpInside += (s, e) => {
var c = (annotation as MKAnnotation).Coordinate;
new UIAlertView("Annotation Clicked", "You clicked on " +
c.Latitude.ToString() + ", " +
c.Longitude.ToString() , null, "OK", null).Show();
};
annotationView.RightCalloutAccessoryView = detailButton;
annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromBundle("Images/Icon/29_icon.png"));
//annotationView.Image = UIImage.FromBundle("Images/Apress-29x29.png");
return annotationView;
}
开发者ID:Adameg,项目名称:mobile-samples,代码行数:36,代码来源:AnnotatedMapScreen.xib.cs
示例10: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation)
{
var extendedAnnotation = annotation as ExtendedMapAnnotation;
if (extendedAnnotation == null) return null;
// try and dequeue the annotation view
var annotationView = mapView.DequeueReusableAnnotation(AnnotationIdentifier);
// if we couldn't dequeue one, create a new one
if (annotationView == null)
{
annotationView = new MKAnnotationView(extendedAnnotation, AnnotationIdentifier);
}
else // if we did dequeue one for reuse, assign the annotation to it
annotationView.Annotation = extendedAnnotation;
// configure our annotation view properties
annotationView.CanShowCallout = false;
annotationView.Selected = true;
if (!string.IsNullOrEmpty(extendedAnnotation.PinIcon))
{
annotationView.Image = UIImage.FromFile(extendedAnnotation.PinIcon);
}
return annotationView;
}
开发者ID:patridge,项目名称:Xamarin.Forms.Plugins,代码行数:28,代码来源:MapDelegate.cs
示例11: 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);
}
}
开发者ID:jorik041,项目名称:odata,代码行数:26,代码来源:MapController.cs
示例12: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
View = mapView;
base.ViewDidLoad();
var firstViewModel = (FourthViewModel)ViewModel;
_regionManager = new RegionManager(mapView);
var button = new UIButton(UIButtonType.RoundedRect);
button.Frame = new RectangleF(10, 10, 300, 40);
button.SetTitle("move", UIControlState.Normal);
Add(button);
var lat = new UITextField(new RectangleF(10, 50, 130, 40));
lat.KeyboardType = UIKeyboardType.DecimalPad;
Add(lat);
var lng = new UITextField(new RectangleF(160, 50, 130, 40));
lng.KeyboardType = UIKeyboardType.DecimalPad;
Add(lng);
var set = this.CreateBindingSet<FourthView, Core.ViewModels.FourthViewModel>();
set.Bind(button).To(vm => vm.UpdateCenterCommand);
set.Bind(lat).To(vm => vm.Lat);
set.Bind(lng).To(vm => vm.Lng);
set.Bind(_regionManager).For(r => r.Center).To(vm => vm.Location);
set.Apply();
}
开发者ID:Jake-a-Lake,项目名称:NPlus1DaysOfMvvmCross,代码行数:30,代码来源:FourthView.cs
示例13: CreateMapView
void CreateMapView()
{
_mapView = new MKMapView (UIScreen.MainScreen.Bounds);
_mapView.ShowsUserLocation = true;
_mapView.Delegate = new MapViewDelegate ();
View.InsertSubview (_mapView, 0);
}
开发者ID:hakonfjukstad,项目名称:Avgangsalarm,代码行数:7,代码来源:MapViewController.cs
示例14: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
{
MKAnnotationView anView;
if (annotation is MKUserLocation)
return null;
if (annotation is MonkeyAnnotation) {
// show monkey annotation
anView = mapView.DequeueReusableAnnotation (mId);
if (anView == null)
anView = new MKAnnotationView (annotation, mId);
anView.Image = UIImage.FromFile ("monkey.png");
anView.CanShowCallout = true;
anView.Draggable = true;
anView.RightCalloutAccessoryView = UIButton.FromType (UIButtonType.DetailDisclosure);
} else {
// show pin annotation
anView = (MKPinAnnotationView)mapView.DequeueReusableAnnotation (pId);
if (anView == null)
anView = new MKPinAnnotationView (annotation, pId);
((MKPinAnnotationView)anView).PinColor = MKPinAnnotationColor.Green;
anView.CanShowCallout = true;
}
return anView;
}
开发者ID:GSerjo,项目名称:Seminars,代码行数:34,代码来源:MapDemoViewController.cs
示例15: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, IMKAnnotation annotation)
{
MKAnnotationView annotationView = null;
MKPointAnnotation anno = null;
if (annotation is MKUserLocation) {
return null;
} else {
anno = annotation as MKPointAnnotation;
}
string identifier = GetIdentifier (anno);
if (identifier == "")
throw new Exception ("No Identifier found for pin");
annotationView = mapView.DequeueReusableAnnotation (identifier);
if (annotationView == null)
annotationView = new CustomMKPinAnnotationView (annotation, identifier);
//This removes the bubble that pops up with the title and everything
((CustomMKPinAnnotationView)annotationView).FormsIdentifier = identifier;
annotationView.CanShowCallout = false;
return annotationView;
}
开发者ID:biyyalakamal,项目名称:customer-success-samples,代码行数:27,代码来源:CustomMapDelegate.cs
示例16: GetViewForAnnotation
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
{
var pet = ((CustomAnnotation)annotation).Model;
var petAnnotationType = GetPetAnnotationType (pet);
var pin = (MapAnnotationView)mapView.DequeueReusableAnnotation(petAnnotationType);
string pinImage = petAnnotationType + ".png";
if (pin == null)
{
pin = new MapAnnotationView(annotation, petAnnotationType);
pin.Image = UIImage.FromBundle(pinImage);
pin.CenterOffset = new PointF (0, -15);
}
else
{
pin.Annotation = annotation;
}
pin.Draggable = _pinIsDraggable;
pin.CanShowCallout = _canShowCallout;
if (_canShowCallout)
{
Task.Run( async () => pin.LeftCalloutAccessoryView = await GetImage(pet));
pin.RightCalloutAccessoryView = GetDetailButton (pet);
}
return pin;
}
开发者ID:sgraphics,项目名称:BindableMapTest,代码行数:28,代码来源:MonkeyMapDelegate.cs
示例17: 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;
};
}
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:60,代码来源:MappingAppViewController.cs
示例18: 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();
}
开发者ID:Jake-a-Lake,项目名称:NPlus1DaysOfMvvmCross,代码行数:31,代码来源:FirstView.cs
示例19: ViewDidLoad
public override void ViewDidLoad()
{
var mapView = new MKMapView();
View = mapView;
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var regionManager = new RegionManager(mapView);
mapView.Delegate = regionManager;
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<FifthView, Core.ViewModels.FifthViewModel>();
set.Bind(regionManager).For(r => r.TheLocation).To(vm => vm.Location);
set.Bind(button).For("Title").To(vm => vm.Location);
set.Apply();
}
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:25,代码来源:FifthView.cs
示例20: ViewDidLoad
public override void ViewDidLoad()
{
mapView = new MKMapView();
RectangleF frame = new RectangleF(0,0,320,360);
mapView.Frame = frame;
mapView.ShowsUserLocation = true;
var myAnnotation = new MyAnnotation(new CLLocationCoordinate2D(0,0), "Home", "is where the heart is");
mapView.AddAnnotationObject(myAnnotation);
UIButton detailButton = UIButton.FromType(UIButtonType.DetailDisclosure);
mapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) {
var anv = mapView.DequeueReusableAnnotation("thislocation");
if (anv == null)
{
anv = new MKPinAnnotationView(annotation, "thislocation");
detailButton.TouchUpInside += (s, e) => {
Console.WriteLine ("Tapped");
};
anv.RightCalloutAccessoryView = detailButton;
}
else
{
anv.Annotation = annotation;
}
anv.CanShowCallout = true;
return anv;
};
View.AddSubview(mapView);
}
开发者ID:amnextking,项目名称:monotouch-bindings,代码行数:35,代码来源:TweetViewController.cs
注:本文中的MKMapView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论