Style

public final class Style

This class provides a container for tiles sources information and map layers.

  • A collection of map’s tile sources.

    This collection is a container of TilesDefinitions, in which json meta-data and important information about the tiles sources is stored. For example, minZoom, maxZoom, type and tile endpoints.

    Declaration

    Swift

    public let sources: SourceCollection
  • An Array of the map Layers included in a given style.

    Map layers are map elements, for example: Borders, Background, Traffic Incidents, Markers, Labels, etc. Each element of the array contains all the information needed to render a layer. Note that a single element of a map, such as a road, may consist of several layers. You can hide specific map layers to get the level of detail you need and highlight the layers that are important for your use case. For example, you can toggle the visibility of the background layer using layersForRegexp(pattern:):

     let layers = try? map.layersForRegexp(pattern: NSRegularExpression(pattern: "background", options: []))
     layers?.forEach { $0.isVisible = false } // The background layer won't show on the map.
     layers?.forEach { $0.isVisible = true } // The background layer shows on the map.
    

    Declaration

    Swift

    public var layers: [Layer]
  • Fetches an Array of Layers based on the given regex pattern.

    The regex is applied to the Layer.id property.

    • Example:

      let roads = NSRegularExpression(pattern: ".*[rR]oad.*", options: []))
      mapView.map.layersForRegexp(pattern: roads)
      

    Declaration

    Swift

    public func layersForRegex(pattern: NSRegularExpression) -> [Layer]

    Parameters

    pattern

    Regex pattern.

    Return Value

    Instances of fetched Layer.