Exemple #1
0
        private UIElement CreateRadioButton(ISampleBase sample)
        {
            var radioButton = new RadioButton
            {
                FontSize = 16,
                Content  = sample.Name,
                Margin   = new Thickness(4)
            };

            radioButton.Click += (s, a) => {
                Catch.Exceptions(async() =>
                {
                    MapControl.Map?.Layers.Clear();

                    await sample.SetupAsync(MapControl);

                    MapControl.Info += MapControlOnInfo;
                    if (MapControl.Map != null)
                    {
                        LayerList.Initialize(MapControl.Map.Layers);
                    }
                });
            };
            return(radioButton);
        }
Exemple #2
0
        public MapPage(ISampleBase sample, Func <MapView?, MapClickedEventArgs, bool>?c = null)
        {
            InitializeComponent();
            Refs.AddRef(this);
            Refs.AddRef(mapView);

            Title = sample.Name;

            mapView.RotationLock          = false;
            mapView.UnSnapRotationDegrees = 30;
            mapView.ReSnapRotationDegrees = 5;

            mapView.PinClicked += OnPinClicked;
            mapView.MapClicked += OnMapClicked;

            Compass.ReadingChanged += Compass_ReadingChanged;

            mapView.MyLocationLayer.UpdateMyLocation(new UI.Forms.Position());
            mapView.MyLocationLayer.CalloutText = "My location!\n";
            mapView.MyLocationLayer.Clicked    += MyLocationClicked;

            mapView.Renderer.WidgetRenders[typeof(CustomWidget.CustomWidget)] = new CustomWidgetSkiaRenderer();

            _ = Task.Run(() => StartGPSAsync());

            try
            {
                if (!Compass.IsMonitoring)
                {
                    Compass.Start(SensorSpeed.Default);
                }
            }
            catch (Exception) { }

            _ = Task.Run(async() =>
            {
                try
                {
                    await sample.SetupAsync(mapView);
                }
                catch (Exception e)
                {
                    Logger.Log(LogLevel.Error, e.Message, e);
                }
            });

            Clicker = c;
        }
Exemple #3
0
        public MapPage(ISampleBase sample, Func <MapView?, MapClickedEventArgs, bool>?c = null)
        {
            InitializeComponent();

            // nullable warning workaround
            var test  = this.mapView ?? throw new InvalidOperationException();
            var test1 = this.info ?? throw new InvalidOperationException();

            mapView !.RotationLock        = false;
            mapView.UnSnapRotationDegrees = 30;
            mapView.ReSnapRotationDegrees = 5;

            mapView.PinClicked += OnPinClicked;
            mapView.MapClicked += OnMapClicked;

            Compass.ReadingChanged += Compass_ReadingChanged;

            mapView.MyLocationLayer.UpdateMyLocation(new Mapsui.UI.Maui.Position());

            mapView.Info += MapView_Info;
            mapView.Renderer.WidgetRenders[typeof(CustomWidget.CustomWidget)] = new CustomWidgetSkiaRenderer();

            _ = Task.Run(StartGPS);

            try
            {
                if (!Compass.IsMonitoring)
                {
                    Compass.Start(SensorSpeed.Default);
                }
            }
            catch (Exception) { }

            Catch.Exceptions(async() =>
            {
                await sample.SetupAsync(mapView);
            });

            Clicker = c;
        }
Exemple #4
0
        private UIElement CreateRadioButton(ISampleBase sample)
        {
            var radioButton = new RadioButton
            {
                FontSize = 16,
                Content  = sample.Name,
                Margin   = new Thickness(4)
            };

            radioButton.Click += (s, a) => {
                Catch.Exceptions(async() =>
                {
                    MapControl.Map !.Layers.Clear();
                    MapControl.Info -= MapOnInfo;
                    await sample.SetupAsync(MapControl);
                    MapControl.Info += MapOnInfo;
                    MapControl.Refresh();
                });
            };

            return(radioButton);
        }