YMKMap

class YMKMap : NSObject

The object that is used to interact with the map.

Summary

Instance methods

func cameraPosition(with geometry: YMKGeometry) -> YMKCameraPosition
Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and { tilt} camera parameters || || ##func [cameraPosition](#camerapositionwithfocus)(with geometry: _[YMKGeometry](./YMKGeometry.md)_,## ##                  focus focusRect: _[YMKScreenRect](./YMKScreenRect.md)_?) -\> _[YMKCameraPosition](./YMKCameraPosition.md)_## Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and { tilt} camera parameters

func cameraPosition(with geometry: YMKGeometry,
                  focus focusRect: YMKScreenRect?,
                          azimuth: NSNumber?) -> YMKCameraPosition
Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and { tilt} camera parameters || || ##func [cameraPosition](#camerapositionwithfocusazimuthtilt)(with geometry: _[YMKGeometry](./YMKGeometry.md)_,## ##                  focus focusRect: _[YMKScreenRect](./YMKScreenRect.md)_?,## ##                          azimuth: NSNumber?,## ##                             tilt: NSNumber?) -\> _[YMKCameraPosition](./YMKCameraPosition.md)_## Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and { tilt} camera parameters

func visibleRegion(with cameraPosition: YMKCameraPosition) -> YMKVisibleRegion

func move(with cameraPosition: YMKCameraPosition)
Changes the camera position

func move(with cameraPosition: YMKCameraPosition, animation: YMKAnimation?)
Changes the camera position

func move(with cameraPosition: YMKCameraPosition,
                    animation: YMKAnimation?,
               cameraCallback: YMKMapCameraCallback? = nil)
Changes the camera position

func addInputListener(with inputListener: any YMKMapInputListener)
Adds input listeners

func removeInputListener(with inputListener: any YMKMapInputListener)
Removes input listeners

func addCameraListener(with cameraListener: any YMKMapCameraListener)
Adds camera listeners

func removeCameraListener(with cameraListener: any YMKMapCameraListener)
Removes camera listeners

func setMapLoadedListenerWith(_ mapLoadedListener: (any YMKMapLoadedListener)?)
Sets a map loaded listener

func addTapListener(with tapListener: any YMKLayersGeoObjectTapListener)
Adds a tap listener that is used to obtain brief geo object info

func removeTapListener(with tapListener: any YMKLayersGeoObjectTapListener)
Removes a tap listener that is used to obtain brief geo object info

func deselectGeoObject()
Resets the currently selected geo object

func selectGeoObject(withSelectionMetaData selectionMetaData: YMKGeoObjectSelectionMetadata)
Selects a geo object with the specified objectId in the specified layerId

func addIndoorStateListener(with indoorStateListener: any YMKIndoorStateListener)
Subscribe to indoor state change events

func removeIndoorStateListener(with indoorStateListener: any YMKIndoorStateListener)
Unsubscribe from indoor state change events

func setMapStyleWithStyle(_ style: String) -> Bool
Applies JSON style transformations to the map

func setMapStyleWithId(_ id: Int, style: String) -> Bool
Applies JSON style transformations to the map

func resetMapStyles()
Resets all JSON style transformations applied to the map

func set2DMode(withEnable enable: Bool)
Forces the map to be flat

func addObjectLayer(withLayerId layerId: String) -> YMKRootMapObjectCollection
Creates a new independent map object collection linked to the specified layer ID

func projection() -> YMKProjection
Provides map projection

func wipe()
Erases tiles, caches, etc

func addTileLayer(withLayerId layerId: String,
                         layerOptions: YMKLayerOptions,
                 createTileDataSource: @escaping YMKCreateTileDataSource) -> YMKLayer
Adds tile layer

Properties

var cameraPositionYMKCameraPosition { get }

var visibleRegionYMKVisibleRegion { get }

var cameraBoundsYMKCameraBounds { get }

var isNightModeEnabled: Bool { get set }
If enabled, night mode will reduce map brightness and improve contrast

var isZoomGesturesEnabled: Bool { get set }
Enable/disable zoom gestures, for example: - pinch - double tap (zoom in) - tap with two fingers (zoom out)

