Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🛰 Lightweight location positioning in Swift

License

NotificationsYou must be signed in to change notification settings

piemonte/Position

Repository files navigation

Position is a lightweight location positioning library for iOS.

Build StatusSwift Package ManagerPod VersionSwift VersionGitHub license

Features
“one shot” customizable location requests
🌌distance and time-based location filtering
🛰location tracking support
🧭device heading support
🔒permission check and response support
🌐geospatial math utilities
🏙place data formatting utilities
📊automatic low-battery location modes
📍vCard location creation
🔭multiple component observer-based architecture

Quick Start

Position is available for installation using theSwift Package Manager or the Cocoa dependency managerCocoaPods. Alternatively, you can simply copy thePosition source files into your Xcode project.

# CocoaPodspod"Position","~> 0.7.0"# Carthagegithub"piemonte/Position" ~>0.7.0# SwiftPMletpackage=Package(dependencies:[.Package(url:"https://github.com/piemonte/Position",majorVersion:0)])

Usage

The sample project provides an example of how to integratePosition, otherwise you can follow these steps.

Ensure your app’sInfo.plist file includes both a location usage description, required device capability “location-services”, and required background mode (if necessary).

See sample project for examples.

Import the file and setup your component to be a PositionObserver, if you’d like it to be a delegate.

import PositionclassViewController:UIViewController,PositionObserver{// ...

Have the component add itself as an observer and configure the appropriate settings.

overridefunc viewDidLoad(){        super.viewDidLoad()        // ...Position.shared.addObserver(self)Position.shared.distanceFilter=20ifPosition.shared.locationServicesStatus==.allowedWhenInUse ||Position.shared.locationServicesStatus==.allowedAlways{Position.shared.performOneShotLocationUpdate(withDesiredAccuracy:250){(location, error)->()inprint(location, error)}}else{            // request permissions based on the type of location support required.Position.shared.requestWhenInUseLocationAuthorization()            // Position.shared.requestAlwaysLocationAuthorization()}}

Observe delegation, if necessary.

func position(position:Position, didChangeLocationAuthorizationStatus status:LocationAuthorizationStatus){        // location authorization did change, often this may even be triggered on application resume if the user updated settings}

Remember when creating location-based apps, respect the privacy of your users and be responsible for how you use their location. This is especially true if your application requires location permissionkCLAuthorizationStatusAuthorizedAlways.

To share a location using a vCard, simply call the vCard function on any location object instance.

letfileURL= location.vCard()

Core Location Additions

Position is bundled with a variety ofadditions to Core Location, such as geospatial math utilities. For example, one can calculation the direction between two coordinate points enablingdirectional views and other waypoint representations.

Documentation

You can findthe docs here. Documentation is generated withjazzy and hosted onGitHub-Pages.

Community

Resources

License

Position is available under the MIT license, see theLICENSE file for more information.


[8]ページ先頭

©2009-2025 Movatter.jp