Как контролировать поворот за поворотом - PullRequest
0 голосов
/ 11 октября 2019

Как отслеживать регионы во время путешествия по маршруту / пути, я использую приведенный ниже код, чтобы идентифицировать регионы и показывать инструкцию маршрута / пути, но это не работает точно, и это дает сбой, если регион больше 20

func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
    print("ENTERED")
    stepCounter += 1
    if stepCounter < steps.count {
        let currentStep = steps[stepCounter]
        print(currentStep.polyline.coordinate)
        let message = "In \(currentStep.distance) meters, \(currentStep.instructions)"
        directionsLabel.text = message
        self.setImageAccordingToDirection(instruction: message)
        let speechUtterance = AVSpeechUtterance(string: message)
        speechSynthesizer.speak(speechUtterance)
    } else {
        let message = "Arrived at destination"
        directionsLabel.text = message
        btnStart.tag = 2
        let speechUtterance = AVSpeechUtterance(string: message)
        speechSynthesizer.speak(speechUtterance)
        stepCounter = 0
        locationManager.monitoredRegions.forEach({ self.locationManager.stopMonitoring(for: $0) })
    }
}
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
    print("exit")
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...