public void OnClick(View view)
        {
            switch (view.Id)
            {
            case Resource.Id.btn_search_place_suggestion:
                double lat = double.Parse(latitudeInput.Text, CultureInfo.InvariantCulture);
                double lon = double.Parse(longitudeInput.Text, CultureInfo.InvariantCulture);

                QuerySuggestionRequest querySuggestionRequest = new QuerySuggestionRequest();
                querySuggestionRequest.Query       = queryInput.Text;
                querySuggestionRequest.Language    = languageInput.Text;
                querySuggestionRequest.CountryCode = countryCodeInput.Text;
                querySuggestionRequest.Location    = new Coordinate(lat, lon);
                querySuggestionRequest.Radius      = Java.Lang.Integer.ValueOf(radiusInput.Text);

                QuerySuggestionResultListener querySuggestionResultListener = new QuerySuggestionResultListener();
                searchService.QuerySuggestion(querySuggestionRequest, querySuggestionResultListener);

                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public void ExecPlaceSuggestionSearch()
        {
            QuerySuggestionRequest QuerySuggestionRequest = new QuerySuggestionRequest();

            if (QueryInput.Text.Length == 0)
            {
                ResultTextView.Text = "Error : Query is empty!";
                return;
            }
            QuerySuggestionRequest.Query = QueryInput.Text;


            if (!string.IsNullOrEmpty(LanguageInput.Text))
            {
                QuerySuggestionRequest.Language = LanguageInput.Text;
            }

            if (!string.IsNullOrEmpty(CountryCodeInput.Text))
            {
                QuerySuggestionRequest.CountryCode = CountryCodeInput.Text;
            }

            double lat;
            double lon;

            if (!string.IsNullOrEmpty(LatitudeInput.Text) || !string.IsNullOrEmpty(LongitudeInput.Text))
            {
                if (!(double.TryParse(LatitudeInput.Text, out lat)) || !(double.TryParse(LongitudeInput.Text, out lon)))
                {
                    ResultTextView.Text = "Error : Location is invalid!";
                    return;
                }
                QuerySuggestionRequest.Location = new Coordinate(lat, lon);
            }

            int radiusInt;

            if (!(Int32.TryParse(RadiusInput.Text, out radiusInt)) || radiusInt <= 0)
            {
                ResultTextView.Text = "Error : Radius Must be greater than 0 !";
                return;
            }
            QuerySuggestionRequest.Radius = (Integer)radiusInt;


            if (!string.IsNullOrEmpty(NortheastLatInput.Text) && !string.IsNullOrEmpty(NortheastLngInput.Text) && !string.IsNullOrEmpty(SouthwestLatInput.Text) && !string.IsNullOrEmpty(SouthwestLngInput.Text))
            {
                Coordinate       northeast = new Coordinate(double.Parse(NortheastLatInput.Text), double.Parse(NortheastLngInput.Text));
                Coordinate       southwest = new Coordinate(double.Parse(SouthwestLatInput.Text), double.Parse(SouthwestLngInput.Text));
                CoordinateBounds bounds    = new CoordinateBounds(northeast, southwest);
                QuerySuggestionRequest.Bounds = bounds;
            }

            QuerySuggestionRequest.Children     = Childern.Checked;
            QuerySuggestionRequest.StrictBounds = (Java.Lang.Boolean)BoundStrict.Checked;

            QuerySuggestionResultListener querySuggestionResultListener = new QuerySuggestionResultListener();

            // Call the search API.
            SearchService.QuerySuggestion(QuerySuggestionRequest, querySuggestionResultListener);
        }