Example #1
0
        public MainPage(RoutePoints points)
        {
            InitializeComponent();
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(53.010281, 18.604922), Distance.FromMiles(2.0)));
            foreach (Points tmp in points.routePoints)
            {
                CustomPin pin = new CustomPin
                {
                    Type     = PinType.SavedPin,
                    Position = new Position(tmp.X, tmp.Y),
                    Label    = tmp.Name,
                    Address  = tmp.Description,
                    Name     = "Xamarin",
                    Url      = "http://xamarin.com/about/",
                    Question = "",
                    Answer   = ""
                };


                if (String.IsNullOrWhiteSpace(tmp.Name))
                {
                    pin.Label = "Name";
                }

                customMap.Pins.Add(pin);
            }
        }
        public MainPage(RoutePoints points)
        {
            InitializeComponent();
            pointsList = points.routePoints;
            Polyline polyline = new Polyline
            {
                StrokeColor = Color.Blue,
                StrokeWidth = 5
            };

            foreach (Points tmp in points.routePoints)
            {
                CustomPin pin = new CustomPin
                {
                    Type     = PinType.SavedPin,
                    Position = new Position(tmp.X, tmp.Y),
                    Label    = tmp.Name,
                    Address  = tmp.Description,
                    Name     = "Xamarin",
                    Url      = "http://xamarin.com/about/",
                    Question = "",
                    Answer   = ""
                };

                if (String.IsNullOrWhiteSpace(tmp.Name))
                {
                    pin.Label = "Name";
                }

                pin.MarkerClicked += async(s, args) =>
                {
                    args.HideInfoWindow = true;
                    string pinName = ((CustomPin)s).Label;
                    // string pytanie = ((CustomPin)s).Question;
                    string opis = ((CustomPin)s).Address;
                    // string odpowiedz = ((CustomPin)s).Answer;
                    await DisplayAlert($"{pinName}", $"{opis}", "Ok");

                    // await DisplayAlert("Quiz", $"{pytanie}", "Przejdź do odpowiedzi");
                    //await Navigation.PushAsync(new QuestionPage(new Question()));
                };

                polyline.Geopath.Add(new Position(tmp.X, tmp.Y));
                customMap.Pins.Add(pin);
            }
            customMap.MapElements.Add(polyline);

            if (points.routePoints.Count > 0)
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(points.routePoints[0].X, points.routePoints[0].Y), Distance.FromMiles(2.0)));
            }
            else
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(53.010281, 18.604922), Distance.FromMiles(2.0)));
            }
        }
Example #3
0
        private async void OnMapClicked(object sender, MapClickedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nazwaEntry.Text))
            {
                await DisplayAlert("Błąd", "Podaj nazwę punktu", "Ok");

                return;
            }
            if (customMap.Pins.Count > 10 || routePoints.Count > 10)
            {
                await DisplayAlert("Uwaga!", "Można do trasy dodać maksymalnie 10 punktów", "Ok");

                return;
            }

            CustomPin pin = new CustomPin
            {
                Type     = PinType.SavedPin,
                Position = new Position(e.Position.Latitude, e.Position.Longitude),
                Label    = nazwaEntry.Text,
                Address  = opisEntry.Text,
                Name     = "Xamarin",
                Url      = "http://xamarin.com/about/",
            };

            pin.MarkerClicked += async(s, args) =>
            {
                args.HideInfoWindow = true;
                string pinName = ((CustomPin)s).Label;
                // string pytanie = ((CustomPin)s).Question;
                string opis = ((CustomPin)s).Address;
                await DisplayAlert($"{pinName}, {e.Position.Latitude}, {e.Position.Longitude}", $"{opis}", "Anuluj");

                // string odpowiedz = ((CustomPin)s).Answer;

                /* if(await DisplayAlert($"{pinName}", $"{opis}","Quiz", "Anuluj"))
                 * {
                 *   await Navigation.PushAsync(new QuestionPage(new Question()));
                 * }*/
            };
            polyline.Geopath.Add(new Position(e.Position.Latitude, e.Position.Longitude));
            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);
            customMap.MapElements.Add(polyline);

            routePoints.Add(new Points()
            {
                X           = e.Position.Latitude,
                Y           = e.Position.Longitude,
                RouteId     = 1,
                Name        = nazwaEntry.Text,
                Description = opisEntry.Text
            });
        }
