【问题标题】:Open iOS map with string address in Swift 2.0在 Swift 2.0 中打开带有字符串地址的 iOS 地图
【发布时间】:2016-01-05 18:08:20
【问题描述】:
【问题讨论】:
标签:
ios
dictionary
swift2
apple-maps
【解决方案1】:
我认为你应该使用CLGeocoder 类。
这是来自苹果文档的示例:https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html:
/*
Use the CLGeocoder class with a dictionary of Address Book
information or a simple string to initiate forward-geocoding
requests. There is no designated format for string-based
requests: Delimiter characters are welcome, but not required,
and the geocoder server treats the string as case-insensitive.
For example, any of the following strings would yield results:
"Apple Inc”
"1 Infinite Loop”
"1 Infinite Loop, Cupertino, CA USA”
*/
[geocoder geocodeAddressString:@"1 Infinite Loop"
completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks)
{
// Process the placemark.
}
}];