setData method
Configure third-party or self-hosted API endpoints.
Ensure that the request body, parameters, and HTTP method are compatible with the default OpenStreetMap services.
Parameters:
-
userAgent
: The User-Agent string to send in request headers to the Nominatim server. -
searchURL
: The URL for search address requests. Default:https://nominatim.openstreetmap.org/search.php
-
reverseURL
: The URL for reverse geocoding requests. Default:https://nominatim.openstreetmap.org/reverse.php
-
polylineURL
: The URL used to fetch routes (polylines). Default:https://router.project-osrm.org/route/v1/driving
Implementation
void setData({
String? userAgent,
String? searchURL,
String? reverseURL,
String? polylineURL,
}) {
if (userAgent != null) _userAgent = userAgent;
if (searchURL != null && searchURL != BaseURL.search) {
if (!_validURL(searchURL)) throw Exception('Invalid search URL');
_searchURL = UrlModel(url: searchURL, isCustom: true);
}
if (reverseURL != null && reverseURL != BaseURL.reverse) {
if (!_validURL(reverseURL)) throw Exception('Invalid reverse URL');
_reverseURL = UrlModel(url: reverseURL, isCustom: true);
}
if (polylineURL != null && polylineURL != BaseURL.polyline) {
if (!_validURL(polylineURL)) throw Exception('Invalid polyline URL');
_polylineURL = UrlModel(url: polylineURL, isCustom: true);
}
}