从iPhone转发地理编码

14 iphone geocoding geolocation ios

鉴于mapkit今天没有提供前向地理编码功能,任何人都可以提供帮助,告诉我今天如何使用搜索栏从用户输入的地址返回纬度和经度坐标.如果有人可以提供非常棒的示例代码.

sye*_*dfa 32

iOS 5现在允许转发地理编码:

http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html#//apple_ref/doc/uid/TP40009497-CH4-SW5

我希望这有帮助!

  • 使用iOS6,这可能是唯一可用的解决方案(除了雅虎之外),因为我怀疑谷歌会对你在Apple地图上覆盖谷歌地理编码数据表示满意...... (2认同)

Mer*_*ack 26

我为Google的地理编码服务器创建了一个前向地理编码API.看看我的博文:http: //blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/


sam*_*tte 15

我创建了SVGeocoder,一个简单的iOS 前向反向地理编码器类.它也使用Google Geocoding API并返回MKPlacemark.

这是您对地址字符串进行地理编码的方式:

NSString *addressString = @"3245 St-Denis, Montreal"
SVGeocoder *geocodeRequest = [[SVGeocoder alloc] initWithAddress:addressString];
[geocodeRequest setDelegate:self];
[geocodeRequest startAsynchronous];
Run Code Online (Sandbox Code Playgroud)

你反向地址编码CLLocationCoordinate2D对象,如下所示:

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(45.54181, -73.62928);
SVGeocoder *rGeocoderRequest = [[SVGeocoder alloc] initWithCoordinate:coordinate];
[rGeocoderRequest setDelegate:self];
[rGeocoderRequest startAsynchronous];
Run Code Online (Sandbox Code Playgroud)

SVGeocoderDelegate提供以下两种方法:

- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark;
- (void)geocoder:(SVGeocoder *)geocoder didFailWithError:(NSError *)error;
Run Code Online (Sandbox Code Playgroud)

  • 现在对iOS开发人员来说完全无用:来自Google TOS:"注意:Geocoding API可能只能与Google地图一起使用"https://developers.google.com/maps/documentation/geocoding/#Limits (4认同)

Ste*_*ntz 1

MapKit 中没有这样的功能。您能做的最好的事情就是调用第三方网络服务。谷歌有一些 API 可以做到这一点,我认为雅虎也有。不过,两者都对商业用途有限制,因此请阅读协议。