CLGeocoder
open class CLGeocoder : NSObject
An object that provides services for converting between a coordinate and user-friendly location information. Apple Documentation
-
A Boolean value indicating whether the geocoder is actively processing a request. Apple Documentation
Declaration
Swift
open var isGeocoding: Bool { get }
-
Creates a geocoder instance for converting between geographic coordinates and user-friendly location information.
Declaration
Swift
public override init()
Parameters
implementation
The geocoding implementation to use. Defaults to
OpenStreetMapGeocoder
. Apple Documentation
-
Initiates a forward geocoding request to convert an address into one or more locations.
Declaration
Swift
open func geocodeAddressString(_ addressString: String, completionHandler: @escaping CLGeocodeCompletionHandler)
Parameters
addressString
The address string to geocode.
completionHandler
A closure that receives an array of
CLPlacemark
objects or an error. Apple Documentation -
geocodeAddressString(_:
Asynchronous) Initiates an asynchronous forward geocoding request.
Declaration
Swift
open func geocodeAddressString(_ addressString: String) async throws -> [CLPlacemark]
Parameters
addressString
The address string to geocode.
Return Value
An array of
CLPlacemark
objects. Apple Documentation -
Initiates a forward geocoding request with a search region constraint.
Declaration
Swift
open func geocodeAddressString(_ addressString: String, in region: CLRegion?, completionHandler: @escaping CLGeocodeCompletionHandler)
Parameters
addressString
The address string to geocode.
region
The
CLRegion
within which to search.completionHandler
A closure that receives an array of
CLPlacemark
objects or an error. Apple Documentation -
geocodeAddressString(_:
Asynchronousin: ) Initiates an asynchronous forward geocoding request with a search region constraint.
Declaration
Swift
open func geocodeAddressString(_ addressString: String, in region: CLRegion?) async throws -> [CLPlacemark]
Parameters
addressString
The address string to geocode.
region
The
CLRegion
within which to search.Return Value
An array of
CLPlacemark
objects. Apple Documentation
-
Initiates a reverse geocoding request to convert a coordinate into user-friendly location information.
Declaration
Swift
open func reverseGeocodeLocation(_ location: CLLocation, completionHandler: @escaping CLGeocodeCompletionHandler)
Parameters
location
The
CLLocation
object containing the latitude and longitude.completionHandler
A closure that receives an array of
CLPlacemark
objects or an error. Apple Documentation -
reverseGeocodeLocation(_:
Asynchronous) Initiates an asynchronous reverse geocoding request.
Declaration
Swift
open func reverseGeocodeLocation(_ location: CLLocation) async throws -> [CLPlacemark]
Parameters
location
The
CLLocation
object containing the latitude and longitude.Return Value
An array of
CLPlacemark
objects. Apple Documentation
-
Cancels all pending geocoding requests. Apple Documentation
Declaration
Swift
open func cancelGeocode()
-
Initiates a geocoding request to convert a postal address into coordinates.
Declaration
Swift
open func geocodePostalAddress(_ postalAddress: CNPostalAddress, completionHandler: @escaping CLGeocodeCompletionHandler)
Parameters
postalAddress
The
CNPostalAddress
object containing address details.completionHandler
A closure that receives an array of
CLPlacemark
objects or an error. Apple Documentation -
geocodePostalAddress(_:
Asynchronous) Initiates an asynchronous geocoding request for a postal address.
Declaration
Swift
open func geocodePostalAddress(_ postalAddress: CNPostalAddress) async throws -> [CLPlacemark]
Parameters
postalAddress
The
CNPostalAddress
object containing address details.Return Value
An array of
CLPlacemark
objects. Apple Documentation