コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            Console.WriteLine($"documents : {document_root}");
            Console.WriteLine($"library   : {library_root}");
            Console.WriteLine("");
            Console.WriteLine("");

            NavigationItem.Title = "MapKit Sample";

            //Init Map
            map_view = new MKMapView {
                MapType           = MKMapType.Standard,
                ShowsUserLocation = true,
                ZoomEnabled       = true,
                ScrollEnabled     = true,
                ShowsBuildings    = true,
                PitchEnabled      = true,
            };

            this.SetToolbarItems(new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Camera, (s, e) => {
                    using (var snapShotOptions = new MKMapSnapshotOptions())
                    {
                        snapShotOptions.Region = map_view.Region;
                        snapShotOptions.Scale  = UIScreen.MainScreen.Scale;
                        snapShotOptions.Size   = map_view.Frame.Size;

                        using (var snapShot = new MKMapSnapshotter(snapShotOptions))
                        {
                            snapShot.Start((snapshot, error) =>
                            {
                                if (error == null)
                                {
                                    Task.Run(async() => {
                                        var allowed = await GetAlbumPermission();
                                        if (allowed)
                                        {
                                            snapshot.Image.SaveToPhotosAlbum(
                                                (uiimage, imgError) =>
                                            {
                                                if (imgError == null)
                                                {
                                                    DisplayAlert("Image Saved", "Map View Image Saved!");
                                                }
                                            });
                                        }
                                    });
                                }
                            });
                        }
                    }
                }),
                new UIBarButtonItem(UIBarButtonSystemItem.Organize, (sender, e) => {
                    CreateRoute();
                }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null),
                new UIBarButtonItem(UIBarButtonSystemItem.Rewind, (sender, e) => {
                    InitialZoomDelta += 0.1;
                    InitialZoomSpan   = new MKCoordinateSpan(InitialZoomDelta, InitialZoomDelta);
                    var newRegion     = new MKCoordinateRegion(orignPlaceMark.Coordinate, InitialZoomSpan);
                    map_view.SetRegion(newRegion, true);
                }),
                new UIBarButtonItem(UIBarButtonSystemItem.FastForward, (sender, e) => {
                    InitialZoomDelta -= 0.1;
                    InitialZoomSpan   = new MKCoordinateSpan(InitialZoomDelta, InitialZoomDelta);
                    var newRegion     = new MKCoordinateRegion(orignPlaceMark.Coordinate, InitialZoomSpan);
                    map_view.SetRegion(newRegion, true);
                }),
            }, false);

            this.NavigationController.ToolbarHidden = false;

            //Create new MapDelegate Instance
            _mapDelegate = new MapDelegate();

            //Add delegate to map
            map_view.Delegate = _mapDelegate;

            View = map_view;

            //Create Directions
            CreateRoute();

            Task.Run(async() => {
                await Task.Delay(3000);

                GeocodeToConsoleAsync("6 Forest Knoll Castle Hill 2154");
                GeocodeToConsoleAsync("19A Cook Street Baulkham Hills 2153");
                GeocodeToConsoleAsync("10 Century Circuit Baulkham Hills 2153");
                GeocodeToConsoleAsync("212/10 Century Circuit Baulkham Hills 2153");
                GeocodeToConsoleAsync("6 Forest Knoll Castle Hill 2154");
                GeocodeToConsoleAsync("1 THE PLACE PENRITH 2750");
                GeocodeToConsoleAsync("103/5 CELEBRATION DRIVE BELLA VISTA 2153");
                GeocodeToConsoleAsync("123 BOB ROAD BOBS FARM 2316");
                GeocodeToConsoleAsync("123 The Road PENRITH 2750");
                GeocodeToConsoleAsync("16A HILL ST BLAYNEY 2799");
                GeocodeToConsoleAsync("3 Packard Ave CASTLE HILL 2154");
                GeocodeToConsoleAsync("42 harris street BECKENHAM 6107");
            });
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.Title = "MapKit Sample";

            //Init Map
            _map = new MKMapView
            {
                MapType = MKMapType.Standard,
                ShowsUserLocation = true,
                ZoomEnabled = true,
                ScrollEnabled = true,
                ShowsBuildings = true,
                PitchEnabled = true,

            };

            this.SetToolbarItems(new UIBarButtonItem[] {
    new UIBarButtonItem(UIBarButtonSystemItem.Camera, (s,e) => {
                                                                   
      using (var snapShotOptions = new MKMapSnapshotOptions())
      {
          snapShotOptions.Region = _map.Region;
          snapShotOptions.Scale = UIScreen.MainScreen.Scale;
          snapShotOptions.Size = _map.Frame.Size;
          
          using (var snapShot = new MKMapSnapshotter(snapShotOptions))
          {
              snapShot.Start((snapshot, error) =>
              {
                  if (error == null)
                  {
                      snapshot.Image.SaveToPhotosAlbum(
                          (uiimage, imgError) =>
                              {
                                  if (imgError == null)
                                  {
                                      new UIAlertView("Image Saved", "Map View Image Saved!", null, "OK", null).Show();
                                  }

                               });
                   }
               });
           }
       }
    })
}, false);

            this.NavigationController.ToolbarHidden = false;





            //Create new MapDelegate Instance
            _mapDelegate = new MapDelegate();

            //Add delegate to map
            _map.Delegate = _mapDelegate;

            View = _map;

            //Create Directions
            CreateRoute();
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.Title = "MapKit Sample";

            //Init Map
            _map = new MKMapView
            {
                MapType           = MKMapType.Standard,
                ShowsUserLocation = true,
                ZoomEnabled       = true,
                ScrollEnabled     = true,
                ShowsBuildings    = true,
                PitchEnabled      = true,
            };

            this.SetToolbarItems(new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Camera, (s, e) => {
                    using (var snapShotOptions = new MKMapSnapshotOptions())
                    {
                        snapShotOptions.Region = _map.Region;
                        snapShotOptions.Scale  = UIScreen.MainScreen.Scale;
                        snapShotOptions.Size   = _map.Frame.Size;

                        using (var snapShot = new MKMapSnapshotter(snapShotOptions))
                        {
                            snapShot.Start((snapshot, error) =>
                            {
                                if (error == null)
                                {
                                    snapshot.Image.SaveToPhotosAlbum(
                                        (uiimage, imgError) =>
                                    {
                                        if (imgError == null)
                                        {
                                            new UIAlertView("Image Saved", "Map View Image Saved!", null, "OK", null).Show();
                                        }
                                    });
                                }
                            });
                        }
                    }
                })
            }, false);

            this.NavigationController.ToolbarHidden = false;



            //Create new MapDelegate Instance
            _mapDelegate = new MapDelegate();

            //Add delegate to map
            _map.Delegate = _mapDelegate;

            View = _map;

            //Create Directions
            CreateRoute();
        }