Interface SearchLayer

com.yandex.mapkit.search.search_layer

public interface SearchLayer

The search layer handles the map search requests and displays the results automatically on the map.

It also handles the map movements and resubmits searches when needed.

Methods

void addPlacemarkListener(@NonNull PlacemarkListener placemarkListener)

Add the placemark listener which will receive notifications from the search layer.

void addSearchResultListener(@NonNull SearchResultListener searchResultListener)

Add the search result listener which will receive notifications from the search layer.

void clear()

Clear the displayed search results from the map.

void deselectPlacemark()

Deselect all placemarks.

void enableMapMoveOnSearchResponse(boolean enable)

Enable or disable moving the map to the primary search response.

void enableResubmitsOnMapMoves(boolean enable)

Enable or disable search resubmits when the map is moved.

void fetchNextPage()

Load the next page of results.

void forceUpdateIcon(@NonNull String geoObjectId, @NonNull PlacemarkIconType iconType, @NonNull ImageProvider image, @NonNull IconStyle style)

Update the icon image for each suitable placemark.

void forceUpdateMapObjects()

Force reloading of all visible pins from AssetsProvider.

List< SearchResultItem > getSearchResultsList()

Get the list of search results.

boolean hasNextPage()

Check if more results could be loaded.

boolean isValid()

Tells if this SearchLayer is valid or no.

void obtainAdIcons(boolean enable)

If enabled, the search layer will obtain and set advertising icons without asking AssetsProvider.

void removePlacemarkListener(@NonNull PlacemarkListener placemarkListener)

Remove placemark listener.

void removeSearchResultListener(@NonNull SearchResultListener searchResultListener)

Remove search result listener.

void resetAssetsProvider()

Reset the asset provider to default.

void resolveUri(@NonNull String uri, @NonNull SearchOptions searchOptions)

Submit search request for URI resolution.

void resubmit()

Manual resubmit.

void searchByOid(@NonNull String oid, @NonNull SearchOptions searchOptions)

Submit search request by organization ID.

SearchMetadata searchMetadata()

Get the last search response metadata.

void selectPlacemark(@NonNull String geoObjectId)

Select placemark by ID.

String selectedPlacemarkId()

Selected placemark ID.

void setAssetsProvider(@NonNull AssetsProvider provider)

Set the custom asset provider, which provides images, sizes and icon styles for placemarks.

void setBaseZIndex(float zIndex)

Set the base z-index for displaying map objects from search results.

void setBitmapDownloader(@NonNull BitmapDownloader bitmapDownloader)

Set bitmap downloader.

void setFilters(@NonNull List< BusinessFilter > filters)

Set search filters.

void setSearchManager(@NonNull SearchManager searchManager)

Set search manager.

void setSortByDistance(@NonNull Geometry origin, @NonNull GeometrySearchType geometrySearchType)

Set sort order of the results by the distance to the geometry.

void setSortByRank()

Set sort order of the results by search rank.

void submitQuery(@NonNull String query, @NonNull SearchOptions searchOptions)

Submit search query with search options.

Method Detail

addPlacemarkListener

public void addPlacemarkListener (@NonNull PlacemarkListener placemarkListener)

Add the placemark listener which will receive notifications from the search layer.

Parameters:
placemarkListener

Placemark listener to add.

addSearchResultListener

public void addSearchResultListener (@NonNull SearchResultListener searchResultListener)

Add the search result listener which will receive notifications from the search layer.

Parameters:
searchResultListener

Search result listener to add.

clear

public void clear ()

Clear the displayed search results from the map.

deselectPlacemark

public void deselectPlacemark ()

Deselect all placemarks.

enableMapMoveOnSearchResponse

public void enableMapMoveOnSearchResponse (boolean enable)

Enable or disable moving the map to the primary search response.

Moving the map is enabled by default.
Parameters:
enable

Enable map moving if true, disable otherwise.

enableResubmitsOnMapMoves

public void enableResubmitsOnMapMoves (boolean enable)

Enable or disable search resubmits when the map is moved.

Resubmits are enabled by default.
Parameters:
enable

Enable resubmits if true, disable otherwise.

fetchNextPage

public void fetchNextPage ()

Load the next page of results.

forceUpdateIcon

public void forceUpdateIcon (@NonNull String geoObjectId, @NonNull PlacemarkIconType iconType, @NonNull ImageProvider image, @NonNull IconStyle style)

Update the icon image for each suitable placemark.

