lukepistrol/lpmapview
> 📖 See the full documentation [here](https://lukepistrol.github.io/LPMapView/documentation/lpmapview).
Overview
This offers a couple more features compared to SwiftUI.Map.
Usage (iOS 16)
@State private var coordinateRegion: MKCoordinateRegion = ...
@State private var items: [MapViewAnnotation] = ...
MapView(
region: $coordinateRegion,
showsUserLocation: false,
userTrackingMode: .none,
annotations: $items
)
.mapDisplayRoute() // connect annotations with lines
.mapRouteStyle(.dashed(5, tint: .red) // Use a dashed line
.mapAnnotations(.visible, tint: .mint) // show annotations with custom tint
.mapConfiguration(.hybrid) // use the hybrid map styleThe above example usage would deliver a map view similar to this one:
[map-preview]
Usage (iOS 14 & 15)
@State private var coordinateRegion: MKCoordinateRegion = ...
@State private var items: [MapViewAnnotation] = ...
LMapView(
region: $coordinateRegion,
showsUserLocation: false,
userTrackingMode: .none,
annotations: $items
)
.mapDisplayRoute() // connect annotations with lines
.mapRouteStyle(.dashed(5, tint: .red) // Use a dashed line
.mapAnnotations(.visible, tint: .mint) // show annotations with custom tint
.mapConfiguration(.hybrid) // use the hybrid map styleModifiers
There are a couple of modifiers available for configuring additional options for the map view.
mapDisplayRoute
Declaration
func mapDisplayRoute(
_ visibility: MapViewVisibility = .visible
) -> some ViewParameters
visibility: Whether or not the route will be visible.
mapRouteStyle
Declaration
func mapRouteStyle(_ style: MapRouteStyle) -> some ViewParameters
style: The route line style to use.
mapAnnotations
Declaration
func mapAnnotations(
_ visibility: MapViewVisibility = .visible,
tint: Color = .red,
calloutEnabled: Bool = false,
fitInVisibleRect: Bool = false,
animated: Bool = true
) -> some ViewParameters
visibility: Whether or not annotations will be visible.tint: The default tint color of the annotation. This can
be overridden by setting `MapViewAnnotation/tint on MapViewAnnotation`.
calloutEnabled: Whether or not to show a detail callout
when an annotation is selected. Note that this will only work if the annotation has a title.
fitInVisibleRect: Whether or not to automatically adjust
map zoom to fit all annotations.
animated: Whether or not to animate changes.
mapConfiguration
Declaration
func mapConfiguration(
_ configuration: MapViewConfiguration,
elevationStyle: MKMapConfiguration.ElevationStyle = .flat, // iOS 16 only
poiFilter: MKPointOfInterestFilter = .includingAll,
selectableFeatures: MKMapFeatureOptions = [] // iOS 16 only
) -> some ViewParameters
configuration: A configuration option defining the map
style.
elevationStyle: Defines how elevation data is handled
when rendering the map view.
poiFilter: A filter that includes or excludes point of
interest categories from a map view, local search, or local search completer.
selectableFeatures: Describes which selectable features
the map responds to.
mapUserInteraction
Declaration
func mapUserInteraction(
zoom: Bool = true,
scroll: Bool = true,
pitch: Bool = true,
rotate: Bool = true
) -> some ViewParameters
zoom: A Boolean value that determines whether the user may
use pinch gestures to zoom in and out of the map.
scroll: A Boolean value that determines whether the user
may scroll around the map.
pitch: A Boolean value that indicates whether the map uses
the camera’s pitch information.
rotate: A Boolean value that indicates whether the map uses
the camera’s heading information.
<a href="https://www.buymeacoffee.com/lukeeep" target="_blank"> <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" > </a>
Package Metadata
Repository: lukepistrol/lpmapview
Default branch: main
README: README.md