var isScrollGesturesEnabled: Bool { get set }
Enable/disable scroll gestures, such as the pan gesture

var isTiltGesturesEnabled: Bool { get set }
Enable/disable tilt gestures, such as parallel pan with two fingers

var isRotateGesturesEnabled: Bool { get set }
Enable/disable rotation gestures, such as rotation with two fingers

var isFastTapEnabled: Bool { get set }
Removes the 300 ms delay in emitting a tap gesture

var mapTypeYMKMapType { get set }
Sets the base map type

var mapObjectsYMKRootMapObjectCollection { get }

var logoYMKLogo { get }
Yandex logo object

var poiLimit: NSNumber? { get set }
Limits the number of visible basemap POIs

var isIndoorEnabled: Bool { get set }
Enables/disables indoor plans on the map

var modeYMKMapMode { get set }
Selects one of predefined map style modes optimized for particular use case(transit, driving, etc)

var isHdModeEnabled: Bool { get set }
Enables hd mode of displayed content

var isAwesomeModelsEnabled: Bool { get set }
Enables rich textured 3d content on basemap

var isValid: Bool { get }
Tells if this object is valid or no

Instance methods

cameraPosition(with:)

func cameraPosition(with geometry: YMKGeometry) -> YMKCameraPosition

Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and {``` tilt} camera parameters.

If {``` focusRect} is not provided, the current focus rect is used (or the full view if no focus rect is set).

If {``` azimuth} is not provided, the current {``` cameraPosition.azimuth} is used.

If {``` tilt} is not provided, the current {``` cameraPosition.tilt} is used.

- returns: The computed camera position.

cameraPosition(with:focus:)

func cameraPosition(with geometry: YMKGeometry,
                  focus focusRect: YMKScreenRect?) -> YMKCameraPosition

Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and {``` tilt} camera parameters.

If {``` focusRect} is not provided, the current focus rect is used (or the full view if no focus rect is set).

If {``` azimuth} is not provided, the current {``` cameraPosition.azimuth} is used.

If {``` tilt} is not provided, the current {``` cameraPosition.tilt} is used.

- returns: The computed camera position.

cameraPosition(with:focus:azimuth:)

func cameraPosition(with geometry: YMKGeometry,
                  focus focusRect: YMKScreenRect?,
                          azimuth: NSNumber?) -> YMKCameraPosition

Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and {``` tilt} camera parameters.

If {``` focusRect} is not provided, the current focus rect is used (or the full view if no focus rect is set).

If {``` azimuth} is not provided, the current {``` cameraPosition.azimuth} is used.

If {``` tilt} is not provided, the current {``` cameraPosition.tilt} is used.

- returns: The computed camera position.

cameraPosition(with:focus:azimuth:tilt:)

func cameraPosition(with geometry: YMKGeometry,
                  focus focusRect: YMKScreenRect?,
                          azimuth: NSNumber?,
                             tilt: NSNumber?) -> YMKCameraPosition

Calculates a camera position that projects the specified geometry into the given { focusRect}, using the provided { azimuth} and {``` tilt} camera parameters.

If {``` focusRect} is not provided, the current focus rect is used (or the full view if no focus rect is set).

If {``` azimuth} is not provided, the current {``` cameraPosition.azimuth} is used.

If {``` tilt} is not provided, the current {``` cameraPosition.tilt} is used.

- returns: The computed camera position.

visibleRegion(with:)

func visibleRegion(with cameraPosition: YMKCameraPosition) -> YMKVisibleRegion

Returns

The map region that is visible from the given camera
position. Region IS bounded by latitude limits [-90, 90] and IS NOT
bounded by longitude limits [-180, 180]. If the longitude exceeds its
limits, we see the world's edge and another instance of the world
beyond this edge.


move(with:)

func move(with cameraPosition: YMKCameraPosition)

Changes the camera position. Can cancel a previous unfinished movement.

