Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            locationManager.RequestWhenInUseAuthorization();
            View.UserInteractionEnabled = true;
            LocationContainer.Hidden    = locsHide;

            // Create Map
            mapDel       = new MyMapDelegate();
            map.Delegate = mapDel;

            map.MapType           = MKMapType.Standard;
            map.ShowsUserLocation = true;

            View = map;
            View.AddSubview(SearchView);
            View.AddSubview(LocationContainer);


            // set map center and region
            const double lat       = 43.161030;
            const double lon       = -77.610924;
            var          mapCenter = new CLLocationCoordinate2D(lat, lon);
            var          mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 20000, 20000);

            map.CenterCoordinate = mapCenter;
            map.Region           = mapRegion;


            //Create Serach Bar
            searchResultsController = new SearchResultsViewController(map);
            var searchUpdater = new SearchResultsUpdator();

            searchUpdater.UpdateSearchResults += searchResultsController.Search;

            //add the search controller
            searchController = new UISearchController(searchResultsController)
            {
                SearchResultsUpdater = searchUpdater
            };


            SearchView.AddSubview(searchController.SearchBar);
            SearchView.BackgroundColor = new UIColor(255, 255, 255, (System.nfloat) .20);

            searchController.SearchBar.SizeToFit();
            searchController.SearchBar.SearchBarStyle = UISearchBarStyle.Minimal;
            searchController.SearchBar.Placeholder    = "Find Locations You Want To Save";

            searchController.HidesNavigationBarDuringPresentation = false;


            DefinesPresentationContext = true;
        }