Example #4
0
        public async void OnMapClicked(object sender, MapClickedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nazwaEntry.Text))
            {
                await DisplayAlert("Błąd", "Podaj nazwę punktu", "Ok");

                return;
            }


            CustomPin pin = new CustomPin
            {
                Type     = PinType.SavedPin,
                Position = new Position(e.Position.Latitude, e.Position.Longitude),
                Label    = nazwaEntry.Text,
                Address  = opisEntry.Text,
                Name     = "Xamarin",
                Url      = "http://xamarin.com/about/",
                Question = zagadkaEntry.Text,
                Answer   = odpowiedzEntry.Text
            };

            pin.MarkerClicked += async(s, args) =>
            {
                args.HideInfoWindow = true;
                string pinName = ((CustomPin)s).Label;
                // string pytanie = ((CustomPin)s).Question;
                string opis = ((CustomPin)s).Address;
                // string odpowiedz = ((CustomPin)s).Answer;
                await DisplayAlert($"{pinName}", $"{opis}", "Quiz");

                // await DisplayAlert("Quiz", $"{pytanie}", "Przejdź do odpowiedzi");
                await Navigation.PushAsync(new QuestionPage(new Question()));
            };
            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);

            /*var json = JsonConvert.SerializeObject(new { X =  pin.Position.Latitude, Y = pin.Position.Longitude });
             * var content = new StringContent(json, Encoding.UTF8, "application/json");
             * HttpClient client = new HttpClient();
             * var result = await client.PostAsync("http://dearjean.ddns.net:44201/api/Points", content);
             * if (result.StatusCode == HttpStatusCode.Created)
             * {
             *  await DisplayAlert("Komunikat", "Dodanie puntku przebiegło pomyślnie", "Anuluj");
             * }
             */
        }
        private async void OnMapClicked(object sender, MapClickedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nazwaEntry.Text))
            {
                await DisplayAlert("Błąd", "Podaj nazwę punktu", "Ok");

                return;
            }

            CustomPin pin = new CustomPin
            {
                Type     = PinType.SavedPin,
                Position = new Position(e.Position.Latitude, e.Position.Longitude),
                Label    = nazwaEntry.Text,
                Address  = opisEntry.Text,
                Name     = "Xamarin",
                Url      = "http://xamarin.com/about/",
            };

            pin.MarkerClicked += async(s, args) =>
            {
                args.HideInfoWindow = true;
                string pinName = ((CustomPin)s).Label;
                // string pytanie = ((CustomPin)s).Question;
                string opis = ((CustomPin)s).Address;
                await DisplayAlert($"{pinName}, {e.Position.Latitude}, {e.Position.Longitude}", $"{opis}", "Anuluj");

                // string odpowiedz = ((CustomPin)s).Answer;

                /* if(await DisplayAlert($"{pinName}", $"{opis}","Quiz", "Anuluj"))
                 * {
                 *   await Navigation.PushAsync(new QuestionPage(new Question()));
                 * }*/
            };
            customMap.CustomPins = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);
            routePoints.Add(new Points()
            {
                X           = e.Position.Latitude,
                Y           = e.Position.Longitude,
                RouteId     = 1,
                Name        = nazwaEntry.Text,
                Description = opisEntry.Text
            });
            if (customMap.Pins.Count > 10 && routePoints.Count > 10)
            {
                await DisplayAlert("Uwaga!", "Można do trasy dodać maksymalnie 10 punktów", "Ok");

                customMap.Pins.Remove(pin);
            }

            /*var json = JsonConvert.SerializeObject(new Points()
             * {
             *  X = e.Position.Latitude,
             *  Y = e.Position.Longitude,
             *  RouteId = 1,
             *  Name = nazwaEntry.Text,
             *  Description = opisEntry.Text
             * });
             * var content = new StringContent(json, Encoding.UTF8, "application/json");
             * HttpClient client = new HttpClient();
             * var result = await client.PostAsync("http://dearjean.ddns.net:44301/api/Points3", content);
             * if (result.StatusCode == HttpStatusCode.Created)
             * {
             *  await DisplayAlert("Komunikat", "Dodanie puntku przebiegło pomyślnie", "Ok");
             * }
             * else
             *  await DisplayAlert("Błąd", "Spróbuj ponownie później", "Ok");*/
        }
        public MainPage(RoutePoints points)
        {
            InitializeComponent();
            double x1 = 0, x2 = 0, y1 = 0, y2 = 0;

            foreach (Points tmp in points.routePoints)
            {
                CustomPin pin = new CustomPin
                {
                    Type     = PinType.SavedPin,
                    Position = new Position(tmp.X, tmp.Y),
                    Label    = tmp.Name,
                    Address  = tmp.Description,
                    Name     = "Xamarin",
                    Url      = "http://xamarin.com/about/",
                    Question = "",
                    Answer   = ""
                };

                if (String.IsNullOrWhiteSpace(tmp.Name))
                {
                    pin.Label = "Name";
                }

                pin.MarkerClicked += async(s, args) =>
                {
                    args.HideInfoWindow = true;
                    string pinName = ((CustomPin)s).Label;
                    // string pytanie = ((CustomPin)s).Question;
                    string opis = ((CustomPin)s).Address;
                    // string odpowiedz = ((CustomPin)s).Answer;
                    await DisplayAlert($"{pinName}", $"{opis}", "Ok");

                    // await DisplayAlert("Quiz", $"{pytanie}", "Przejdź do odpowiedzi");
                    //await Navigation.PushAsync(new QuestionPage(new Question()));
                };
                customMap.Pins.Add(pin);

                if (tmp.X < x1)
                {
                    x1 = tmp.X;
                }
                if (tmp.X > x2)
                {
                    x2 = tmp.X;
                }
                if (tmp.Y < y1)
                {
                    y1 = tmp.Y;
                }
                if (tmp.Y > y2)
                {
                    y2 = tmp.Y;
                }
            }

            if (points.routePoints.Count > 1)
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position((x1 + x2) / 2, (y1 + y2) / 2), Distance.FromMiles(2.0)));
            }
            else if (points.routePoints.Count == 1)
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(x1 + x2, y1 + y2), Distance.FromMiles(2.0)));
            }
            else
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(53.010281, 18.604922), Distance.FromMiles(2.0)));
            }
        }