MMKMap

class MMKMap : NSObject

The object that is used to interact with the map.

Summary

Instance methods

func cameraPosition(with geometry: MMKGeometry) -> MMKCameraPosition
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: MMKGeometry,
                  focus focusRect: MMKScreenRect) -> MMKCameraPosition
Calculates the camera position that projects the specified geometry into the custom focusRect

func cameraPosition(with geometry: MMKGeometry,
                          azimuth: Float,
                             tilt: Float,
                  focus focusRect: MMKScreenRect?) -> MMKCameraPosition

func visibleRegion(with cameraPosition: MMKCameraPosition) -> MMKVisibleRegion

func move(with cameraPosition: MMKCameraPosition,
                    animation: MMKAnimation,
               cameraCallback: MMKMapCameraCallback? = nil)
Changes camera position

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

func addInputListener(with inputListener: MMKMapInputListener)
Adds input listeners

func removeInputListener(with inputListener: MMKMapInputListener)
Removes input listeners

func addCameraListener(with cameraListener: MMKMapCameraListener)
Adds camera listeners

func removeCameraListener(with cameraListener: MMKMapCameraListener)
Removes camera listeners

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

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

func removeTapListener(with tapListener: MMKLayersGeoObjectTapListener)
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: MMKGeoObjectSelectionMetadata)
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() -> MMKProjection
Provides map projection

func wipe()
Erases tiles, caches, etc

func addTileLayer(withLayerId layerId: String,
                         layerOptions: MMKLayerOptions,
                 createTileDataSource: @escaping MMKCreateTileDataSource) -> MMKLayer
Adds tile layer

Properties

var cameraPositionMMKCameraPosition { get }

var visibleRegionMMKVisibleRegion { get }

var cameraBoundsMMKCameraBounds { 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 mapTypeMMKMapType { get set }
Sets the base map type

var mapObjectsMMKMapObjectCollection { get }

var logoMMKLogo { get }
Mappable logo object

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

var modeMMKMapMode { 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: MMKGeometry) -> MMKCameraPosition

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: MMKGeometry,
                  focus focusRect: MMKScreenRect) -> MMKCameraPosition

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


cameraPosition(with:azimuth:tilt:focus:)

func cameraPosition(with geometry: MMKGeometry,
                          azimuth: Float,
                             tilt: Float,
                  focus focusRect: MMKScreenRect?) -> MMKCameraPosition

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: MMKCameraPosition) -> MMKVisibleRegion

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: MMKCameraPosition,
                    animation: MMKAnimation,
               cameraCallback: MMKMapCameraCallback? = 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: MMKCameraPosition)

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


addInputListener(with:)

func addInputListener(with inputListener: MMKMapInputListener)

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: MMKMapInputListener)

Removes input listeners.


addCameraListener(with:)

func addCameraListener(with cameraListener: MMKMapCameraListener)

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: MMKMapCameraListener)

Removes camera listeners.


setMapLoadedListenerWith(_:)

func setMapLoadedListenerWith( mapLoadedListener: MMKMapLoadedListener_?)

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: MMKLayersGeoObjectTapListener)

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: MMKLayersGeoObjectTapListener)

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: MMKGeoObjectSelectionMetadata)

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

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: MMKLayerOptions,
                 createTileDataSource: @escaping MMKCreateTileDataSource) -> MMKLayer

Adds tile layer.


Properties

cameraPosition

var cameraPosition: MMKCameraPosition { get }

Returns

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


visibleRegion

var visibleRegion: MMKVisibleRegion { 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: MMKCameraBounds { 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: MMKMapType { get set }

Sets the base map type.


mapObjects

var mapObjects: MMKMapObjectCollection { get }

Returns

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


var logo: MMKLogo { get }

Mappable logo object.


poiLimit

var poiLimit: NSNumber? { get set }

Limits the number of visible basemap POIs.

Optional property, can be nil.


mode

var mode: MMKMapMode { 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.