Ejemplo n.º 1
0
        // sliders, labels, buttons for the filter menu
        public void filterLayout(CustomMap customMap, StackLayout stack)
        {
            int    bedMin      = 0;
            double bathMin     = 0;
            int    minPriceInt = 0;
            int    maxPriceInt = 0;
            int    minFeetInt  = 0;
            int    maxFeetInt  = 0;

            var city = new Entry {
                Placeholder = "City"
            };
            var county = new Entry {
                Placeholder = "County"
            };
            Label priceLabel = new Label {
                Text = "Price"
            };
            Label minPrice = new Label {
                Text = "Min: $", TextColor = minMaxColor
            };
            Label maxPrice = new Label {
                Text = "Max: $"
            };

            addGestureRecognizer(minPrice, maxPrice, "minPrice");
            addGestureRecognizer(maxPrice, minPrice, "maxPrice");
            Slider priceSlider = new Slider
            {
                Maximum = 1000000,
                Minimum = 100000,
            };

            priceSlider.ValueChanged += (sender, args) =>
            {
                if (minPriceClicked)
                {
                    minPriceInt   = Convert.ToInt32(args.NewValue);
                    minPrice.Text = "Min: $" + formatInt(minPriceInt);
                }
                else
                {
                    maxPriceInt   = Convert.ToInt32(args.NewValue);
                    maxPrice.Text = "Max: $" + formatInt(maxPriceInt);
                }
            };
            Label feetLabel = new Label {
                Text = "Square Feet"
            };
            Label minFeet = new Label {
                Text = "Min: ", TextColor = minMaxColor
            };
            Label maxFeet = new Label {
                Text = "Max: "
            };

            addGestureRecognizer(minFeet, maxFeet, "minFeet");
            addGestureRecognizer(maxFeet, minFeet, "maxFeet");
            Slider sqFt = new Slider
            {
                Maximum = 10000,
                Minimum = 500
            };

            sqFt.ValueChanged += (sender, args) =>
            {
                if (minFeetClicked)
                {
                    minFeetInt   = Convert.ToInt32(args.NewValue);
                    minFeet.Text = "Min: " + formatInt(minFeetInt);
                }
                else
                {
                    maxFeetInt   = Convert.ToInt32(args.NewValue);
                    maxFeet.Text = "Max: " + formatInt(maxFeetInt);
                }
            };
            List <String> bedList = new List <String> {
                "0+ Beds", "1+ Beds", "2+ Beds", "3+ Beds", "4+ Beds", "5+ Beds", "6+ Beds"
            };
            List <String> bathList = new List <String> {
                "0+ Baths", "1+ Baths", "1.5+ Baths", "2+ Baths", "3+ Baths", "4+ Baths", "5+ Baths", "6+ Baths"
            };
            Picker bedPicker = new Picker {
                Title = "Beds"
            };
            Picker bathPicker = new Picker {
                Title = "Baths"
            };

            foreach (String b in bedList)
            {
                bedPicker.Items.Add(b);
            }
            foreach (String b in bathList)
            {
                bathPicker.Items.Add(b);
            }
            bedPicker.SelectedIndexChanged += (sender, args) =>
            {
                if (bedPicker.SelectedIndex != -1)
                {
                    string bedNum = bedPicker.Items[bedPicker.SelectedIndex];
                    bedMin = Convert.ToInt32((bedNum.ToCharArray()[0]).ToString());
                }
            };
            bathPicker.SelectedIndexChanged += (sender, args) =>
            {
                if (bathPicker.SelectedIndex != -1)
                {
                    string bathNum = bathPicker.Items[bathPicker.SelectedIndex];
                    bathMin = Convert.ToInt32((bathNum.ToCharArray()[0]).ToString());
                    if (bathMin == 1)
                    {
                        if (bathNum.ToCharArray()[1] == '.')
                        {
                            bathMin = 1.5;
                        }
                    }
                    Debug.WriteLine("bathMin: " + bathMin);
                }
            };
            Button enter = new Button {
                Text = "enter"
            };

            enter.Clicked += async(sender, args) =>
            {
                if ((minPriceInt > maxPriceInt) || minFeetInt > maxFeetInt)
                {
                    await DisplayAlert("", "Error: Min must be less than Max", "Ok");
                }
                else
                {
                    requestFilteredResults(customMap, city.Text, county.Text, minPriceInt, maxPriceInt, minFeetInt, maxFeetInt, bedMin, bathMin);
                }
            };
            stack.Children.Add(city);
            stack.Children.Add(county);
            stack.Children.Add(priceLabel);
            stack.Children.Add(minPrice);
            stack.Children.Add(maxPrice);
            stack.Children.Add(priceSlider);
            stack.Children.Add(feetLabel);
            stack.Children.Add(minFeet);
            stack.Children.Add(maxFeet);
            stack.Children.Add(sqFt);
            stack.Children.Add(bedPicker);
            stack.Children.Add(bathPicker);
            stack.Children.Add(enter);
        }
