Classes
The following classes are available globally.
-
Class to add a key for the map. The key must be injected before a MapView can be used.
- Example: “” func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { MapsDisplayService.apiKey = “MAP_KEY” […] return true }
See more- Important: This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
final public class MapsDisplayService
-
Default implementation of
See moreCopyrightsService.Declaration
Swift
final public class TomTomCopyrightsService : CopyrightsService -
Allows the user to configure the initial parameters of the map.
MapOptionsis used in conjunction withMapViewinitialization, i.e: When creating aMapView, it is possible to pass aMapOptionsobject to configure theMapViewbefore it is showing on the screen, for example, creating aMapViewobject with the default TomTom style, and a dark style mode:let mapOptions = MapOptions(mapStyle: .defaultStyle, apiKey: "your-key", styleMode: .dark)let mapView = MapView(mapOptions: mapOptions)Creating a
See moreMapViewwithout passing aMapOptionsobject, will result in theMapViewbeing created using the deafult values. In such case, the API Key that will be used for the map will be taken fromMapsDisplayService.apiKey.Declaration
Swift
public class MapOptions : NSObject
-
The
See moreLayerprotocol that represents map layer.Declaration
Swift
public class Layer
-
This class provides a container for tiles sources information and map layers.
See moreDeclaration
Swift
public final class Style
-
Represents the circle on the map.
See moreDeclaration
Swift
public class Circle : Annotation
-
Represents the line on the map.
See moreDeclaration
Swift
public class Line : Annotation
-
Represents the marker on the map.
See moreDeclaration
Swift
public class Marker : Annotation
-
Options that defines inner polygon. Can be used with
PolygonOverlayOptions.See moreImportant
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class InnerPolygonOptions : AnnotationOptions
-
A polygon overlay can be built by setting the outer area color and adding inner polygons. Only one inner polygon is supported, but the inner polygons can be nested. Example:
let innerOptions = InnerPolygonOptions(fillColor: .red coordinates: coordinates) innerOptions.nestedPolygonOptions = InnerPolygonOptions( fillColor: UIColor.blue, coordinates: coordinates ) let polygonOptions = PolygonOverlayOptions(outerColor: .green, innerPolygonOptions: innerOptions) try? mapView.map.addPolygonOverlay(options: polygonOptions)}
See moreImportant
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class PolygonOverlay : Annotation
-
Options for creating a
PolygonOverlay.See moreImportant
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class PolygonOverlayOptions : AnnotationOptions
-
Represents the polygon on the map.
See moreDeclaration
Swift
public class Polygon : Annotation
-
A
Routerepresentation which can be added and displayed on the map.To show a
Routeon the map, call theTomTomMap.addRoute(RouteOptions)method. You can configure its shape and appearance with theRouteOptionsclass. Drawing aRouteon the map requires a list with coordinates of theRoutepoints.See moreImportant
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class Route
-
The
MapViewobject to wrap the underlying map renderer.It contains the map created by the renderer in the view hierarchy and provides UI and view life-cycle functionalities. The view can be created programmatically, via xib or storyboards.
For example, displaying a simple
MapViewprogrammatically using a constraints-based layout:Initialization:
lazy var mapView: MapView = { let mapOptions = MapOptions(mapStyle: .defaultStyle, apiKey: "your-key") let mapView = MapView(mapOptions: mapOptions) return mapView }()Layout:
mapView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(mapView) NSLayoutConstraint.activate([ mapView.widthAnchor.constraint(equalTo: view.widthAnchor), mapView.heightAnchor.constraint(equalTo: view.heightAnchor), ])Setting up the receival of life-cycle events and updates, as well as setting the initial zoom and position of the map view:
mapView.delegate = self mapView.cameraUpdate = .init(position: .AMSTERDAM, zoom: 13)There will also be a need to conform your
See moreUIViewControllertoMapViewDelegateand implement the required methods.Declaration
Swift
@objc open class MapView : UIView
-
The
TomTomMapclass serves as the foundational class, acting as the primary gateway for integrating a multitude of map-related features. It offers a rich set of functionalities enabling developer interaction with the map and customizing its behavior.TomTomMapcan be accessed in several ways through theMapViewclass:- Through the property
mapView.map. - By calling
mapView.getMapAsync, i.e.,mapView.getMapAsync { map in // do something with map } - By assigning
mapView.onMapReadyCallback, i.e.,mapView.onMapReadyCallback = { map in // do something with map } - By defining
mapView(_:, onMapReady:)through theMapDelegate, i.e.,func mapView(_: MapView, onMapReady map: TomTomMap) { // do something with the map }In most cases, the preferred way to access the map would be through the propertymapView.map, but in some cases where the map should be ready first, such as when callingshowVehicleRestrictions(vehicle:)the preferred way would bemapView.getMapAsyncormapView.onMapReadyCallback.
Declaration
Swift
public class TomTomMap : AnnotationsActions, RouteActions, MapActionsextension TomTomMap: CameraActionsextension TomTomMap: RenderedFeatureActionsextension TomTomMap: VehicleActions, LocationActions - Through the property
Classes Reference