Interface SearchLayer
- Summary
- Methods
- submitQuery
- submitQuery
- searchByUri
- resubmit
- enableRequestsOnMapMoves
- enableMapMoveOnSearchResponse
- hasNextPage
- fetchNextPage
- clear
- getSearchResultsList
- searchMetadata
- setSearchManager
- addSearchResultListener
- removeSearchResultListener
- addPlacemarkListener
- removePlacemarkListener
- setSortByDistance
- setPolylinePosition
- resetSort
- setFilterCollection
- setFilters
- setAssetsProvider
- resetAssetsProvider
- selectPlacemark
- selectedPlacemarkId
- deselectPlacemark
- forceUpdateIcon
- forceUpdateMapObjects
- obtainAdIcons
- setInsets
- isVisible
- setVisible
- isValid
Warning
This feature is available in the Full MapKit SDK version
Package com.yandex.mapkit.search.search_layer
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.
Summary
Methods
|
Type and modifiers |
Method and Description |
|
void |
submitQuery(@NonNull java.lang.String query, |
|
void |
submitQuery(@NonNull java.lang.String query, |
|
void |
searchByUri(@NonNull java.lang.String uri, |
|
void |
resubmit() |
|
void |
enableRequestsOnMapMoves(boolean enable) |
|
void |
enableMapMoveOnSearchResponse(boolean enable) |
|
boolean |
hasNextPage() |
|
void |
fetchNextPage() |
|
void |
clear() |
|
java.util.List<SearchResultItem> |
getSearchResultsList() |
|
searchMetadata() |
|
|
void |
setSearchManager(@NonNull SearchManager searchManager) |
|
void |
addSearchResultListener(@NonNull SearchResultListener searchResultListener) |
|
void |
removeSearchResultListener(@NonNull SearchResultListener searchResultListener) |
|
void |
addPlacemarkListener(@NonNull PlacemarkListener placemarkListener) |
|
void |
removePlacemarkListener(@NonNull PlacemarkListener placemarkListener) |
|
void |
setSortByDistance(@NonNull Geometry origin) |
|
void |
setPolylinePosition(@NonNull PolylinePosition position) |
|
void |
resetSort() |
|
void |
setFilterCollection(@Nullable FilterCollection filters) |
|
void |
setFilters(@NonNull java.util.List<BusinessFilter> filters) |
|
void |
setAssetsProvider(@NonNull AssetsProvider provider) |
|
void |
resetAssetsProvider() |
|
void |
selectPlacemark(@NonNull java.lang.String geoObjectId) |
|
java.lang.String |
selectedPlacemarkId() |
|
void |
deselectPlacemark() |
|
void |
forceUpdateIcon(@NonNull java.lang.String geoObjectId, |
|
void |
forceUpdateMapObjects() |
|
void |
obtainAdIcons(boolean enable) |
|
void |
setInsets(int top, |
|
boolean |
isVisible() |
|
void |
setVisible(boolean visible) |
|
boolean |
isValid() |
Methods
submitQuery
|
void submitQuery(@NonNull java.lang.String query, |
Submit search query with search options.
|
Parameters |
|
|
|
User query |
|
|
Search options |
submitQuery
|
void submitQuery(@NonNull java.lang.String query, |
Submit search query with search options near provided geometry.
|
Parameters |
|
|
|
User query. |
|
|
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. |
|
|
Search options. |
searchByUri
|
void searchByUri(@NonNull java.lang.String uri, |
Submit search request for URI resolution.
Allows multiple objects in response.
|
Parameters |
|
|
|
Object URI. |
|
|
Additional search parameters. See mapkit.search.SearchOptions definition for details, and 'searchByURI' method in mapkit.search.SearchManager for currently supported options. |
resubmit
|
void resubmit() |
Manual resubmit.
enableRequestsOnMapMoves
|
void enableRequestsOnMapMoves(boolean enable) |
Enable or disable search requests (resubmits and submits) when the map is moved.
Requests are enabled by default.
|
Parameters |
|
|
|
Enable requests if true, disable otherwise. |
enableMapMoveOnSearchResponse
|
void enableMapMoveOnSearchResponse(boolean enable) |
Enable or disable moving the map on primary search response.
Map moving is enabled by default.
|
Parameters |
|
|
|
Enable map moving if true, disable otherwise. |
hasNextPage
|
boolean hasNextPage() |
Check if more results could be loaded.
fetchNextPage
|
void fetchNextPage() |
Load the next page of results.
clear
|
void clear() |
Clear the displayed search results from the map.
getSearchResultsList
|
@NonNull |
Get the list of search results.
searchMetadata
|
@Nullable |
Get the last search response metadata.
setSearchManager
|
void setSearchManager(@NonNull SearchManager searchManager) |
Set the search manager.
Do not use this method; it is for internal use only.
|
Parameters |
|
|
|
Search manager |
addSearchResultListener
|
void addSearchResultListener(@NonNull SearchResultListener searchResultListener) |
Add the search result listener, which will receive notifications from the search layer.
The class does not retain the object in the 'searchResultListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.
|
Parameters |
|
|
|
Search result listener to add. |
removeSearchResultListener
|
void removeSearchResultListener(@NonNull SearchResultListener searchResultListener) |
Remove search result listener.
|
Parameters |
|
|
|
Search result listener to remove. |
addPlacemarkListener
|
void addPlacemarkListener(@NonNull PlacemarkListener placemarkListener) |
Add a placemark listener, which will receive notifications from the search layer.
The class does not retain the object in the 'placemarkListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.
|
Parameters |
|
|
|
Placemark listener to add. |
removePlacemarkListener
|
void removePlacemarkListener(@NonNull PlacemarkListener placemarkListener) |
Remove placemark listener
|
Parameters |
|
|
|
Placemark listener to remove. |
setSortByDistance
|
void setSortByDistance(@NonNull Geometry origin) |
Set sort order of the results by distance from given geometry.
setPolylinePosition
|
void setPolylinePosition(@NonNull PolylinePosition position) |
When sorting by distance from polyline sets position on this polyline.
Has the same effect as sorting by distance from the sub-polyline from position to the end of the polyline. Throws if no polyline is set or position is out of range.
|
Parameters |
|
|
|
new polyline position value |
resetSort
|
void resetSort() |
Reset the sort if it was previously set.
setFilterCollection
|
void setFilterCollection(@Nullable FilterCollection filters) |
Set search filters.
|
Parameters |
|
|
|
Business filters |
setFilters
|
@Deprecated |
Alert
Use } instead.
setAssetsProvider
|
void setAssetsProvider(@NonNull AssetsProvider provider) |
Set a custom assets provider, which provides images, sizes and icon styles for placemarks.
The class does not retain the object in the 'provider' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.
|
Parameters |
|
|
|
Assets provider (must not be null) |
resetAssetsProvider
|
void resetAssetsProvider() |
Reset the assets provider to default.
selectPlacemark
|
void selectPlacemark(@NonNull java.lang.String geoObjectId) |
Select the placemark by ID.
|
Parameters |
|
|
|
Placemark identifier |
selectedPlacemarkId
|
@Nullable |
Selected placemark ID.
|
Returns |
|
Placemark identifier if any placemark is selected, otherwise none. |
deselectPlacemark
|
void deselectPlacemark() |
Deselect all placemarks.
forceUpdateIcon
|
void forceUpdateIcon(@NonNull java.lang.String geoObjectId, |
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 |
|
|
|
Placemark identifier |
|
|
Icon type |
|
|
Icon image |
|
|
Icon style |
forceUpdateMapObjects
|
void forceUpdateMapObjects() |
Force reloading all visible pins from AssetProvider.
Use when there is a reason to update ALL the icons simultaneously (for example icon theme change, day/night mode, and other). 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.
obtainAdIcons
|
void obtainAdIcons(boolean enable) |
If enabled, the search layer will obtain and set advertising icons without asking AssetsProvider.
|
Parameters |
|
|
|
Enable mode if true, disable otherwise |
setInsets
|
void setInsets(int top, |
Apply insets (in pixels) to the screen.
If inset is not zero, search in the cut-off area will not be performed.
|
Parameters |
|
|
|
Top inset. |
|
|
Left inset. |
|
|
Bottom inset. |
|
|
Right inset. |
isVisible
|
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, and other) are executed as usual.
setVisible
|
void setVisible(boolean visible) |
isValid
|
boolean isValid() |
Tells if this SearchLayer is valid or not.
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.