Ejemplo n.º 2
0
        public void placeMap(CustomMap customMap)
        {
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lon), Distance.FromMiles(zoomOutAmt)));
            customMap.HasScrollEnabled = false;
            customMap.HasZoomEnabled   = false;
            var stack = new StackLayout {
                Spacing = 0
            };
            Button buttonZoomIn = new Button
            {
                Text = "➕ ",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 38
            };
            Button buttonZoomOut = new Button
            {
                Text = "➖",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 38,
            };
            Button buttonLoc = new Button
            {
                Text = "📌 Location ",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            Button polygonButton = new Button
            {
                Text = "🏠",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 38,
            };
            Button searchButton = new Button
            {
                Text = "🔍",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 38,
            };
            Button resetFiltersButton = new Button
            {
                Text = "🔄",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 38,
            };

            resetFiltersButton.Clicked += async(sender, args) =>
            {
                filteredAddresses.Clear();
                String[] city0 = yourCityState.Split(' ');
                findHouseAsync(yourAddress, city0[0], city0[1]);
            };
            polygonButton.Clicked += async(sender, args) =>
            {
                if (customMap.ShapeCoordinates.Count < 4)
                {
                    await DisplayAlert("", "Please select 4 points for the polygon first", "Ok");
                }
                else
                {
                    getPolygonAddresses(customMap);
                }
            };
            buttonZoomIn.Clicked += async(sender, args) =>
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lon), Distance.FromMiles(zoomInAmt)));
            };
            buttonZoomOut.Clicked += async(sender, args) =>
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lon), Distance.FromMiles(zoomOutAmt)));
            };
            searchButton.Clicked += async(sender, args) =>
            {
                searchClicked(customMap);
            };

            var refreshLoc = new Button
            {
                Text              = " 🔄 Location",
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            refreshLoc.Clicked += async(sender, args) => { refreshLocation(customMap); };
            stack.Children.Add(refreshLoc);
            stack.Children.Add(customMap);
            stack.Children.Add(buttonLoc);
            Content = stack;
            customMap.HasScrollEnabled = false;
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lon), Distance.FromMiles(10))); //1.0

            buttonLoc.Clicked += async(sender, args) =>
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(lat, lon), Distance.FromMiles(zoomOutAmt))); //1.0

                buttonLoc.IsVisible = false;
                stack.Children.Add(buttonZoomIn);
                stack.Children.Add(buttonZoomOut);
                // stack.Children.Add(polygonButton); //takes up a lot of room...
                stack.Children.Add(searchButton);
                if (filteredAddresses.Count > 0)
                {
                    stack.Children.Add(resetFiltersButton);
                }
                stack.Children.Add(loadingPinLabel);
                customMap.HasZoomEnabled   = false;
                customMap.HasScrollEnabled = false;
            };
        }
