I am able to determine the latitude and longitude of a location in the center of a map with the following:
func TargetGridReference(outletMapView_PrimaryTargetLo
The first part of the accepted answer has a slight typo:
let latDegrees = abs(Int(lat))
will always produce positive latDegrees
and therefore the return portion
latDegrees >= 0 ? "N" : "S"
will always produce N
regardless of the input lat: Double
sign.
Just need change to
lat >= 0 ? "N" : "S")
as well as lon >= 0 ? "E" : "W")
to evaluate the input values` sign directly.