null}, the camera position changes instantly. - see: mapkit.Animation for more details. - parameter: cameraCallback A function that receives a boolean indicating whether the camera action completed successfully. Invoked when: <ul> <li>The camera action is cancelled (for example, due to a new camera movement request), in which case { false} is passed.

  • The camera action finishes successfully, in which case {``` true} is passed.
  • Parameters

    animation

    Defines animation parameters. If {


    move(with:animation:)

    func move(with cameraPosition: YMKCameraPosition, animation: YMKAnimation?)

    Changes the camera position. Can cancel a previous unfinished movement.

    null}, the camera position changes instantly. - see: mapkit.Animation for more details. - parameter: cameraCallback A function that receives a boolean indicating whether the camera action completed successfully. Invoked when: <ul> <li>The camera action is cancelled (for example, due to a new camera movement request), in which case { false} is passed.

  • The camera action finishes successfully, in which case {``` true} is passed.
  • Parameters

    animation

    Defines animation parameters. If {


    move(with:animation:cameraCallback:)

    func move(with cameraPosition: YMKCameraPosition,
                        animation: YMKAnimation?,
                   cameraCallback: YMKMapCameraCallback? = nil)

    Changes the camera position. Can cancel a previous unfinished movement.

    null}, the camera position changes instantly. - see: mapkit.Animation for more details. - parameter: cameraCallback A function that receives a boolean indicating whether the camera action completed successfully. Invoked when: <ul> <li>The camera action is cancelled (for example, due to a new camera movement request), in which case { false} is passed.

  • The camera action finishes successfully, in which case {``` true} is passed.
  • Parameters

    animation

    Defines animation parameters. If {


    addInputListener(with:)

    func addInputListener(with inputListener: any YMKMapInputListener)

    Adds input listeners.

    The class does not retain the object in the 'inputListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


    removeInputListener(with:)

    func removeInputListener(with inputListener: any YMKMapInputListener)

    Removes input listeners.


    addCameraListener(with:)

    func addCameraListener(with cameraListener: any YMKMapCameraListener)

    Adds camera listeners.

    The class does not retain the object in the 'cameraListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


    removeCameraListener(with:)

    func removeCameraListener(with cameraListener: any YMKMapCameraListener)

    Removes camera listeners.


    setMapLoadedListenerWith(_:)

    func setMapLoadedListenerWith(_ mapLoadedListener: (any YMKMapLoadedListener)?)

    Sets a map loaded listener.

    The class does not retain the object in the 'mapLoadedListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


    addTapListener(with:)

    func addTapListener(with tapListener: any YMKLayersGeoObjectTapListener)

    Adds a tap listener that is used to obtain brief geo object info.

    The class does not retain the object in the 'tapListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


    removeTapListener(with:)

    func removeTapListener(with tapListener: any YMKLayersGeoObjectTapListener)

    Removes a tap listener that is used to obtain brief geo object info.


    deselectGeoObject()

    func deselectGeoObject()

    Resets the currently selected geo object.


    selectGeoObject(withSelectionMetaData:)

    func selectGeoObject(withSelectionMetaData selectionMetaData: YMKGeoObjectSelectionMetadata)

    Selects a geo object with the specified objectId in the specified layerId. If the object is not currently on the screen, it is selected anyway, but the user will not actually see that. You need to move the camera in addition to this call to be sure that the selected object is visible for the user. GeoObjectSelectionMetadata can be extracted from the geo object's metadata container when the user taps on a geo object.


    addIndoorStateListener(with:)

    func addIndoorStateListener(with indoorStateListener: any YMKIndoorStateListener)

    Subscribe to indoor state change events.

    The class does not retain the object in the 'indoorStateListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


    removeIndoorStateListener(with:)

    func removeIndoorStateListener(with indoorStateListener: any YMKIndoorStateListener)

    Unsubscribe from indoor state change events.


    setMapStyleWithStyle(_:)

    func setMapStyleWithStyle(_ style: String) -> Bool

    Applies JSON style transformations to the map. Same as setMapStyle(0, style). Affects VectorMap and Hybrid map types. Set to empty string to clear previous styling. Returns true if the style was successfully parsed, and false otherwise. If the returned value is false, the current map style remains unchanged.


    setMapStyleWithId(_:style:)

    func setMapStyleWithId(_ id: Int, style: String) -> Bool

    Applies JSON style transformations to the map. Replaces previous styling with the specified ID (if such exists). Stylings are applied in an ascending order. Affects VectorMap and Hybrid map types. Set to empty string to clear previous styling with the specified ID. Returns true if the style was successfully parsed, and false otherwise. If the returned value is false, the current map style remains unchanged.


    resetMapStyles()

    func resetMapStyles()

    Resets all JSON style transformations applied to the map.


    set2DMode(withEnable:)

    func set2DMode(withEnable enable: Bool)

    Forces the map to be flat. true - All loaded tiles start showing the "flatten out" animation; all new tiles do not start 3D animation. false - All tiles start showing the "rise up" animation.


    addObjectLayer(withLayerId:)

    func addObjectLayer(withLayerId layerId: String) -> YMKRootMapObjectCollection

    Creates a new independent map object collection linked to the specified layer ID. Sublayers will be added after corresponding sublayers of the topmost layer.


    projection()

    func projection() -> YMKProjection

    Provides map projection


    wipe()

    func wipe()

    Erases tiles, caches, etc. Does not trigger the next frame generation.


    addTileLayer(withLayerId:layerOptions:createTileDataSource:)

    func addTileLayer(withLayerId layerId: String,
                             layerOptions: YMKLayerOptions,
                     createTileDataSource: @escaping YMKCreateTileDataSource) -> YMKLayer

    Adds tile layer.


    Properties

    cameraPosition

    var cameraPosition: YMKCameraPosition { get }

    Returns

    Current camera position. Target position must be within
    latitude [-90, 90] and longitude [-180, 180].


    visibleRegion

    var visibleRegion: YMKVisibleRegion { get }

    Returns

    The map region that is currently visible. Region IS bounded
    by latitude limits [-90, 90] and IS NOT bounded by longitude limits
    [-180, 180]. If the longitude exceeds its limits, we see the world's
    edge and another instance of the world beyond this edge.


    cameraBounds

    var cameraBounds: YMKCameraBounds { get }


    isNightModeEnabled

    var isNightModeEnabled: Bool { get set }

    If enabled, night mode will reduce map brightness and improve contrast.


    isZoomGesturesEnabled

    var isZoomGesturesEnabled: Bool { get set }

    Enable/disable zoom gestures, for example: - pinch - double tap (zoom in) - tap with two fingers (zoom out)


    isScrollGesturesEnabled

    var isScrollGesturesEnabled: Bool { get set }

    Enable/disable scroll gestures, such as the pan gesture.


    isTiltGesturesEnabled

    var isTiltGesturesEnabled: Bool { get set }

    Enable/disable tilt gestures, such as parallel pan with two fingers.


    isRotateGesturesEnabled

    var isRotateGesturesEnabled: Bool { get set }

    Enable/disable rotation gestures, such as rotation with two fingers.


    isFastTapEnabled

    var isFastTapEnabled: Bool { get set }

    Removes the 300 ms delay in emitting a tap gesture. However, a double-tap will emit a tap gesture along with a double-tap.


    mapType

    var mapType: YMKMapType { get set }

    Sets the base map type.


    mapObjects

    var mapObjects: YMKRootMapObjectCollection { get }

    Returns

    List of map objects associated with the map. The layerId for
    this collection can be retrieved via LayerIds.mapObjectsLayerId


    var logo: YMKLogo { get }

    Yandex logo object.


    poiLimit

    var poiLimit: NSNumber? { get set }

    Limits the number of visible basemap POIs.

    Optional property, can be nil.


    isIndoorEnabled

    var isIndoorEnabled: Bool { get set }

    Enables/disables indoor plans on the map. Disabled by default.


    mode

    var mode: YMKMapMode { get set }

    Selects one of predefined map style modes optimized for particular use case(transit, driving, etc). Resets json styles set with setMapStyle. MapMode.Map by deafult.


    isHdModeEnabled

    var isHdModeEnabled: Bool { get set }

    Enables hd mode of displayed content


    isAwesomeModelsEnabled

    var isAwesomeModelsEnabled: Bool { get set }

    Enables rich textured 3d content on basemap.


    isValid

    var isValid: Bool { get }

    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.


    Следующая