Class YMKSearchLayer

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.

Instance Methods

- addPlacemarkListenerWithPlacemarkListener:

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

- addSearchResultListenerWithSearchResultListener:

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

- clear

Clear the displayed search results from the map.

- deselectPlacemark

Deselect all placemarks.

- enableMapMoveOnSearchResponseWithEnable:

Enable or disable moving the map on primary search response.

- enableResubmitsOnMapMovesWithEnable:

Enable or disable search resubmits when the map is moved.

- fetchNextPage

Load the next page of results.

- forceUpdateIconWithGeoObjectId:iconType:image:style:

Update the icon image for each suitable placemark.

- forceUpdateMapObjects

Force reloading all visible pins from AssetProvider.

- getSearchResultsList

Get the list of search results.

- hasNextPage

Check if more results could be loaded.

- obtainAdIconsWithEnable:

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

- removePlacemarkListenerWithPlacemarkListener:

Remove placemark listener.

- removeSearchResultListenerWithSearchResultListener:

Remove search result listener.

- resetAssetsProvider

Reset the assets provider to default.

- resolveUriWithUri:searchOptions:

Submit search request for URI resolution.

- resubmit

Manual resubmit.

- searchByOidWithOid:searchOptions:

Submit search request by organization ID.

- searchByUriWithUri:searchOptions:

Submit search request for URI resolution.

- searchMetadata

Get the last search response metadata.

- selectedPlacemarkId

Selected placemark ID.

- selectPlacemarkWithGeoObjectId:

Select the placemark by ID.

- setAssetsProviderWithProvider:

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

- setBaseZIndexWithZIndex:

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

- setBitmapDownloaderWithBitmapDownloader:

Set the bitmap downloader.

- setFiltersWithFilters:

Set search filters.

- setInsetsWithTop:left:bottom:right:

Apply insets (in pixels) to the screen.

- setSearchManagerWithSearchManager:

Set the search manager.

- setSortByDistanceWithOrigin:

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

- setSortByRank

Set sort order of the results by search rank.

- submitQueryWithQuery:geometry:searchOptions:

Submit search query with search options near provided geometry.

- submitQueryWithQuery:searchOptions:

Submit search query with search options.

Properties

valid

Tells if this object is valid or no.

visible

Search layer visibility.

Method Detail

-addPlacemarkListenerWithPlacemarkListener:

- (void)addPlacemarkListenerWithPlacemarkListener:(nonnull id< YMKSearchLayerTapHandler >)placemarkListener 

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

Parameters:
placemarkListener

Placemark listener to add.

-addSearchResultListenerWithSearchResultListener:

- (void)addSearchResultListenerWithSearchResultListener:(nonnull id< YMKSearchLayerResponseHandler >)searchResultListener 

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

Parameters:
searchResultListener

Search result listener to add.

-clear

- (void)clear

Clear the displayed search results from the map.

-deselectPlacemark

- (void)deselectPlacemark

Deselect all placemarks.

-enableMapMoveOnSearchResponseWithEnable:

- (void)enableMapMoveOnSearchResponseWithEnable:(BOOL)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.

-enableResubmitsOnMapMovesWithEnable:

- (void)enableResubmitsOnMapMovesWithEnable:(BOOL)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

- (void)fetchNextPage

Load the next page of results.

-forceUpdateIconWithGeoObjectId:iconType:image:style:

- (void)forceUpdateIconWithGeoObjectId:(nonnull NSString *)geoObjectId
                              iconType:(YMKPlacemarkIconType)iconType
                                 image:(nonnull UIImage *)image
                                 style:(nonnull YMKIconStyle *)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

