public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new CoffeesViewModel(); MyButtonLoadData.TouchUpInside += async(sender, args) => { MyButtonLoadData.Enabled = false; MyMap.RemoveAnnotations(MyMap.Annotations); var coffees = await viewModel.GetCoffees(); foreach (var coffee in coffees) { MyMap.AddAnnotation(new MKPointAnnotation { Coordinate = new CLLocationCoordinate2D(coffee.Latitude, coffee.Longitude), Title = coffee.Name }); } MyButtonLoadData.Enabled = true; }; ZoomToSeattle(); }
async partial void MyButtonPin_TouchUpInside(UIButton sender) { var center = MyMap.Region.Center; var title = await viewModel.GetNameForLocation(center.Latitude, center.Longitude); MyMap.AddAnnotation(new MKPointAnnotation { Coordinate = center, Title = title }); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); var coords = new CoreLocation.CLLocationCoordinate2D(Latitude, Longitude); SetMapToCoordinate(coords); Title = PinTitle; var pin = new BasicPinAnnotation(coords, PinTitle, PinSubtitle); MyMap.AddAnnotation(pin); }
public override void ViewDidLoad() { base.ViewDidLoad(); try { var latitude = ViewModel.Latitude; var longitude = ViewModel.Longitude; var coords = new CLLocationCoordinate2D(latitude ?? 0, longitude ?? 0); SetMapToCoordinate(coords); Title = ViewModel.Title; var pin = new BasicPinAnnotation(coords, ViewModel.Title, ViewModel.Subtitle); MyMap.AddAnnotation(pin); } catch (Exception) { } }
public override void ViewDidLoad() { base.ViewDidLoad(); var vm = NavigationParameter as CoffeeMapViewModel; if (vm == null) { return; } Record record = vm.Record; if (record == null) { return; } if (record.geometry == null || record.geometry.coordinates == null) { return; } try { var recordCoordinates = record.geometry.coordinates; var latitude = recordCoordinates[1]; var longitude = recordCoordinates[0]; var coords = new CLLocationCoordinate2D(latitude, longitude); SetMapToCoordinate(coords); Title = record.fields.nom_du_cafe; var pin = new BasicPinAnnotation(coords, record.fields.nom_du_cafe, record.fields.adresse); MyMap.AddAnnotation(pin); } catch (Exception) { } }