public async void OnAppearing()
        {
            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromMeters(10000000)));
            Location loc = await Geolocation.GetLocationAsync();

            Services.RestService connection = new Services.RestService();
            (List <Stop> stops, int statuscode1) = await connection.GetPublishedStops(guide_id);

            (Guide g, int statuscode2) = await connection.GetPublishedGuide(guide_id);

            if (statuscode1 == 200 && statuscode2 == 200)
            {
                Map.Pins.Clear();
                bool first = true;
                foreach (Stop stop in stops)
                {
                    if (first)
                    {
                        Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(stop.latitude, stop.longitude), Distance.FromMeters(5000)));
                        first = false;
                    }
                    Pin location = new Pin()
                    {
                        Type     = PinType.Place,
                        Label    = stop.title,
                        Address  = stop.description,
                        Position = new Position(stop.latitude, stop.longitude),
                    };
                    Map.Pins.Add(location);
                }
            }
        }
        public async void OnAppearing()
        {
            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromMeters(10000000)));
            Location loc = await Geolocation.GetLocationAsync();

            Map.CustomPins.Clear();
            Map.Pins.Clear();

            Services.RestService connection = new Services.RestService();
            (List <Guide> guides, int statuscode) = await connection.GetPublishedGuides();

            if (statuscode == 200)
            {
                //Map.CustomPins = new List<CustomPin>();
                foreach (Guide guide in guides)
                {
                    CustomPin location = new CustomPin
                    {
                        Type     = PinType.Place,
                        Position = new Position(guide.latitude, guide.longitude),
                        Label    = guide.title,                            //Titulo label
                        Address  = guide.creator_username,                 //Persona snippet
                        Name     = Math.Round(guide.rating, 1).ToString(), //Rating
                        Url      = guide._id
                    };
                    Map.CustomPins.Add(location);
                    Map.Pins.Add(location);
                }
            }
            await Task.Delay(2000);

            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(loc.Latitude, loc.Longitude), Distance.FromMeters(1500000)));
        }
Example #3
0
        private async void LoginActionAsync(object x)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                using (var res = new Services.RestService())
                {
                    this.Email    = "*****@*****.**";
                    this.Password = "******";
                    token         = await res.GenerateTokenAsync(this.Email, Password);

                    if (token != null)
                    {
                        var main = new Views.MainMenu(token);
                        Helpers.Main.Token = token;
                        ((App)App.Current).ChangeScreen(main);
                    }
                    else
                    {
                        MessagingCenter.Send(new MessagingCenterAlert
                        {
                            Title   = "Error",
                            Message = "Gagal Login",
                            Cancel  = "OK"
                        }, "message");
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                MessagingCenter.Send(new MessagingCenterAlert
                {
                    Title   = "Error",
                    Message = ex.Message,
                    Cancel  = "OK"
                }, "message");
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async void OnAppearing()
        {
            Location loc = await Geolocation.GetLocationAsync();

            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(loc.Latitude, loc.Longitude), Distance.FromMeters(5000)));
            Services.RestService connection = new Services.RestService();
            (List <Stop> stops, int statuscode) = await connection.GetDraftStops(App.User_id);

            if (statuscode == 200)
            {
                Map.Pins.Clear();
                foreach (Stop stop in stops)
                {
                    Pin location = new Pin()
                    {
                        Type     = PinType.Place,
                        Label    = stop.title,
                        Address  = stop.description,
                        Position = new Position(stop.latitude, stop.longitude),
                    };
                    Map.Pins.Add(location);
                }
            }
        }