Ejemplo n.º 3
0
        // search button pressed:
        public void searchClicked(CustomMap customMap)
        {
            Label title = new Label {
                Text = "Search for a house", FontSize = 30, TextColor = Color.Black
            };
            Label filterLabel = new Label {
                Text = "Or filter house results ", FontSize = 30, TextColor = Color.Black
            };
            var stack = new StackLayout {
                Spacing = 0
            };
            var address = new Entry {
                Placeholder = "Address"
            };
            var city = new Entry {
                Placeholder = "City"
            };
            var state = new Entry {
                Placeholder = "State"
            };

            Button enter = new Button
            {
                Text = "enter"
            };

            enter.Clicked += async(sender, args) =>
            {
                try
                {
                    Debug.WriteLine("enter clicked:" + address.Text + city.Text + state.Text);
                    if (address.Text.Equals("") || city.Text.Equals("") || state.Text.Equals(""))
                    {
                        await DisplayAlert("", "House search failed", "Ok");
                    }
                    else
                    {
                        findHouseAsync(address.Text, city.Text, state.Text);
                    }
                } catch (Exception e)
                {
                    await DisplayAlert("", "House search failed", "Ok");
                }
            };
            Button back = new Button
            {
                Text = "◀️ back to map page"
            };
            Button filter = new Button
            {
                Text = "filter"
            };

            back.Clicked += async(sender, args) => { placeMap(customMap); };
            stack.Children.Add(title);
            stack.Children.Add(address);
            stack.Children.Add(city);
            stack.Children.Add(state);
            stack.Children.Add(enter);
            // stack.Children.Add(new Label { Text = " " });
            stack.Children.Add(filterLabel);
            filterLayout(customMap, stack);
            stack.Children.Add(new Label {
                Text = " "
            });
            stack.Children.Add(back);
            Content = stack;
        }
Ejemplo n.º 4
0
        //decide which geolocations are valid and add them to list
        async System.Threading.Tasks.Task populateAddress(double lat1, double lon1, CustomMap customMap, Boolean yourLoc, int index)
        {
            if (index % 5 == 0)
            {
                curIndex++;
                loadingPinLabel.Text = loadingClocks[curIndex] + " loading pins...";
                if (curIndex == loadingClocks.Length - 1)
                {
                    curIndex = -1;
                }
            }
            try
            {
                var placemarks = await Geocoding.GetPlacemarksAsync(lat1, lon1);

                var placemark = placemarks?.FirstOrDefault();
                if (placemark != null)
                {
                    var geocodeAddress =
                        $"AdminArea:       {placemark.AdminArea}\n" +
                        $"CountryCode:     {placemark.CountryCode}\n" +
                        $"CountryName:     {placemark.CountryName}\n" +
                        $"FeatureName:     {placemark.FeatureName}\n" +
                        $"Locality:        {placemark.Locality}\n" +
                        $"PostalCode:      {placemark.PostalCode}\n" +
                        $"SubAdminArea:    {placemark.SubAdminArea}\n" +
                        $"SubLocality:     {placemark.SubLocality}\n" +
                        $"SubThoroughfare: {placemark.SubThoroughfare}\n" +
                        $"Thoroughfare:    {placemark.Thoroughfare}\n";
                    System.Diagnostics.Debug.WriteLine(geocodeAddress);
                    System.String address   = placemark.FeatureName + " " + placemark.Thoroughfare;
                    System.String cityState = placemark.Locality + " " + placemark.AdminArea;
                    if (!yourLoc && cityState.Equals(yourCityState) && address.Equals(yourAddress))
                    {
                        return;
                    }
                    if (filteredAddresses.Count > 0 && !filteredAddresses.Contains(address + " " + cityState))
                    {
                        return;
                    }
                    filteredPinsPlaced++;
                    String houseInfo = address + " " + placemark.Locality + " " + placemark.AdminArea;
                    if (addressInfo.Contains(houseInfo))
                    {
                        return;
                    }
                    if (address.Equals("Unnamed Road Unnamed Road"))
                    {
                        return;
                    }
                    //  String id = "Xamarin";
                    bool isLocation = false;
                    if (yourLoc)
                    {
                        //   id = "yourLocation";
                        isLocation    = true;
                        yourAddress   = address;
                        yourCityState = cityState;
                    }
                    addressInfo.Add(houseInfo);
                    createPinAsync(customMap, lat1, lon1, isLocation, address, cityState);
                }
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.ToString() + "Error with getting coordinates");
            }
        }