Ejemplo n.º 1
0
        public async Task <Address[]> SearchAsync(string query, double?pickupLatitude, double?pickupLongitude, string currentLanguage, GeoResult geoResult = null)
        {
            var popularPlaces = new Address[0];

            if (query.HasValue())
            {
                popularPlaces = SearchPopularAddresses(query);
            }

            if (geoResult == null)
            {
                var addresses = await SearchUsingNameAsync(query, currentLanguage, pickupLatitude, pickupLongitude);

                return(addresses == null
                    ? popularPlaces
                    : popularPlaces.Concat(addresses.Select(a => new GeoObjToAddressMapper().ConvertToAddress(a, null, true))).ToArray());
            }
            else
            {
                var addresses = geoResult.ConvertGeoResultToAddresses();

                return(addresses == null
                    ? popularPlaces
                    : popularPlaces.Concat(addresses.Select(a => new GeoObjToAddressMapper().ConvertToAddress(a, null, true))).ToArray());
            }
        }
Ejemplo n.º 2
0
        public async Task <Address[]> SearchAsync(double latitude, double longitude, string currentLanguage, GeoResult geoResult = null,
                                                  bool searchPopularAddress = false)
        {
            var addressesInRange = new Address[0];

            if (searchPopularAddress)
            {
                addressesInRange = GetPopularAddressesInRange(new Position(latitude, longitude));
            }

            var addresses = geoResult != null
                ? geoResult.ConvertGeoResultToAddresses()
                : await _mapApi.GeocodeLocationAsync(latitude, longitude, currentLanguage);

            return(addressesInRange
                   .Concat(addresses.Select(ToAddress))
                   .ToArray());
        }