If the placemark is not found, the image will be put in a queue and will be applied once when the placemark is created. This is not the regular way to set the image. It is highly advisable to return the correct image from AssetsProvider.
Parameters:
geoObjectId

Placemark identifier.

iconType

Icon type.

image

Icon image.

style

Icon style.

forceUpdateMapObjects

public void forceUpdateMapObjects ()

Force reloading of all visible pins from AssetsProvider.

Use when it is necessary to update ALL the icons simultaneously (i.e. icon theme change, day/night mode, etc.). This can be a pretty expensive operation, as it wipes all the map objects off of the layer and creates them from scratch. Use only if absolutely necessary.

getSearchResultsList

public List< SearchResultItem > getSearchResultsList ()

Get the list of search results.

hasNextPage

public boolean hasNextPage ()

Check if more results could be loaded.

isValid

public boolean isValid ()

Tells if this SearchLayer is valid or no.

Any other method (except for this one) called on an invalid SearchLayer will throw java.lang.RuntimeException. An instance becomes invalid only on UI thread, and only when its implementation depends on objects already destroyed by now. Please refer to general docs about the interface for details on its invalidation.

obtainAdIcons

public void obtainAdIcons (boolean enable)

If enabled, the search layer will obtain and set advertising icons without asking AssetsProvider.

Parameters:
enable

Enable this mode if true, disable otherwise.

removePlacemarkListener

public void removePlacemarkListener (@NonNull PlacemarkListener placemarkListener)

Remove placemark listener.

Parameters:
placemarkListener

Placemark listener to remove.

removeSearchResultListener

public void removeSearchResultListener (@NonNull SearchResultListener searchResultListener)

Remove search result listener.

Parameters:
searchResultListener

Search result listener to remove.

resetAssetsProvider

public void resetAssetsProvider ()

Reset the asset provider to default.

resolveUri

public void resolveUri (@NonNull String uri, @NonNull SearchOptions searchOptions)

Submit search request for URI resolution.

Parameters:
uri

Object URI.

searchOptions

Additional search parameters. See SearchOptions definition for details, and 'resolveURI' method in SearchManager for currently supported options.

resubmit

public void resubmit ()

Manual resubmit.

searchByOid

public void searchByOid (@NonNull String oid, @NonNull SearchOptions searchOptions)

Submit search request by organization ID.

Parameters:
oid

ID of organization.

searchOptions

Additional search parameters. See SearchOptions definition for details, and 'searchByOid' method in SearchManager for currently supported options.

searchMetadata

public SearchMetadata searchMetadata ()

Get the last search response metadata.

selectPlacemark

public void selectPlacemark (@NonNull String geoObjectId)

Select placemark by ID.

Parameters:
geoObjectId

Placemark identifier.

selectedPlacemarkId

public String selectedPlacemarkId ()

Selected placemark ID.

Returns:

s Placemark identifier if any placemark is selected, nothing otherwise.

setAssetsProvider

public void setAssetsProvider (@NonNull AssetsProvider provider)

Set the custom asset provider, which provides images, sizes and icon styles for placemarks.

Parameters:
provider

Asset provider (must not be null).

setBaseZIndex

public void setBaseZIndex (float zIndex)

Set the base z-index for displaying map objects from search results.

It is guaranteed that all map objects from search will have the z-index within the interval [base; base + 10] Note: if the asset provider explicitly sets the z-index for an icon, then it is not guaranteed that the icon will have a z-index within the interval [base; base + 10]

setBitmapDownloader

public void setBitmapDownloader (@NonNull BitmapDownloader bitmapDownloader)

Set bitmap downloader.

Do not use this method; it is for internal use only.
Parameters:
bitmapDownloader

Bitmap downloader.

setFilters

public void setFilters (@NonNull List< BusinessFilter > filters)

Set search filters.

Parameters:
filters

Business filters.

setSearchManager

public void setSearchManager (@NonNull SearchManager searchManager)

Set search manager.

Do not use this method; it is for internal use only.
Parameters:
searchManager

Search manager.

setSortByDistance

public void setSortByDistance (@NonNull Geometry origin, @NonNull GeometrySearchType geometrySearchType)

Set sort order of the results by the distance to the geometry.

Parameters:
origin

Geometry to sort by.

geometrySearchType

Geometry search type.

setSortByRank

public void setSortByRank ()

Set sort order of the results by search rank.

submitQuery

public void submitQuery (@NonNull String query, @NonNull SearchOptions searchOptions)

Submit search query with search options.

Parameters:
query

User query.

searchOptions

Search options.