Interface SearchLayer

com.yandex.mapkit.search.search_layer

public interface SearchLayer

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

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

Methods

void addPlacemarkListener(@NonNull PlacemarkListener placemarkListener)

Add a 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 on 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 all visible pins from AssetProvider.

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.

boolean isVisible()

Search layer visibility.

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 assets 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.

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

Submit search request for URI resolution.

SearchMetadata searchMetadata()

Get the last search response metadata.

void selectPlacemark(@NonNull String geoObjectId)

Select the placemark by ID.

String selectedPlacemarkId()

Selected placemark ID.

void setAssetsProvider(@NonNull AssetsProvider provider)

Set a custom assets 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.

void setBitmapDownloader(@NonNull BitmapDownloader bitmapDownloader)

Set the bitmap downloader.

void setFilters(@NonNull List< BusinessFilter > filters)

Set search filters.

void setInsets(int top, int left, int bottom, int right)

Apply insets (in pixels) to the screen.

void setSearchManager(@NonNull SearchManager searchManager)

Set the search manager.

void setSortByDistance(@NonNull Geometry origin)

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

void setSortByRank()

Set sort order of the results by search rank.

void setVisible(boolean visible)
void submitQuery(@NonNull String query, @NonNull SearchOptions searchOptions)

Submit search query with search options.

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

Submit search query with search options near provided geometry.

Method Detail

addPlacemarkListener

public void addPlacemarkListener (@NonNull PlacemarkListener placemarkListener)

Add a 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 on primary search response.

Map moving 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 normal way to set the image. It is highly advisable to return the right image from AssetsProvider.
Parameters:
geoObjectId

Placemark identifier

iconType

Icon type

image

Icon image

style

Icon style

forceUpdateMapObjects

public void forceUpdateMapObjects ()

Force reloading all visible pins from AssetProvider.

Use when there is a reason 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.

isVisible

public boolean isVisible ()

Search layer visibility.

Visible by default. While the layer is invisible resubmits are not performed on map moves, but all the state changing methods (submitQuery, resubmit, deselectPlacemark, etc.) are executed as usual.

obtainAdIcons

public void obtainAdIcons (boolean enable)

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

Parameters:
enable

Enable 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 assets 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.

searchByUri

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

Submit search request for URI resolution.

Allows multiple objects in response.
Parameters:
uri

Object URI.

searchOptions

Additional search parameters. See SearchOptions definition for details, and 'searchByURI' 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 the placemark by ID.

Parameters:
geoObjectId

Placemark identifier

selectedPlacemarkId

public String selectedPlacemarkId ()

Selected placemark ID.

Returns:

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

setAssetsProvider

public void setAssetsProvider (@NonNull AssetsProvider provider)

Set a custom assets provider, which provides images, sizes and icon styles for placemarks.

Parameters:
provider

Assets provider (must not be null)

setBaseZIndex

public void setBaseZIndex (float zIndex)

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

It is guaranteed that all search map objects will have a z-index within the interval [base; base + 10] Note: if the assets 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 the 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

setInsets

public void setInsets (int top, int left, int bottom, int right)

Apply insets (in pixels) to the screen.

If inset is not zero, search in the cut-off area will not be performed.
Parameters:
top

Top inset.

left

Left inset.

bottom

Bottom inset.

right

Right inset.

setSearchManager

public void setSearchManager (@NonNull SearchManager searchManager)

Set the search manager.

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

Search manager

setSortByDistance

public void setSortByDistance (@NonNull Geometry origin)

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

Parameters:
origin

Geometry to sort by.

setSortByRank

public void setSortByRank ()

Set sort order of the results by search rank.

setVisible

public void setVisible (boolean visible)

submitQuery

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

Submit search query with search options.

Parameters:
query

User query

searchOptions

Search options

submitQuery

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

Submit search query with search options near provided geometry.

Parameters:
query

User query.

geometry

Geometry to search near. Supported types: point, bounding box, polyline and polygon. Polygon is expected to be a search window: 4 points in outer ring (or 5 if the last point is equal to the first) and no inner rings.

searchOptions

Search options.