Click or drag to resize

AutocompleteGeocoderGeocode Method (String, BoundingBox, LatLon, TimeSpan)

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Generate a set of address suggestions based on the partial address string provided, searching all countries which intersect the provided BoundingBox, with an optional LatLon location hint provided to sort results based on country and proximity.

Namespace:  Telogis.GeoBase.Geocoding
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public static AutocompleteGeocoderResult Geocode(
	string query,
	BoundingBox countriesZone,
	LatLon locationHint,
	TimeSpan timeout
)

Parameters

query
Type: SystemString
The partial address string for which to search.
countriesZone
Type: Telogis.GeoBaseBoundingBox
A BoundingBox that determines which countries to search. All countries intersecting this BoundingBox will be included in the search. Note that this does not limit the search to only those regions of the country covered by the BoundingBox. If a value of null is passed for this parameter, all available countries will be searched.
locationHint
Type: Telogis.GeoBaseLatLon
A LatLon value. Suggestions from the country in which this location falls will appear first in the list of suggestions, and suggestions from this country will in turn be sorted by their proximity to this location, from nearest to further. Suggestions from other countries will not be sorted based on their proximity to this location. If you do not wish to use a location hint, this parameter should be set to Empty.
timeout
Type: SystemTimeSpan
Specifies how long the search should continue before terminating prematurely. Specifying a timeout of TimeSpan.Zero means that the search will not timeout. When a search times out, the AutocompleteGeocoderResult object returned will contain all suggestions found prior to the timeout, and have a status of Timeout.

Return Value

Type: AutocompleteGeocoderResult
An AutocompleteGeocoderResult object, containing an array of suggestions along with a status code.
Remarks
Due to the potential for latency, running this method on a non-UI thread is recommended. See the Autocomplete Geocoder Tutorial for an example of a threaded implementation.
Examples
C#
AutocompleteGeocoderResult result = AutocompleteGeocoder.Geocode("Queen Stre", new BoundingBox(new LatLon(-40.9, 167.7), new LatLon(-46.2, 176.4)), LatLon.Empty, TimeSpan.FromSeconds(5));
if (result.Status == SearchResult.SearchCompleted && result.Suggestions.Length == 0) {
    Console.WriteLine("No result found.");
} else if (result.Status == SearchCancelled) {
    Console.WriteLine("Search was cancelled.");
} else {
    if (result.Status == SearchResult.TooManyResults || result.Status == SearchResult.Timeout) {
        Console.WriteLine("Too many results for the string provided. Further qualify the address to see further suggestions.");
    } else if (result.Status == SearchResult.SearchCompleted) {
        Console.WriteLine("Search completed");
    }
    foreach (AutocompleteGeocoderSuggestion suggestion in result.Suggestions) {
        Console.WriteLine(suggestion.ToString());
    }
}
See Also