How can I plot addresses in Swift, converting address to longitude and latitude coordinates?
- 阅读更多 关于 How can I plot addresses in Swift, converting address to longitude and latitude coordinates?
In Objective-C this code works fine to plot an address and it finds the longitude and latitude coordinates: NSString *address = @"1 Infinite Loop, CA, USA"; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:address completionHandler:^(NSArray* placemarks, NSError* error){ // Check for returned placemarks if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; // Create a MLPlacemark and add it to the map view MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult]; [self.mapView addAnnotation:placemark];