Exemple #1
0
        async Task GetCurrent()
        {
            geoCoder = new Geocoder();
            var position = await CrossGeolocator.Current.GetPositionAsync();

            var currentPosition = new Position(position.Latitude, position.Longitude);
            var Addresses       = await geoCoder.GetAddressesForPositionAsync(currentPosition);

            MapCurrent.IsVisible = false;
            myMap.IsVisible      = true;
            myMap.MoveToRegion(MapSpan.FromCenterAndRadius(currentPosition, Distance.FromKilometers(7)));
            string fulladdress = "";

            foreach (var address in Addresses)
            {
                fulladdress += address;
            }
            var currentcode = await po.GetbyPostcodeAsync(fulladdress);

            List <Library> library = await lib.GetbyPostcodeAsync(3168);

            //test.Text = "We display the top " + library.Count.ToString() + " most close Library of your current position";

            testLogin.IsEnabled     = false;
            testLogin.IsVisible     = false;
            testNoneLogin.IsEnabled = true;
            testNoneLogin.IsVisible = true;

            for (int i = 0; i < library.Count; i++)
            {
                var pin = new CustomPin
                {
                    Pin = new Pin
                    {
                        Type     = PinType.Place,
                        Position = new Position(Double.Parse(library[i].Lat), Double.Parse(library[i].Lon)),
                        Label    = library[i].Name,
                        Address  = library[i].Address
                    }
                };
                myMap.CustomPins = new List <CustomPin> {
                    pin
                };
                myMap.Pins.Add(pin.Pin);
                pin.Pin.Clicked += async(object sender, EventArgs e) =>
                {
                    var p1 = sender as Pin;
                    await SetMap(p1.Address);
                };
            }
            var myPin = new Pin
            {
                Type     = PinType.Generic,
                Position = currentPosition,
                Label    = "Current Location",
                Address  = fulladdress
            };

            myMap.Pins.Add(myPin);
        }
Exemple #2
0
        async void Handle_ClickedAsync(object sender, System.EventArgs e)
        {
            indicator.IsVisible = true;
            List <Job> job1;

            inner.Children.Clear();
            if (post.Text.ValidPost())
            {
                job1 = await jo.GetNameAsync(post.Text);


                if (job1.Count > 0)
                {
                    Label label2 = new Label {
                        Text = "You can contact the following organizations that are close to your location:"
                    };
                    inner.Children.Add(label2);
                    for (int i = 0; i < job1.Count; i++)
                    {
                        Button button1 = new Button
                        {
                            Text = job1[i].Name,
                            HorizontalOptions = LayoutOptions.Start
                        };
                        button1.Clicked += Handle2_ClickedAsync;
                        inner.Children.Add(button1);
                    }
                }
                else
                {
                    Label label2 = new Label
                    {
                        Text = "There is no provider near you. We have suggested some places near the city center below:"
                    };


                    CustomMap customMap = new CustomMap
                    {
                        MapType       = MapType.Street,
                        WidthRequest  = 200,
                        HeightRequest = 400
                    };

                    List <Job2> job2 = await jo2.GetAllAsync();

                    for (int i = 0; i < job2.Count; i++)
                    {
                        var pins = new CustomPin
                        {
                            Pin = new Pin
                            {
                                Type     = PinType.Place,
                                Position = new Position(Double.Parse(job2[i].Lat), Double.Parse(job2[i].Lon)),
                                Label    = job2[i].Name,
                                Address  = job2[i].Address
                            },
                            postcode = job2[i].Postcode
                        };

                        customMap.CustomPins = new List <CustomPin> {
                            pins
                        };
                        customMap.Pins.Add(pins.Pin);
                        pins.Pin.Clicked += async(object sender2, EventArgs e2) =>
                        {
                            var p1 = sender2 as Pin;

                            await Navigation.PushAsync(new JobMap(pins.postcode, p1.Label));
                        };
                    }
                    customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-37.814, 144.96332), Distance.FromKilometers(5)));
                    inner.Children.Add(label2);
                    inner.Children.Add(customMap);
                }
            }
            else
            {
                Label label2 = new Label
                {
                    Text      = "Please enter a valid Victoria postcode(e.g.3000)",
                    FontSize  = 12,
                    TextColor = Color.Red
                };
                inner.Children.Add(label2);
            }
            indicator.IsVisible = false;
        }