https://github.com/lawrencebensaid/mapkit-swiftui
MapKit, but for SwiftUI!
https://github.com/lawrencebensaid/mapkit-swiftui
directions mapkit swift swiftui
Last synced: 6 months ago
JSON representation
MapKit, but for SwiftUI!
- Host: GitHub
- URL: https://github.com/lawrencebensaid/mapkit-swiftui
- Owner: lawrencebensaid
- Created: 2022-04-05T02:13:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-07T12:05:51.000Z (over 3 years ago)
- Last Synced: 2025-04-07T17:02:08.738Z (6 months ago)
- Topics: directions, mapkit, swift, swiftui
- Language: Swift
- Homepage:
- Size: 40 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MapKit-SwiftUI
MapKit, but with SwiftUI!
## Examples
**Example 1: Simple Map**
```swift
import MapKitSwiftUIstruct ContentView: View {
var body: some View {
AppleMap(lat: 42.336777, long: -71.097242)
.displayCompass()
.pointsOfInterest(include: [.school, .cafe, .park])
.zoomBoundry(500..<2500)
.ignoresSafeArea()
}
}
```Configuring your AppleMap is easy.
**Example 2: Markers**
```swift
let places: [Place] = [
Place("Coffee! ☕️", lat: 42.33562, long: -71.095651),
Place("Campus 🫡", lat: 42.336777, long: -71.097242)
]var body: some View {
AppleMap(lat: 42.336777, long: -71.097242, annotations: places) {
Marker(lat: $0.coordinate.latitude, long: $0.coordinate.longitude)
.title($0.name, subtitle: "Place of interest")
.color(.systemPurple)
.glyphImage(systemName: "building.fill")
}
.zoomBoundry(500..<2500)
.boundary(distance: 250)
}
```Easily add markers or pins to the map by using the `Marker` and `Pin` models
```swift
struct Place {let name: String
let lat: Double
let long: Double
init(_ name, lat: Double, long: Double) {
self.name = name
self.lat = lat
self.long = long
}
}
```*Place model I used in example 2 and 3*
**Example 3: Pins**
```swift
import MapKitSwiftUIstruct ContentView: View {
let places: [Place] = [
Place("Coffee! ☕️", lat: 42.33562, long: -71.095651),
Place("Campus 🫡", lat: 42.336777, long: -71.097242)
]var body: some View {
AppleMap(lat: 42.336777, long: -71.097242, annotations: places) {
Pin(lat: $0.coordinate.latitude, long: $0.coordinate.longitude)
.title($0.name)
.color(.systemBlue)
}
.zoomBoundry(500..<2500)
.boundary(distance: 250)
}
}
```Pins are very similar to Markers