Ejemplo n.º 1
0
        async Task Handle_Clicked(object sender, System.EventArgs e)
        {
            geoCoder = new Geocoder();
            var position = await CrossGeolocator.Current.GetPositionAsync();

            var currentPosition = new Position(position.Latitude, position.Longitude);

            if (Application.Current.Properties.ContainsKey("Postcode"))
            {
                MapCurrent.IsVisible = true;
                myMap.IsVisible      = false;
                MapCurrent.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-37.814, 144.96332), Distance.FromKilometers(10)));
            }
            else
            {
                MapCurrent.IsVisible = false;
                myMap.IsVisible      = true;
                myMap.MoveToRegion(MapSpan.FromCenterAndRadius(currentPosition, Distance.FromKilometers(7)));
            }
        }
Ejemplo n.º 2
0
        async Task GetPostcode()
        {
            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 = true;
            myMap.IsVisible      = false;

            string fulladdress = "";

            foreach (var address in Addresses)
            {
                fulladdress += address;
            }
            MapCurrent.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-37.814, 144.96332), Distance.FromKilometers(10)));
            var            post    = Application.Current.Properties["Postcode"] as string;
            List <Library> library = await lib.GetbyPostcodeAsync(int.Parse(post));

            //  test.Text = "We display the top " + library.Count.ToString() + " most close Library of your postcode";
            testLogin.IsEnabled     = true;
            testLogin.IsVisible     = true;
            testNoneLogin.IsEnabled = false;
            testNoneLogin.IsVisible = false;


            if (library.Count > 0)
            {
                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
                        }
                    };

                    MapCurrent.CustomPins = new List <CustomPin> {
                        pin
                    };
                    MapCurrent.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
                };

                MapCurrent.Pins.Add(myPin);
            }
        }