You should either declare from and to in:
an init() - just declare type in the general declaration and set value in init
in .onAppear as a modifier of the VStack
But there are many errors in the code that you have to correct first:
you call distance in the distance func. That will cause infinite loop
return from.distance(from: to)
You need to set values of parameters,
let distanceFrom = from.distance(from: to)
such as
let distanceFrom = from.distance(from: from, to: to)
from is a CLLocationCoordinate2D
But distance is defined for CLLocation only…
Topic:
App & System Services
SubTopic:
Maps & Location
Tags: