[ad_1]
Good afternoon,
I attempted to get when up to date the brand new location to show it on display screen, however I do not know of easy methods to get location to make use of it exterior of the perform getCoordinate() to get currentLoc ?
import MapKit
import SwiftUI
var pace = Float(0)
var currentLoc = Float(0)
enum MapDetails{
static let startingLocation = CLLocationCoordinate2D(latitude: 76.2973451, longitude: 26.0744009)
static let defaultSpan = MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)
}
remaining class ContentViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
@Printed var area = MKCoordinateRegion(middle: MapDetails.startingLocation, span: MapDetails.defaultSpan)
var locationManager : CLLocationManager?
func getCoordinate(){
let currentLoc = locationManager?.location!.coordinate
print(currentLoc)
}
func getSpeed(_manager: CLLocationManager, didUpdateLocations areas: [CLLocation] ){
let location = areas[0]
pace = Float(location.pace)
print(location)
print(pace)
}
}
struct CoordinateView: View{
var physique: some View {
Textual content("Vitesse : " + String(pace))
Textual content("Place : " + String(currentLoc))
//Textual content(currentLoc)
}
}
[ad_2]
