searchAlongRoute static method
Search for landmarks along a route.
Finds landmarks along the specified route, optionally filtered by textFilter.
Parameters
route: The route to search along.onComplete: Callback invoked when the search completes. Provides:err: The result status. Possible values:- GemError.success: Search completed successfully with results.
- GemError.reducedResult: Search completed successfully but only a subset of results was returned.
- GemError.invalidInput: Invalid input.
- GemError.cancel: Search canceled by user.
- GemError.noMemory: Insufficient memory for operation.
- GemError.operationTimeout: Operation timeout on online service (typically > 1 min).
- GemError.networkFailed: Network failure during online search.
results: List of found landmarks (empty on error).
textFilter: Optional text filter to narrow results.preferences: Optional SearchPreferences to customize search behavior.
Returns
- TaskHandler?: TaskHandler for this operation if search could be started; otherwise null.
See also:
- Route - Represents the route along which to search for landmarks.
- SearchPreferences - Configure search behavior (fuzzy matching, onboard-only, max results, etc.).
Implementation
static TaskHandler? searchAlongRoute(
final Route route,
final void Function(GemError err, List<Landmark> results) onComplete, {
final String? textFilter,
SearchPreferences? preferences,
}) {
preferences ??= SearchPreferences();
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
final LandmarkList results = LandmarkList();
progListener.registerOnCompleteWithData((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
if (err == GemError.success.code || err == GemError.reducedResult.code) {
onComplete(GemErrorExtension.fromCode(err), results.toList());
} else {
onComplete(GemErrorExtension.fromCode(err), <Landmark>[]);
}
});
final OperationResult resultString = staticMethod(
'SearchService',
'searchAlongRoute',
args: <String, dynamic>{
'results': results.pointerId,
'listener': progListener.id,
'route': route.pointerId,
if (textFilter != null) 'textFilter': textFilter,
'preferences': preferences.pointerId,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete(errorCode, <Landmark>[]);
return null;
}
return TaskHandlerImpl(progListener.id);
}