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

            locationManager.RequestWhenInUseAuthorization();

            // set map type and show user location
            map.MapType           = MKMapType.Standard;
            map.ShowsUserLocation = true;

            map.Bounds = View.Bounds;

            // 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
            mapDel       = new MyMapDelegate();
            map.Delegate = mapDel;

            // add a custom annotation
            map.AddAnnotation(new MonkeyAnnotation("Xamarin", mapCenter));

            // add an overlay
            var circleOverlay = MKCircle.Circle(mapCenter, 1000);

            map.AddOverlay(circleOverlay);

            var searchResultsController = new SearchResultsViewController(map);


            var searchUpdater = new SearchResultsUpdator();

            searchUpdater.UpdateSearchResults += searchResultsController.Search;

            //add the search controller
            searchController = new UISearchController(searchResultsController)
            {
                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;
        }
        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();
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			locationManager.RequestWhenInUseAuthorization ();

			// set map type and show user location
			map.MapType = MKMapType.Standard;
			map.ShowsUserLocation = true;
			map.Bounds = View.Bounds;

			// 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
			mapDel = new MyMapDelegate ();
			map.Delegate = mapDel;

			// add a custom annotation
			map.AddAnnotation (new MonkeyAnnotation ("Xamarin", mapCenter));

			// add an overlay
			var circleOverlay = MKCircle.Circle (mapCenter, 1000);
			map.AddOverlay (circleOverlay);

			var searchResultsController = new SearchResultsViewController (map);


			var searchUpdater = new SearchResultsUpdator ();
			searchUpdater.UpdateSearchResults += searchResultsController.Search;

			//add the search controller
			searchController = new UISearchController (searchResultsController) {
				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;
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            locationManager.RequestWhenInUseAuthorization();

            // set map type and show user location
            map.MapType           = MKMapType.Standard;
            map.ShowsUserLocation = true;
            map.Bounds            = View.Bounds;

            // set map center and region
            double lat       = 31.739444;
            double lon       = -106.48694;
            var    mapCenter = new CLLocationCoordinate2D(lat, lon);
            var    mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 3000, 3000);

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

            // add an annotation
            var actualAnnotation = new MKPointAnnotation();

            actualAnnotation.Title      = "Ubicacion Actual";
            actualAnnotation.Coordinate = new CLLocationCoordinate2D(lat, lon);
            map.AddAnnotation(actualAnnotation);

            // set the map delegate
            mapDel       = new MyMapDelegate();
            map.Delegate = mapDel;


            // add an overlay
            var circleOverlay = MKCircle.Circle(mapCenter, 200);

            map.AddOverlay(circleOverlay);

            // Safe Zone
            var mapSafe        = new CLLocationCoordinate2D(31.75, -106.5);
            var safeOverlay_01 = MKCircle.Circle(mapSafe, 20);

            map.AddOverlay(safeOverlay_01);
            //map.AddAnnotation(new MonkeyAnnotation("Xamarin", mapCenter));
            var punto = new MKPointAnnotation();

            punto.Title      = "Startbucks";
            punto.Coordinate = new CLLocationCoordinate2D(31.75, -106.5);
            map.AddAnnotation(punto);

            // Danger Zone
            var mapDanger        = new CLLocationCoordinate2D(31.7526, -106.5053);
            var dangerOverlay_01 = MKCircle.Circle(mapDanger, 400);

            map.AddOverlay(dangerOverlay_01);


            // Busqueda
            var searchResultsController = new SearchResultsViewController(map);

            var searchUpdater = new SearchResultsUpdator();

            searchUpdater.UpdateSearchResults += searchResultsController.Search;

            //add the search controller
            searchController = new UISearchController(searchResultsController)
            {
                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;

            /* Button Actions */
            upButton.TouchUpInside += (object sender, EventArgs e) => {
                map.RemoveAnnotation(actualAnnotation);
                map.RemoveOverlay(circleOverlay);

                lat = lat + 0.0005;
                actualAnnotation.Title      = "Ubicacion Actual";
                actualAnnotation.Coordinate = new CLLocationCoordinate2D(lat, lon);
                map.AddAnnotation(actualAnnotation);

                mapCenter     = new CLLocationCoordinate2D(lat, lon);
                circleOverlay = MKCircle.Circle(mapCenter, 200);
                map.AddOverlay(circleOverlay);

                check(lon, lat);
            };

            leftButton.TouchUpInside += (object sender, EventArgs e) => {
                map.RemoveAnnotation(actualAnnotation);
                map.RemoveOverlay(circleOverlay);

                lon = lon - 0.0005;
                actualAnnotation.Title      = "Ubicacion Actual";
                actualAnnotation.Coordinate = new CLLocationCoordinate2D(lat, lon);
                map.AddAnnotation(actualAnnotation);

                mapCenter     = new CLLocationCoordinate2D(lat, lon);
                circleOverlay = MKCircle.Circle(mapCenter, 200);
                map.AddOverlay(circleOverlay);

                check(lon, lat);
            };

            rightButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                map.RemoveAnnotation(actualAnnotation);
                map.RemoveOverlay(circleOverlay);

                lon = lon + 0.0005;
                actualAnnotation.Title      = "Ubicacion Actual";
                actualAnnotation.Coordinate = new CLLocationCoordinate2D(lat, lon);
                map.AddAnnotation(actualAnnotation);

                mapCenter     = new CLLocationCoordinate2D(lat, lon);
                circleOverlay = MKCircle.Circle(mapCenter, 200);
                map.AddOverlay(circleOverlay);

                check(lon, lat);
            };

            downButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                map.RemoveAnnotation(actualAnnotation);
                map.RemoveOverlay(circleOverlay);

                lat = lat - 0.0005;
                actualAnnotation.Title      = "Ubicacion Actual";
                actualAnnotation.Coordinate = new CLLocationCoordinate2D(lat, lon);
                map.AddAnnotation(actualAnnotation);

                mapCenter     = new CLLocationCoordinate2D(lat, lon);
                circleOverlay = MKCircle.Circle(mapCenter, 200);
                map.AddOverlay(circleOverlay);

                check(lon, lat);
            };
        }