Skip to content

Instantly share code, notes, and snippets.

View ryanisnhp's full-sized avatar

RyanisNHP ryanisnhp

View GitHub Profile
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
let accuracyAuthorization = manager.accuracyAuthorization
switch accuracyAuthorization {
case .fullAccuracy:
break
case .reducedAccuracy:
manager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: "ForDelivery")
break
default:
break
<dict>
<key>ForDelivery</key>
<string>Help your driver delivery items on time</string>
<key>BackupKey</key>
<string>Use BackupKey to get this explanation</string>
</dict>
func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String)
func requestTemporaryFullAccuracyAuthorization(withPurposeKey purposeKey: String, completion: ((Error?) -> Void)? = nil)
<key>NSLocationDefaultAccuracyReduced</key>
<false/>
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
let accuracyAuthorization = manager.accuracyAuthorization
switch accuracyAuthorization {
case .fullAccuracy:
break
case .reducedAccuracy:
break
default:
break
}
@objc func animatePolylineDashAnimation() {
//Iterate each valid coordinate on the path
if i < path.count() {
newPath.add(path.coordinate(at: i))
newPolyline.path = newPath
newPolyline.strokeWidth = 4
let dashLength = calculateDashLength(zoomLevel: mapView.camera.zoom)
let clearDashLength = Int(Double(dashLength) * 0.5)
let lengths = [dashLength, clearDashLength] // Play with this for dotted line
@objc func animatePolylineWithGradient() {
//Iterate each valid coordinate on the path
if i < path.count() {
newPath.add(path.coordinate(at: i))
newPolyline.path = newPath
newPolyline.strokeWidth = 4
newPolyline.spans = [GMSStyleSpan(style: .gradient(from: UIColor(rgb: 0x38726E), to: UIColor(rgb: 0x404969)))]
newPolyline.map = mapView
i += 1
} else {
//STEP 3: - ANIMATIONS
@objc func animatePolylinePath() {
//Iterate each valid coordinate on the path
if i < path.count() {
newPath.add(path.coordinate(at: i))
newPolyline.path = newPath
newPolyline.strokeColor = UIColor.black
newPolyline.strokeWidth = 4
newPolyline.map = mapView
i += 1
//STEP 2: - DRAW A ROUTE ON THE MAP
func drawRouteOnMap(route: String?) {
guard let route = route else {return}
guard let path = GMSPath(fromEncodedPath: route) else {return}
self.path = path
let polyline = GMSPolyline(path: path)
polyline.strokeColor = .gray
polyline.strokeWidth = 2
polyline.map = mapView