public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. //change map type and show user location //mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; mapView.ShowsUserLocation = true; //set map center and region double lat = 45.8149; double lon = 15.9785; var mapCenter = new CLLocationCoordinate2D (lat,lon); var mapRegion = MKCoordinateRegion.FromDistance (mapCenter, 2000, 2000); mapView.CenterCoordinate = mapCenter; mapView.Region = mapRegion; //set the map delegate -> callback //mapView will call this when something needs to be done (extras ...) MapViewDelegate mvd = new MapViewDelegate(); mapView.Delegate = mvd; //It's important that the map delegate is created before annotations!! //add an annotation MKPointAnnotation -> basic class mapView.AddAnnotation (new MKPointAnnotation (){Title="MyAnnotation",Coordinate = new CLLocationCoordinate2D(45.8100,15.9760)}); //add an annotation MyCustomAnnotation -> custom class mapView.AddAnnotation (new MyCustomAnnotation("HolisticWare","www.holisticware.com",new CLLocationCoordinate2D(45.8090,15.9710))); //add an overlay var circleOverlay = MKCircle.Circle (mapCenter, 1000); mapView.AddOverlay (circleOverlay); }
public override void ViewDidLoad() { base.ViewDidLoad(); locationManager.RequestWhenInUseAuthorization(); // set map center and region const double lat = 42.374260; const double lon = -71.120824; var mapCenter = new CLLocationCoordinate2D(lat, lon); var mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 2000, 2000); map.CenterCoordinate = mapCenter; map.Region = mapRegion; // add an annotation map.AddAnnotation(new MKPointAnnotation { Title = "MyAnnotation", Coordinate = new CLLocationCoordinate2D(42.364260, -71.120824) }); // set the map delegate mapViewDelegate = new MapViewDelegate(); map.Delegate = mapViewDelegate; // add a custom annotation map.AddAnnotation(new MonkeyAnnotation("Xamarin", mapCenter)); // add an overlay map.AddOverlay(MKCircle.Circle(mapCenter, 1000)); // add search var searchResultsController = new SearchResultsViewController(map); var searchUpdater = new SearchResultsUpdator(); searchUpdater.UpdateSearchResults += searchResultsController.UpdateSearchResults; // add the search controller searchController = new UISearchController(searchResultsController); searchController.SearchResultsUpdater = searchUpdater; searchController.SearchBar.SizeToFit(); searchController.SearchBar.SearchBarStyle = UISearchBarStyle.Minimal; searchController.SearchBar.Placeholder = "Enter a search query"; searchController.HidesNavigationBarDuringPresentation = false; NavigationItem.TitleView = searchController.SearchBar; DefinesPresentationContext = true; //adresse in koordinaten umwandeln getCoordinates("Chennai International Airport"); mapCenter = newLocation; map.CenterCoordinate = mapCenter; getAdress(); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (searchController != null) { searchController.Dispose(); searchController = null; } if (mapViewDelegate != null) { mapViewDelegate.Dispose(); mapViewDelegate = null; } if (locationManager != null) { locationManager.Dispose(); } }