private void UpdateAnnotation() { IMKOverlay[] overlays = MapView.Overlays; if (overlays != null) { MapView.RemoveOverlays(MapView.Overlays); } IMKAnnotation[] mKAnnotation = MapView.Annotations; if (mKAnnotation != null) { MapView.RemoveAnnotations(mKAnnotation); } //Access database, will create table if needed DatabaseManagement.BuildAllTables(); Data[] traces = DatabaseManagement.GetAllTraces(); //Add Overlay to map foreach (var i in traces) { MapView.AddOverlay(MKPolyline.FromCoordinates(i.locs.ToArray())); } annotationData[] annotations = DatabaseManagement.GetAllAnnotations(); //Add Overlay to map foreach (var j in annotations) { MapView.AddAnnotations(new TraceAnnotation(j)); } }
private void ShotDetected(CLLocationCoordinate2D coordinate2D) { //Creates a map annotation on the paramater location MapView.AddAnnotations(new ShotsAnnotation("Shots Detected", coordinate2D)); if (debugPrint) { Console.WriteLine("Shots Fired Annotation, Detected"); } }
private void ShotDetected() { //Creates a map annotation on the users current location MapView.AddAnnotations(new ShotsAnnotation("Shots Fired", new CLLocationCoordinate2D(locationManager.Location.Coordinate.Latitude, locationManager.Location.Coordinate.Longitude))); if (debugPrint) { Console.WriteLine("Shots Fired Annotation"); } }
void SetUpAnnotations() { var annotations = viewModel.Places.Select(p => new MKPointAnnotation { Coordinate = new CLLocationCoordinate2D(p.Geometry.Location.Latitude, p.Geometry.Location.Longitude), Title = p.Name }).ToArray(); MapView.AddAnnotations(annotations); MapView.ShowAnnotations(annotations, false); }
private void LoadDataForMapRegionAndBikes() { var plist = NSDictionary.FromFile(NSBundle.MainBundle.PathForResource("Data", "plist")); var region = plist["region"] as NSArray; if (region != null) { var coordinate = new CLLocationCoordinate2D(region.GetItem <NSNumber>(0).NFloatValue, region.GetItem <NSNumber>(1).NFloatValue); var span = new MKCoordinateSpan(region.GetItem <NSNumber>(2).NFloatValue, region.GetItem <NSNumber>(3).NFloatValue); MapView.Region = new MKCoordinateRegion(coordinate, span); } var bikes = plist["bikes"] as NSArray; if (bikes != null) { MapView.AddAnnotations(Bike.FromDictionaryArray(bikes)); } }
public async override void ViewDidLoad() { MobileService = new MobileServiceClient("https://some.azurewebsites.net"); AdressesTable = MobileService.GetTable <Adresses>(); try { await InitList(); cLLocationManager = new CLLocationManager(); cLLocationManager.RequestWhenInUseAuthorization(); MapView.Delegate = new MapViewDelegeate(); MapView.AddAnnotations(annots.ToArray()); } catch { PresentViewController(GetAlertsClass.GetAlert("Проблемы с геолокацией"), true, null); } }
protected override void OnDataContextChanged(object previousContext, object newContext) { var previousAnnotations = MapView.Annotations.Where(a => !(a is MKUserLocation)).ToArray(); var isFirstLoading = previousAnnotations.Length == 0; MapView.RemoveAnnotations(previousAnnotations); if (DataContext != null && DataContext.HasAddresses()) { var annotations = DataContext.Addresses .Select(a => new MapViewAnnotation( DataContext.Name.GetAbbreviation(2), DataContext.Name, a)) .ToArray(); var coordinates = MapUtil.GetAnnotationsCoordinates(annotations); if (coordinates.Length > 0) { MapView.SetRegion( MapUtil.CoordinateRegionForCoordinates( coordinates, new MKMapSize(3000, 3000)), !isFirstLoading); MapView.SetCenterCoordinate( new CLLocationCoordinate2D( annotations[0].Coordinate.Latitude + 0.00047, // moving a bit down to compensate callout height annotations[0].Coordinate.Longitude), !isFirstLoading); MapView.AddAnnotations(annotations); } AddressLabel.Text = DataContext.GetAddressText(); } else { AddressLabel.Text = null; } SetNeedsUpdateConstraints(); }
private void SetupMKMapView(double zoomLatitude, double zoomLongitude, double maxminLatitude, double maxminLongitude) { LocationButton.TouchUpInside += (sender, e) => { var userRegion = new MKCoordinateRegion(MapView.UserLocation.Coordinate, new MKCoordinateSpan(0.2, 0.2)); MapView.SetRegion(userRegion, true); }; foreach (var item in Coordinates) { MapView.AddAnnotations(new MKPointAnnotation() { Coordinate = item }); } MapView.SetRegion(new MKCoordinateRegion( new CLLocationCoordinate2D(zoomLatitude, zoomLongitude), new MKCoordinateSpan(maxminLatitude * 2, maxminLongitude * 2)), true); }