• Provides access to the map model, including the camera, style, observable map events, and querying rendered features.

    If you have a MapView you can access the MapboxMap instance via mapboxMap property.

    Use style property to access runtime styling API, for example:

      mapboxMap.style.uri = .satelliteStreets
    

    Use on-prefixed properties to subscribe to map events, for example:

       // Holds resources allocated for subscriptions.
       var cancelables = Set<AnyCancelable>()
    
       // Observe every occurrence of CameraChanged event.
       mapboxMap.onCameraChanged.observe { event in
            print("Current camera state: \(event.cameraState)")
       }.store(in: &cancelables)
    
       // Observe only the next occurrence of MapLoaded event.
       mapboxMap.onMapLoaded.observeNext { event in
           print("Map is loaded at: \(event.timeInterval.end)")
       }.store(in: &cancelables)
    

    The AnyCancelable object returned from observe(_:) or observeNext(_:) holds the resources allocated for the subscription and can be used to cancel it. If the cancelable object is deallocated, the subscription will be cancelled immediately.

    The simplified diagram of the events emitted by the map is displayed below.

    ┌─────────────┐               ┌─────────┐                   ┌──────────────┐
     Application                   Map                      ResourceLoader
    └──────┬──────┘               └────┬────┘                   └───────┬──────┘
                                                                      
           ├───────setStyleURI────────▶│                                
                                      ├───────────get style───────────▶│
                                                                      
                                      │◀─────────style data────────────┤
                                                                      
                                      ├─parse style─┐                  
                                                                     
                 StyleDataLoaded      ◀─────────────┘                  
           │◀───────type: Style────────┤                                
                                      ├─────────get sprite────────────▶│
                                                                      
                                      │◀────────sprite data────────────┤
                                                                      
                                      ├──────parse sprite───────┐      
                                                                     
                 StyleDataLoaded      ◀─────────────────────────┘      
           │◀──────type: Sprite────────┤                                
                                      ├─────get source TileJSON(s)────▶│
                                                                      
                SourceDataLoaded      │◀─────parse TileJSON data───────┤
           │◀─────type: Metadata───────┤                                
                                                                      
                                                                      
                 StyleDataLoaded                                      
           │◀──────type: Sources───────┤                                
                                      ├──────────get tiles────────────▶│
                                                                      
           │◀───────StyleLoaded────────┤                                
                                                                      
                SourceDataLoaded      │◀─────────tile data─────────────┤
           │◀───────type: Tile─────────┤                                
                                                                      
                                                                      
           │◀────RenderFrameStarted────┤                                
                                      ├─────render─────┐               
                                                                     
                                      ◀────────────────┘               
           │◀───RenderFrameFinished────┤                                
                                      ├──render, all tiles loaded──┐   
                                                                     
                                      ◀────────────────────────────┘   
           │◀────────MapLoaded─────────┤                                
                                                                      
                                                                      
           │◀─────────MapIdle──────────┤                                
                                ─── ─┴─ ───                          
                                  offline                            
                                ─── ─┬─ ───                          
                                                                      
           ├─────────setCamera────────▶│                                
                                      ├───────────get tiles───────────▶│
                                                                      
                                      │┌                 
           │◀─────────MapIdle──────────┤   waiting for connectivity    
                                      ││  Map renders cached data      
                                                       
                                                                      
    

    Important

    MapboxMap should only be used from the main thread.
    See more

    Declaration

    Swift

    public final class MapboxMap : StyleManager
  • Undocumented

    See more

    Declaration

    Swift

    public struct CameraState : Codable, Hashable
  • Undocumented

    See more

    Declaration

    Swift

    public struct CameraOptions : Codable, Hashable
  • Holds information about camera bounds.

    See more

    Declaration

    Swift

    public struct CameraBounds : Hashable
  • Holds options to be used for setting camera bounds.

    See more

    Declaration

    Swift

    public struct CameraBoundsOptions : Hashable