Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiliankoe/headingindicator
SwiftUI view that points towards a specific coordinate
https://github.com/kiliankoe/headingindicator
compass heading swift-package swiftui
Last synced: 3 months ago
JSON representation
SwiftUI view that points towards a specific coordinate
- Host: GitHub
- URL: https://github.com/kiliankoe/headingindicator
- Owner: kiliankoe
- Created: 2021-03-20T10:10:39.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-23T15:52:42.000Z (almost 2 years ago)
- Last Synced: 2024-09-16T14:46:34.615Z (4 months ago)
- Topics: compass, heading, swift-package, swiftui
- Language: Swift
- Homepage:
- Size: 5.86 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🧠Heading Indicator
A µPackage for displaying a SwiftUI view that automatically rotates to always point towards a specified coordinate. It's like a compass, only
that it points wherever you like.## Usage
You'll need an observed object that publishes location changes and current heading information, specifically you'll likely want to implement
the following in your `CLLocationManagerDelegate`:* `func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])`
* `func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading)`Then just create a new `HeadingIndicator` view, tell it where to point and set how it should display. Please make sure that the view
points up by default, otherwise it won't be rotated correctly.```swift
import HeadingIndicatorHeadingIndicator(
currentLocation: /* The device's current location. */,
currentHeading: /* The device's current heading. */,
targetLocation: /* The location to point to. */
) {
Image(systemName: "arrow.up.circle")
}
```