我的地址是字符串格式(不是纬度或经度),从字符串中删除zip,city或road名称是不可行的。
有没有可能用字符串打开地图? 字符串的格式如下: Fussballplatz Talgut,Grüzefeldstrasse,8400 Winterthur
我尝试了两个例子: 1)http://www.techotopia.com/index.php/An_Example_Swift_iOS_8_MKMapItem_Application 这有问题kABPersonAddressStreetKey在swift 2.0中未定义(这样认为)
2)How to open maps App programmatically with coordinates in swift? 在这里,我没有经度纬度。
答案 0 :(得分:1)
我认为你应该使用CLGeocoder
类。
这是来自apple docs的示例: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.
}
}];
答案 1 :(得分:0)