forwardSearch method
Does a forward search with the given searchText
.
Results can be prioritized around a certain latitude
and longitude
or inside a certain boundingBox
.
The langCode
is an ISO-639-1 language code. Supported languages are EN, DE, FR, IT.
When no langCode
is given, the default language is the main language at the result's location.
Use layer
to filter by a certain layer, see Photon documentation for this.
You can specify your own query parameters in the additionalQuery
map, for example for filtering by OSM tags and values
If secure
is set to false, requests will be performed via HTTP, otherweise HTTPS is used (default).
Throws an exception if the API response has a status code different than 200.
Implementation
Future<List<PhotonFeature>> forwardSearch(String searchText,
{int? limit,
double? latitude,
double? longitude,
String? langCode,
PhotonBoundingBox? boundingBox,
PhotonLayer? layer,
Map<String, String>? additionalQuery,
bool secure = true}) async {
var initialQueryParams = {'q': searchText};
if (boundingBox != null) {
initialQueryParams['bbox'] = boundingBox.buildRequestString();
}
final queryParams = _buildQueryParams(
init: initialQueryParams,
limit: limit,
latitude: latitude,
longitude: longitude,
langCode: langCode,
layer: layer,
additionalQuery: additionalQuery);
final uri = secure
? Uri.https(
_baseUri.authority, _baseUri.path + _forwardEndpoint, queryParams)
: Uri.http(
_baseUri.authority, _baseUri.path + _forwardEndpoint, queryParams);
final res = await http.get(uri);
return _handleResponse(res);
}