YMKMap

class YMKMap : NSObject

The object that is used to interact with the map.

Summary

Instance methods

func cameraPosition(with geometry: YMKGeometry) -> YMKCameraPosition
Calculates the camera position that projects the specified geometry into the current focusRect, or the full view if the focusRect is not set

func cameraPosition(with geometry: YMKGeometry,
                  focus focusRect: YMKScreenRect) -> YMKCameraPosition
Calculates the camera position that projects the specified geometry into the custom focusRect

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

func visibleRegion(with cameraPosition: YMKCameraPosition) -> YMKVisibleRegion

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

func move(with cameraPosition: YMKCameraPosition)
Immediately changes the camera position

func addInputListener(with inputListener: YMKMapInputListener)
Adds input listeners

func removeInputListener(with inputListener: YMKMapInputListener)
Removes input listeners

func addCameraListener(with cameraListener: YMKMapCameraListener)
Adds camera listeners

func removeCameraListener(with cameraListener: YMKMapCameraListener)
Removes camera listeners

func setMapLoadedListenerWith( mapLoadedListener: YMKMapLoadedListener_?)
Sets a map loaded listener

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

func removeTapListener(with tapListener: 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 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 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 }
Undocumented

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 mapObjectsYMKMapObjectCollection { get }

var logoYMKLogo { get }
Yandex logo object

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

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

Instance methods

cameraPosition(with:)

func cameraPosition(with geometry: YMKGeometry) -> YMKCameraPosition

Calculates the camera position that projects the specified geometry into the current focusRect, or the full view if the focusRect is not set.


cameraPosition(with:focus:)

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

Calculates the camera position that projects the specified geometry into the custom focusRect.


cameraPosition(with:azimuth:tilt:focus:)

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

Returns

Camera position that projects the specified geometry into the
custom focusRect, with custom azimuth and tilt camera parameters. If
focus rect is not provided, current focus rect is used.


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:animation:cameraCallback:)

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

Changes camera position. Can cancel a previous unfinished movement.

@see mapkit.Animation for more details. - parameter: cameraCallback A function that takes the bool argument marking the camera action complete. Invoked when:

  • A camera action is cancelled (for example, as a result of a subsequent request for camera movement), passing false as an argument.
  • A camera action finished successfully, passing true as an argument.

Parameters

animation

Required. Defines animation parameters.

cameraCallback

A function that takes the bool argument marking the camera action complete. Invoked when: A camera action is cancelled (for example, as a result of a subsequent request for camera movement), passing false as an argument. A camera action finished successfully, passing true as an argument.


move(with:)

func move(with cameraPosition: YMKCameraPosition)

Immediately changes the camera position. Can cancel a previous unfinished movement.


addInputListener(with:)

func addInputListener(with inputListener: 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: YMKMapInputListener)

Removes input listeners.


addCameraListener(with:)

func addCameraListener(with cameraListener: 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: YMKMapCameraListener)

Removes camera listeners.


setMapLoadedListenerWith(_:)

func setMapLoadedListenerWith( mapLoadedListener: 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: 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: 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.


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.


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 }

Undocumented


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: YMKMapObjectCollection { 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.


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.


Следующая