search static method

TaskHandler? search(
  1. String filter,
  2. Landmark parent,
  3. AddressDetailLevel detailLevel,
  4. void onCompleteCallback(
    1. GemError err,
    2. List<Landmark> landmarks
    ),
)

Search for more details starting at the selected parent landmark.

Starting at the selected parent landmark the engine will search the required detail level using the provided filter.

Parameters

  • IN parent The starting point for the search. If it is default then the only detail level that can be searched is AddressDetailLevel.country. If the landmark address detail level is AddressDetailLevel.street then the next details that can be searched may be AddressDetailLevel.houseNumber or AddressDetailLevel.crossing (for example). It is also allowed to 'decrease' the search level and use AddressDetailLevel.city (for example).
  • IN filter The filter to use when searching for the required detail level. If it is empty then all items are returned (limited to the maximum number of matches from preferences).
  • IN detailLevel The address detail level to search.
  • IN onCompleteCallback Will be invoked when the search operation is completed, providing the search results and an error code.

Returns

  • Associated TaskHandler for this operation if the search can be started otherwise null.

Throws

  • An exception if it fails.

Implementation

static TaskHandler? search(
  final String filter,
  final Landmark parent,
  final AddressDetailLevel detailLevel,
  final void Function(GemError err, List<Landmark> landmarks)
      onCompleteCallback,
) {
  final EventDrivenProgressListener progListener =
      EventDrivenProgressListener();
  GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
  final LandmarkList results = LandmarkList();

  progListener.registerOnCompleteWithDataCallback((
    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) {
      onCompleteCallback(GemErrorExtension.fromCode(err), results.toList());
    } else {
      onCompleteCallback(GemErrorExtension.fromCode(err), <Landmark>[]);
    }
  });

  final OperationResult resultString = staticMethod(
    'GuidedAddressSearchService',
    'search',
    args: <String, dynamic>{
      'results': results.pointerId,
      'parent': parent.pointerId,
      'filter': filter,
      'detailToSearch': detailLevel.id,
      'progress': progListener.id,
    },
  );

  final int errorCode = resultString['result'];

  if (errorCode != GemError.success.code) {
    onCompleteCallback(GemErrorExtension.fromCode(errorCode), <Landmark>[]);
    return null;
  }

  return TaskHandlerImpl(progListener.id);
}