Directory | Mobile SDK | Urbi Documentation
Flutter SDK

Directory

To search for objects in the directory, create a SearchManager object by calling one of the following methods:

  • SearchManager.createOnlineManager() - creates an object to work with an online directory.
  • SearchManager.createOfflineManager() - creates an object to work with an offline directory (preloaded data only).
  • SearchManager.createSmartManager() - creates an object that works primarily with online data and switches to offline mode when the network goes down.
import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

final SearchManager searchManager = sdk.SearchManager.createOnlineManager(context);

If the object ID is known, to get information about the object, call the searchById() method. The method returns a deferred result with a DirectoryObject object.

import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

searchManager.searchByDirectoryObjectId(objectId);

If the object ID is not known, you can create a SearchQuery object using SearchQueryBuilder and pass it to the search() method. The method returns a deferred result with a SearchResult object, which contains a paginated list of DirectoryObject.

import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

final SearchQuery searchQuery = searchManager.search(sdk.SearchQueryBuilder.fromQueryText(query)).setPageSize(15).build();

final SearchResult result = await widget._searchManager.search(query).value;

final Page? searchPage = result.firstPage;

To get the next page of search results, call the fetchNextPage() page method, which returns a deferred result with a Page object.

import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

final Page? nextPage = await searchPage?.fetchNextPage()?.value;

You can also use the object directory to get suggestions when text searching (see Suggest API for demonstration). Create a SuggestQuery object using SuggestQueryBuilder and pass it to the suggest() method. The method returns a deferred result with a SuggestResult object, which contains a list of suggestions (Suggest objects).

import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

final SuggestQuery suggestQuery = sdk.SuggestQueryBuilder.fromQueryText(query).build();

final SuggestQuery = await searchManager.suggest(suggestQuery).value;

You can search for addresses with the exact apartment or entrance number.

DgisObjectId contains two identifiers:

  • objectId - stable numeric identifier of the object.

  • entranceId - stable numeric identifier of the object entrance.

    If the entranceId is non-zero, then the search result is not a building, but a specific entrance.

If you need to draw a marker on a specific entrance or get its coordinates to calculate a route, do not use the markerPosition property. This property contains the position related to the marker of the building. To get the entrance position, use the information from the entrances.

import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;

sdk.GeoPoint? getMarkerPosition(sdk.DirectoryObject directoryObject) {
  final int entranceId = directoryObject.id?.entranceId ?? 0;
  if (entranceId != 0) {
    return directoryObject.entrances
            .firstWhere((entrance) => entrance.id.entranceId == entranceId)
            .geometry
            ?.entrancePoints
            .firstOrNull ??
        directoryObject.markerPosition?.point;
  }
  return null;
}