Пример #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);
            }
        }
Пример #2
0
        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)));
            }
        }
        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)));
            }
        }