MGLStyle

@interface MGLStyle : NSObject

The proxy object for the current map style for customization purposes and a set of convenience methods for creating style URLs of default styles provided by Mapbox. Learn more about Mapbox default styles.

  • Returns the URL to version 8 of the Mapbox Streets style.

    Streets is a general-purpose style with detailed road and transit networks.

    MGLMapView and MGLTilePyramidOfflineRegion use Mapbox Streets when no style is specified explicitly.

    Declaration

    Objective-C

    + (nonnull NSURL *)streetsStyleURL;

    Swift

    class func streetsStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Streets style.

    Streets is a general-purpose style with detailed road and transit networks.

    MGLMapView and MGLTilePyramidOfflineRegion use Mapbox Streets when no style is specified explicitly.

    Declaration

    Objective-C

    + (nonnull NSURL *)streetsStyleURLWithVersion:(NSInteger)version;

    Swift

    class func streetsStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • Returns the URL to version 8 of the Mapbox Emerald style.

    Emerald is a tactile style with subtle textures and dramatic hillshading.

    Declaration

    Objective-C

    + (nonnull NSURL *)emeraldStyleURL;

    Swift

    class func emeraldStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Outdoors style.

    Outdoors is a general-purpose style tailored to outdoor activities.

    Declaration

    Objective-C

    + (nonnull NSURL *)outdoorsStyleURLWithVersion:(NSInteger)version;

    Swift

    class func outdoorsStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • Returns the URL to version 8 of the Mapbox Light style.

    Light is a subtle, light-colored backdrop for data visualizations.

    Declaration

    Objective-C

    + (nonnull NSURL *)lightStyleURL;

    Swift

    class func lightStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Light style.

    Light is a subtle, light-colored backdrop for data visualizations.

    Declaration

    Objective-C

    + (nonnull NSURL *)lightStyleURLWithVersion:(NSInteger)version;

    Swift

    class func lightStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • Returns the URL to version 8 of the Mapbox Dark style.

    Dark is a subtle, dark-colored backdrop for data visualizations.

    Declaration

    Objective-C

    + (nonnull NSURL *)darkStyleURL;

    Swift

    class func darkStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Dark style.

    Dark is a subtle, dark-colored backdrop for data visualizations.

    Declaration

    Objective-C

    + (nonnull NSURL *)darkStyleURLWithVersion:(NSInteger)version;

    Swift

    class func darkStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • Returns the URL to version 8 of the Mapbox Satellite style.

    Satellite is high-resolution satellite and aerial imagery.

    Declaration

    Objective-C

    + (nonnull NSURL *)satelliteStyleURL;

    Swift

    class func satelliteStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Satellite style.

    Satellite is high-resolution satellite and aerial imagery.

    Declaration

    Objective-C

    + (nonnull NSURL *)satelliteStyleURLWithVersion:(NSInteger)version;

    Swift

    class func satelliteStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • Returns the URL to version 8 of the Mapbox Satellite Streets style.

    Satellite Streets combines the high-resolution satellite and aerial imagery of Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox Streets.

    Declaration

    Objective-C

    + (nonnull NSURL *)hybridStyleURL;

    Swift

    class func hybridStyleURL() -> NSURL
  • Returns the URL to the given version of the Mapbox Satellite Streets style.

    Satellite Streets combines the high-resolution satellite and aerial imagery of Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox Streets.

    Declaration

    Objective-C

    + (nonnull NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version;

    Swift

    class func satelliteStreetsStyleURLWithVersion(version: Int) -> NSURL

    Parameters

    version

    The style’s latest released version. As of publication, the current version is 9.

  • The name of the style.

    You can customize the style’s name in Mapbox Studio.

    Declaration

    Objective-C

    @property (readonly, copy, atomic, nullable) NSString *name;

    Swift

    var name: String? { get }
  • Returns a layer that conforms to MGLStyleLayer if any layer with the given identifier was found.

    Declaration

    Objective-C

    - (nullable MGLStyleLayer *)layerWithIdentifier:(nonnull NSString *)identifier;

    Swift

    func layerWithIdentifier(identifier: String) -> MGLStyleLayer?

    Return Value

    An instance of a concrete subclass of MGLStyleLayer associated with the given identifier.

  • Returns a source if any source with the given identifier was found.

    Declaration

    Objective-C

    - (nullable MGLSource *)sourceWithIdentifier:(nonnull NSString *)identifier;

    Swift

    func sourceWithIdentifier(identifier: String) -> MGLSource?

    Return Value

    An instance of a concrete subclass of MGLSource associated with the given identifier.

  • Adds a new layer on top of existing layers.

    Declaration

    Objective-C

    - (void)addLayer:(nonnull MGLStyleLayer *)layer;

    Swift

    func addLayer(layer: MGLStyleLayer)

    Parameters

    layer

    The layer object to add to the map view. This object must be an instance of a concrete subclass of MGLStyleLayer.

  • Inserts a new layer below another layer.

    Declaration

    Objective-C

    - (void)insertLayer:(nonnull MGLStyleLayer *)layer
             belowLayer:(nonnull MGLStyleLayer *)otherLayer;

    Swift

    func insertLayer(layer: MGLStyleLayer, belowLayer otherLayer: MGLStyleLayer)

    Parameters

    layer

    Layer to be inserted.

    belowLayer

    A layer that’s already on the map view.

  • Removes a layer from the map view.

    Declaration

    Objective-C

    - (void)removeLayer:(nonnull MGLStyleLayer *)layer;

    Swift

    func removeLayer(layer: MGLStyleLayer)

    Parameters

    layer

    The layer object to remove from the map view. This object must conform to the MGLStyleLayer protocol.

  • Adds a new source to the map view.

    Declaration

    Objective-C

    - (void)addSource:(nonnull MGLSource *)source;

    Swift

    func addSource(source: MGLSource)

    Parameters

    source

    The source to add to the map view.

  • Removes a source from the map view.

    Declaration

    Objective-C

    - (void)removeSource:(nonnull MGLSource *)source;

    Swift

    func removeSource(source: MGLSource)

    Parameters

    source

    The source to remove.

  • Currently active style classes, represented as an array of string identifiers.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        NSArray<NSString *> *_Nonnull styleClasses;

    Swift

    var styleClasses: [String] { get set }
  • Returns a Boolean value indicating whether the style class with the given identifier is currently active.

    Declaration

    Objective-C

    - (BOOL)hasStyleClass:(nonnull NSString *)styleClass;

    Swift

    func hasStyleClass(styleClass: String) -> Bool

    Parameters

    styleClass

    The style class to query for.

    Return Value

    Whether the style class is currently active.

  • Activates the style class with the given identifier.

    Declaration

    Objective-C

    - (void)addStyleClass:(nonnull NSString *)styleClass;

    Swift

    func addStyleClass(styleClass: String)

    Parameters

    styleClass

    The style class to activate.

  • Deactivates the style class with the given identifier.

    Declaration

    Objective-C

    - (void)removeStyleClass:(nonnull NSString *)styleClass;

    Swift

    func removeStyleClass(styleClass: String)

    Parameters

    styleClass

    The style class to deactivate.

  • Adds or overrides an image used by the style’s layers.

    To use an image in a style layer, give it a unique name using this method, then set the iconImage property of an MGLSymbolStyleLayer object to that name.

    Declaration

    Objective-C

    - (void)setImage:(nonnull UIImage *)image forName:(nonnull NSString *)name;

    Swift

    func setImage(image: NSImage, forName name: String)

    Parameters

    image

    The image for the name.

    name

    The name of the image to set to the style.

  • Removes a name and its associated image from the style.

    Declaration

    Objective-C

    - (void)removeImageForName:(nonnull NSString *)name;

    Swift

    func removeImageForName(name: String)

    Parameters

    name

    The name of the image to remove.