Class GLSearchRequest

java.lang.Object
globus.glsearch.GLSearchRequest

public final class GLSearchRequest extends Object
Request model for GLSearch. The same request runs against either transport: startOnline(ResultsCallback) queries the online search service (/v1/search, /v1/autocomplete); startOffline(ResultsCallback) queries the downloaded offline maps. Both apply the same ranking and display rules. The low-level GLSearch class (tag filters over offline data) is separate.

The request returns GLMapVectorObjectList with display data baked on each object: the primary name through the object's localized name, the second line as the search:secondaryText tag, and category/icon through GLSearch.GetSearchCategory(globus.glmap.GLMapVectorObject).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Callback invoked when an online or offline request finishes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final String[]
    Optional GLSearch category identifiers, for example "cafe" or "restaurant".
    final globus.glmap.MapGeoPoint
    Search center used for result ranking.
    final int
    Maximum number of results.
    final String[]
    Ordered locale codes, for example {"be", "ru", "en", "native"}.
    final String
    User query text.
    final int
    Request type: search or autocomplete.
    final globus.glmap.GLMapBBox
    Optional visible bounds in internal map coordinates.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GLSearchRequest(int type, String text)
    Creates a search request from a type and text; center, limit, locales, and categories keep their defaults (no ranking center — global — and no category filter).
    GLSearchRequest(int type, String text, globus.glmap.MapGeoPoint center, int limit, String[] locales, String[] categories)
    Creates a search request with a ranking center.
    GLSearchRequest(int type, String text, globus.glmap.MapGeoPoint center, int limit, String[] locales, String[] categories, globus.glmap.GLMapBBox visibleArea)
    Creates a request with an optional soft viewport hint.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    cancel(long requestID)
    boolean
     
    int
     
    long
    Starts the same request against downloaded offline maps.
    long
    Starts the request against the online search service.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • type

      public final int type
      Request type: search or autocomplete.
    • text

      @NonNull public final String text
      User query text.
    • locales

      @Nullable public final String[] locales
      Ordered locale codes, for example {"be", "ru", "en", "native"}. The first entry is the preferred display language; every entry is used for matching. "native" requests the map object's native name. Null or empty uses native names only.
    • limit

      public final int limit
      Maximum number of results. Values less than 1 use server defaults.
    • center

      @Nullable public final globus.glmap.MapGeoPoint center
      Search center used for result ranking. The center is not a strict geographic filter.
    • visibleArea

      @Nullable public final globus.glmap.GLMapBBox visibleArea
      Optional visible bounds in internal map coordinates. A soft hint, not a strict filter: centered online corrections use twice the farthest corner distance, clamped to 50–500 km. Named cities may move the search area. Null/empty clears the hint; without a center it has no effect. Offline builds without fuzzy support do not perform corrections.
    • categories

      @Nullable public final String[] categories
      Optional GLSearch category identifiers, for example "cafe" or "restaurant".
  • Constructor Details

    • GLSearchRequest

      public GLSearchRequest(int type, @NonNull String text)
      Creates a search request from a type and text; center, limit, locales, and categories keep their defaults (no ranking center — global — and no category filter). Use the full constructor to customize.
      Parameters:
      type - request type: search or autocomplete
      text - user query text or autocomplete input
    • GLSearchRequest

      public GLSearchRequest(int type, @NonNull String text, @Nullable globus.glmap.MapGeoPoint center, int limit, @Nullable String[] locales, @Nullable String[] categories)
      Creates a search request with a ranking center. The two nullable refinements (locales, categories) come last.
      Parameters:
      type - request type: search or autocomplete
      text - user query text or autocomplete input
      center - search center used for ranking nearby matches higher; null for a global request
      limit - maximum number of results; pass 0 to use server defaults
      locales - ordered locale codes; the first is the display language, all are used for matching; null for native names
      categories - GLSearch category identifiers; pass null for an unrestricted request
    • GLSearchRequest

      public GLSearchRequest(int type, @NonNull String text, @Nullable globus.glmap.MapGeoPoint center, int limit, @Nullable String[] locales, @Nullable String[] categories, @Nullable globus.glmap.GLMapBBox visibleArea)
      Creates a request with an optional soft viewport hint. The hint is copied and is not a strict geographic filter.
      Parameters:
      type - request type: search or autocomplete
      text - user query text or autocomplete input
      center - search center used for ranking nearby matches higher; null for a global request
      limit - maximum number of results; values less than 1 use the default limit
      locales - ordered locale codes; the first is the display language, all are used for matching; null or empty for native names
      categories - GLSearch category identifiers; null or empty for no category filter
      visibleArea - visible bounds in internal map coordinates; null or empty for no viewport hint. The hint has no effect without a center and does not enable fuzzy matching in offline mobile builds.
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • startOnline

      public long startOnline(@NonNull GLSearchRequest.ResultsCallback callback)
      Starts the request against the online search service.

      The callback may be invoked on a background thread (or synchronously, when the request completes without starting). If you update UI, post back to the main thread. The callback is invoked exactly once per start: a request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an ECANCELED error.

      Parameters:
      callback - callback that receives parsed vector objects or an error
      Returns:
      request ID that can be passed to cancel(long), or 0 if the request completed without starting
    • startOffline

      public long startOffline(@NonNull GLSearchRequest.ResultsCallback callback)
      Starts the same request against downloaded offline maps.

      Text, categories, center, limit and locales are mapped to the offline search engine with the same rules the online server uses, so both paths can share one code path in the app.

      The callback may be invoked on a background thread (or synchronously, when the request completes without starting). If you update UI, post back to the main thread. The callback is invoked exactly once per start: a request with nothing to search (both text and categories are empty, or an autocomplete prefix is below the minimum length) completes with an empty result. Category-only requests are valid. A cancelled request completes with an ECANCELED error.

      Parameters:
      callback - callback that receives result vector objects or an error
      Returns:
      request ID that can be passed to cancel(long), or 0 if the request completed without starting
    • cancel

      public static void cancel(long requestID)
      Cancels a request started via startOnline(ResultsCallback) or startOffline(ResultsCallback). The callback of the cancelled request receives an ECANCELED error.
      Parameters:
      requestID - request ID returned by the start method