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
AMLMapViewdirectly.Declaration
Swift
public init(viewModel: AMLMapCompositeViewModel = .init())Parameters
viewModelThe
AMLMapCompositeViewModelthat is configured with aAMLMapViewStateobject. 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) -> AMLMapCompositeViewParameters
showLocationEnables 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>) -> AMLMapCompositeViewParameters
zoomLevelsA closed range of
Doublewhere 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) -> AMLMapCompositeViewParameters
maxZoomLevelThe 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) -> AMLMapCompositeViewParameters
minZoomLevelThe 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 underlyingMGLMapViewconsumesUIImages, this method turns aSwiftUIview 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 : ViewParameters
viewThe 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) -> AMLMapCompositeViewParameters
imageThe 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 ) -> AMLMapCompositeViewParameters
implementationClosure provided a
MGLMapViewandMGLPointFeature. Define your desired behavior on themapViewusing information from thepointFeatureas 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 ) -> AMLMapCompositeViewParameters
implementationClosure provided a
MGLMapViewandMGLPointFeatureCluster. Define your desired behavior on themapViewusing information from thepointFeatureClusteras needed.Return Value
An instance of
AMLMapCompositeView. -
Set the position of the compass on the
MGLMapView.Declaration
Swift
func compassPosition(_ position: MGLOrnamentPosition) -> AMLMapCompositeViewParameters
positionMGLOrnamentPositiondefining the location.Return Value
An instance of
AMLMapCompositeView. -
Set whether the map features should cluster.
Declaration
Swift
func shouldCluster(_ shouldCluster: Bool) -> AMLMapCompositeViewParameters
shouldClusterFeatures 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) -> AMLMapCompositeViewParameters
maxZoomThe 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) -> AMLMapCompositeViewParameters
colorThe fill color of the circle cluster. Sets the
MGLCircleStyleLayercircleColorproperty.Return Value
An instance of
AMLMapCompositeView. -
The text color of the number displayed in the circle cluster.
Declaration
Swift
func clusterNumberColor(_ color: UIColor) -> AMLMapCompositeViewParameters
colorThe color of text displaying the number within a cluster. Sets the
MGLSymbolStyleLayertextColorproperty.Return Value
An instance of
AMLMapCompositeView. -
Set colors for different cluster steps.
Declaration
Swift
func clusterColorSteps(_ steps: [Int : UIColor]) -> AMLMapCompositeViewParameters
stepsDictionary representation of cluster color steps where the
keyis the number of features in a cluster and thevalueis 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) -> AMLMapCompositeViewParameters
radiusThe cluster radius. Corresponds to the
MGLShapeSourceOption.clusterRadius.Return Value
An instance of
AMLMapCompositeView.
View on GitHub
AMLMapCompositeView Structure Reference