Create MKPlacemark/CLPlacemark from human-readable string

156 Views Asked by At

Is there a way to create a MKPlacemark from a human-readable string, e.g. the placemark's own description?

placemark.description // -> "The Home Depot, 1675 Wilshire Blvd, Los Angeles, CA  90017, United States @ <+34.05726385,-118.27165514> +/- 0.00m, region CLCircularRegion (identifier:\'<+34.05726385,-118.27165514> radius 141.68\', center:<+34.05726385,-118.27165514>, radius:141.68m)"

I am aware of NSKeyedArchiver, but as far as I can tell its output is not readable.

1

There are 1 best solutions below

0
On

It turns out what I want is called forward-geocoding, and is supported by the CLGeocoder class.

let addressString = "123 Somewhere Pl"
CLGeocoder().geocodeAddressString(addressString) { placemark, _ in
    guard let placemark = placemark else { return }
    // use placemark...
}