AMLMapCompositeView
public struct AMLMapCompositeView : View
AMLMapView
including standard the view components:
AMLSearchBar
, AMLMapControlView
, and AMLPlaceCellView
.
-
Create a new
AMLMapCompositeView
.To create a full user experience, this leverages
For more layout customizability, use
AMLMapView
directly.Declaration
Swift
public init(viewModel: AMLMapCompositeViewModel = .init())
Parameters
viewModel
The
AMLMapCompositeViewModel
that is configured with aAMLMapViewState
object. Default implementations provided. -
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) -> AMLMapCompositeView
Parameters
showLocation
Enables showing the user’s location on the map.
Return Value
An instance of
AMLMapCompositeView
. -
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>) -> AMLMapCompositeView
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
AMLMapCompositeView
. -
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) -> AMLMapCompositeView
Parameters
maxZoomLevel
The maximum zoom level allowed by the map.
Return Value
An instance of
AMLMapCompositeView
. -
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) -> AMLMapCompositeView
Parameters
minZoomLevel
The minimum zoom level allowed by the map.
Return Value
An instance of
AMLMapCompositeView
. -
Provide an SwiftUI view that represents a point on a map.
Important
Because the underlyingMGLMapView
consumesUIImage
s, this method turns aSwiftUI
view into aUIImage
. There may be hidden cost to using this. If you experience performance and / or rendering issues, please use thefeatureImage(_:)
view modifier instead.Declaration
Swift
func featureView<T>(_ view: () -> T) -> AMLMapCompositeView where T : View
Parameters
view
The view to be displayed.
Return Value
An instance of
AMLMapCompositeView
. -
Provide an UIImage that represents a point on a map.
Declaration
Swift
func featureImage(_ image: () -> UIImage) -> AMLMapCompositeView
Parameters
image
The image to be displayed.
Return Value
An instance of
AMLMapCompositeView
. -
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 ) -> AMLMapCompositeView
Parameters
implementation
Closure provided a
MGLMapView
andMGLPointFeature
. Define your desired behavior on themapView
using information from thepointFeature
as needed.Return Value
An instance of
AMLMapCompositeView
. -
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 ) -> AMLMapCompositeView
Parameters
implementation
Closure provided a
MGLMapView
andMGLPointFeatureCluster
. Define your desired behavior on themapView
using information from thepointFeatureCluster
as needed.Return Value
An instance of
AMLMapCompositeView
. -
Set the position of the compass on the
MGLMapView
.Declaration
Swift
func compassPosition(_ position: MGLOrnamentPosition) -> AMLMapCompositeView
Parameters
position
MGLOrnamentPosition
defining the location.Return Value
An instance of
AMLMapCompositeView
. -
Set whether the map features should cluster.
Declaration
Swift
func shouldCluster(_ shouldCluster: Bool) -> AMLMapCompositeView
Parameters
shouldCluster
Features displayed on the map should cluster. Corresponds to the
MGLShapeSourceOption
.clustered
.Return Value
An instance of
AMLMapCompositeView
. -
Specifies the maximum zoom level at which to cluster points if clustering is enabled.
Declaration
Swift
func maximumClusterZoomLevel(_ maxZoom: Int) -> AMLMapCompositeView
Parameters
maxZoom
The maximum zoom level of clustering. Corresponds to
MGLShapeSourceOption
.maximumZoomLevelForClustering
.Return Value
An instance of
AMLMapCompositeView
. -
Set the fill color of the circle cluster.
Declaration
Swift
func clusterColor(_ color: UIColor) -> AMLMapCompositeView
Parameters
color
The fill color of the circle cluster. Sets the
MGLCircleStyleLayer
circleColor
property.Return Value
An instance of
AMLMapCompositeView
. -
The text color of the number displayed in the circle cluster.
Declaration
Swift
func clusterNumberColor(_ color: UIColor) -> AMLMapCompositeView
Parameters
color
The color of text displaying the number within a cluster. Sets the
MGLSymbolStyleLayer
textColor
property.Return Value
An instance of
AMLMapCompositeView
. -
Set colors for different cluster steps.
Declaration
Swift
func clusterColorSteps(_ steps: [Int : UIColor]) -> AMLMapCompositeView
Parameters
steps
Dictionary representation of cluster color steps where the
key
is the number of features in a cluster and thevalue
is the color for that corresponding numberReturn Value
An instance of
AMLMapCompositeView
. -
Set the radius of each cluster if clustering is enabled.
Declaration
Swift
func clusterRadius(_ radius: Int) -> AMLMapCompositeView
Parameters
radius
The cluster radius. Corresponds to the
MGLShapeSourceOption
.clusterRadius
.Return Value
An instance of
AMLMapCompositeView
.