Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Xamarin.Geolocation - How to constrain results to a geographic area

$
0
0

` Hi, basically what i would like to do is to have the "GetPositionsForAddressAsyncCall" be constrained to a GeoGraphic region - like North America, Or USA, or NewYork, or zipcode.
What i don't want is for it to search the entire world - but i don't see any overloads for this method, and don't see any Parameters I can set on the Geocoder object.
Is there a way to achieve this?

Some sample code:

    //Used to disambiguate between Xamarin.Forms.Maps.Position and Xamarin.Geolocation.Position
    using MapPosition = Xamarin.Forms.Maps.Position;  
    var approximateLocation = await _geoCoder.GetPositionsForAddressAsync(searchText);
                            List<string> possibleAddresses = new List<string>();
                            MapPosition position = new MapPosition();

                            foreach (var p in approximateLocation)
                            {
                                position = new MapPosition(p.Latitude, p.Longitude);
                                var locationAddress = await _geoCoder.GetAddressesForPositionAsync(position);
                                if(locationAddress != null && locationAddress.ToList().Count > 0)
                                    possibleAddresses.Add(locationAddress.ToList()[0]);

                            }`

Viewing all articles
Browse latest Browse all 58056

Trending Articles