- (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

- (nonnull NSArray< YMKSearchResultItem * > *)getSearchResultsList

Get the list of search results.

-hasNextPage

- (BOOL)hasNextPage

Check if more results could be loaded.

-obtainAdIconsWithEnable:

- (void)obtainAdIconsWithEnable:(BOOL)enable 

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

Parameters:
enable

Enable mode if true, disable otherwise

-removePlacemarkListenerWithPlacemarkListener:

- (void)removePlacemarkListenerWithPlacemarkListener:(nonnull id< YMKSearchLayerTapHandler >)placemarkListener 

Remove placemark listener.

Parameters:
placemarkListener

Placemark listener to remove.

-removeSearchResultListenerWithSearchResultListener:

- (void)removeSearchResultListenerWithSearchResultListener:(nonnull id< YMKSearchLayerResponseHandler >)searchResultListener 

Remove search result listener.

Parameters:
searchResultListener

Search result listener to remove.

-resetAssetsProvider

- (void)resetAssetsProvider

Reset the assets provider to default.

-resolveUriWithUri:searchOptions:

- (void)resolveUriWithUri:(nonnull NSString *)uri
            searchOptions:(nonnull YMKSearchOptions *)searchOptions 

Submit search request for URI resolution.

Parameters:
uri

Object URI.

searchOptions

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

-resubmit

- (void)resubmit

Manual resubmit.

-searchByOidWithOid:searchOptions:

- (void)searchByOidWithOid:(nonnull NSString *)oid
             searchOptions:(nonnull YMKSearchOptions *)searchOptions 

Submit search request by organization ID.

Parameters:
oid

ID of organization.

searchOptions

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

-searchByUriWithUri:searchOptions:

- (void)searchByUriWithUri:(nonnull NSString *)uri
             searchOptions:(nonnull YMKSearchOptions *)searchOptions 

Submit search request for URI resolution.

Allows multiple objects in response.
Parameters:
uri

Object URI.

searchOptions

Additional search parameters. See YMKSearchOptions definition for details, and 'searchByURI' method in YMKSearchManager for currently supported options.

-searchMetadata

- (nullable YMKSearchMetadata *)searchMetadata

Get the last search response metadata.

-selectPlacemarkWithGeoObjectId:

- (void)selectPlacemarkWithGeoObjectId:(nonnull NSString *)geoObjectId 

Select the placemark by ID.

Parameters:
geoObjectId

Placemark identifier

-selectedPlacemarkId

- (nullable NSString *)selectedPlacemarkId

Selected placemark ID.

Returns:

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

-setAssetsProviderWithProvider:

- (void)setAssetsProviderWithProvider:(nonnull id< YMKAssetsProvider >)provider 

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

Parameters:
provider

Assets provider (must not be null)

-setBaseZIndexWithZIndex:

- (void)setBaseZIndexWithZIndex:(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].

-setBitmapDownloaderWithBitmapDownloader:

- (void)setBitmapDownloaderWithBitmapDownloader:(nonnull YMKSearchBitmapDownloader *)bitmapDownloader 

Set the bitmap downloader.

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

Bitmap downloader

-setFiltersWithFilters:

- (void)setFiltersWithFilters:(nonnull NSArray< YMKSearchBusinessFilter * > *)filters 

Set search filters.

Parameters:
filters

Business filters

-setInsetsWithTop:left:bottom:right:

- (void)setInsetsWithTop:(NSUInteger)top
                    left:(NSUInteger)left
                  bottom:(NSUInteger)bottom
                   right:(NSUInteger)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.

-setSearchManagerWithSearchManager:

- (void)setSearchManagerWithSearchManager:(nonnull YMKSearchManager *)searchManager 

Set the search manager.

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

Search manager

-setSortByDistanceWithOrigin:

- (void)setSortByDistanceWithOrigin:(nonnull YMKGeometry *)origin 

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

Parameters:
origin

Geometry to sort by.

-setSortByRank

- (void)setSortByRank

Set sort order of the results by search rank.

-submitQueryWithQuery:geometry:searchOptions:

- (void)submitQueryWithQuery:(nonnull NSString *)query
                    geometry:(nonnull YMKGeometry *)geometry
               searchOptions:(nonnull YMKSearchOptions *)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.

-submitQueryWithQuery:searchOptions:

- (void)submitQueryWithQuery:(nonnull NSString *)query
               searchOptions:(nonnull YMKSearchOptions *)searchOptions 

Submit search query with search options.

Parameters:
query

User query

searchOptions

Search options

Property Detail

valid

(assign, readonly, getter=isValid) BOOL valid

Tells if this object is valid or no.

Any method called on an invalid object will throw an exception. The object 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.

visible

(assign, readwrite, getter=isVisible) BOOL visible

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.