AMLMapView

public struct AMLMapView : View

The SwiftUI wrapper for MGLMapView

  • Create an instance of AMLMapView

    Declaration

    Swift

    public init(mapState: AMLMapViewState = .init())

    Parameters

    mapState

    Object to track state changes.

  • Declaration

    Swift

    public var body: some View { get }
  • View modifier to enable showing the user’s location on the map.

    To access the user’s locaiton, location access must be enabled in the app, and the user must choose to allow access.

    Declaration

    Swift

    func showUserLocation(_ showLocation: Bool) -> AMLMapView

    Parameters

    showLocation

    Enables showing the user’s location on the map.

    Return Value

    An instance of AMLMapView.

  • View modifier to set the map’s maximum and minimum zoom levels.

    Zoom Level Approximation Reference:

    • 0 -> The Earth
    • 3 -> A continent
    • 4 -> Large islands
    • 6 -> Large rivers
    • 10 -> Large roads
    • 15 -> Buildings

    Important

    The minimum allowable zoom level is 0 and the maximum allowable zoom level is 22. Any value set below 0 or above 22 will revert to 0 or 22 accordingly.

    Declaration

    Swift

    func allowedZoomLevels(_ zoomLevels: ClosedRange<Double>) -> AMLMapView

    Parameters

    zoomLevels

    A closed range of Double where the lower bound is the min and the upper bound the max zoom level.

    Return Value

    An instance of AMLMapView.

  • View modifier to set the map’s maximum zoom level.

    Zoom Level Approximation Reference:

    • 0 -> The Earth
    • 3 -> A continent
    • 4 -> Large islands
    • 6 -> Large rivers
    • 10 -> Large roads
    • 15 -> Buildings

    Important

    The maximum zoom level is 22. Any value set above 22 will revert to 22.

    Declaration

    Swift

    func maxZoomLevel(_ maxZoomLevel: Double) -> AMLMapView

    Parameters

    maxZoomLevel

    The maximum zoom level allowed by the map.

    Return Value

    An instance of AMLMapView.

  • View modifier to set the map’s minimum zoom level.

    Zoom Level Approximation Reference:

    • 0 -> The Earth
    • 3 -> A continent
    • 4 -> Large islands
    • 6 -> Large rivers
    • 10 -> Large roads
    • 15 -> Buildings

    Important

    The minimum allowable zoom level is 0. Any value set below 0 revert to 0.

    Declaration

    Swift

    func minZoomLevel(_ minZoomLevel: Double) -> AMLMapView

    Parameters

    minZoomLevel

    The minimum zoom level allowed by the map.

    Return Value

    An instance of AMLMapView.

  • Provide an SwiftUI view that represents a point on a map.

    Important

    Because the underlying MGLMapView consumes UIImages, this method turns a SwiftUI view into a UIImage. There may be hidden cost to using this. If you experience performance and / or rendering issues, please use the featureImage(_:) view modifier instead.

    Declaration

    Swift

    func featureView<T>(_ view: () -> T) -> AMLMapView where T : View

    Parameters

    view

    The view to be displayed.

    Return Value

    An instance of AMLMapView.

  • Provide an UIImage that represents a point on a map.

    Declaration

    Swift

    func featureImage(_ image: () -> UIImage) -> AMLMapView

    Parameters

    image

    The image to be displayed.

    Return Value

    An instance of AMLMapView.

  • Define the behavior when a feature is tapped.

    The default implementation pans the feature to the center of the screen and presents an AMLCalloutView. Defining an implementation here will override this behavior.

    Declaration

    Swift

    func featureTapped(
        _ implementation: @escaping (
            _ mapView: MGLMapView,
            _ pointFeature: MGLPointFeature
        ) -> Void
    ) -> AMLMapView

    Parameters

    implementation

    Closure provided a MGLMapView and MGLPointFeature. Define your desired behavior on the mapView using information from the pointFeature as needed.

    Return Value

    An instance of AMLMapView.

  • Define the behavior when a feature cluster is tapped.

    The default implementation zooms in on the map. Defining an implementation here will override this behavior.

    Declaration

    Swift

    func featureClusterTapped(
        _ implementation: @escaping (
            _ mapView: MGLMapView,
            _ pointFeatureCluster: MGLPointFeatureCluster
        ) -> Void
    ) -> AMLMapView

    Parameters

    implementation

    Closure provided a MGLMapView and MGLPointFeatureCluster. Define your desired behavior on the mapView using information from the pointFeatureCluster as needed.

    Return Value

    An instance of AMLMapView.

  • Set the position of the compass on the MGLMapView.

    Declaration

    Swift

    func compassPosition(_ position: MGLOrnamentPosition) -> AMLMapView

    Parameters

    position

    MGLOrnamentPosition defining the location.

    Return Value

    An instance of AMLMapView.

  • Set whether the map features should cluster.

    Declaration

    Swift

    func shouldCluster(_ shouldCluster: Bool) -> AMLMapView

    Parameters

    shouldCluster

    Features displayed on the map should cluster. Corresponds to the MGLShapeSourceOption .clustered.

    Return Value

    An instance of AMLMapView.

  • Specifies the maximum zoom level at which to cluster points if clustering is enabled.

    Declaration

    Swift

    func maximumClusterZoomLevel(_ maxZoom: Int) -> AMLMapView

    Parameters

    maxZoom

    The maximum zoom level of clustering. Corresponds to MGLShapeSourceOption .maximumZoomLevelForClustering.

    Return Value

    An instance of AMLMapView.

  • Set the fill color of the circle cluster.

    Declaration

    Swift

    func clusterColor(_ color: UIColor) -> AMLMapView

    Parameters

    color

    The fill color of the circle cluster. Sets the MGLCircleStyleLayer circleColor property.

    Return Value

    An instance of AMLMapView.

  • The text color of the number displayed in the circle cluster.

    Declaration

    Swift

    func clusterNumberColor(_ color: UIColor) -> AMLMapView

    Parameters

    color

    The color of text displaying the number within a cluster. Sets the MGLSymbolStyleLayer textColor property.

    Return Value

    An instance of AMLMapView.

  • Set colors for different cluster steps.

    Declaration

    Swift

    func clusterColorSteps(_ steps: [Int : UIColor]) -> AMLMapView

    Parameters

    steps

    Dictionary representation of cluster color steps where the key is the number of features in a cluster and the value is the color for that corresponding number

    Return Value

    An instance of AMLMapView.

  • Set the radius of each cluster if clustering is enabled.

    Declaration

    Swift

    func clusterRadius(_ radius: Int) -> AMLMapView

    Parameters

    radius

    The cluster radius. Corresponds to the MGLShapeSourceOption .clusterRadius.

    Return Value

    An instance of AMLMapView.