【发布时间】:2010-11-11 13:01:08
【问题描述】:
鉴于今天的 mapkit 不提供前向地理编码功能,任何人都可以提供有关我如何使用搜索栏从今天用户输入的地址返回纬度和经度坐标的帮助。如果有人可以提供示例代码,那就太好了。
【问题讨论】:
标签: iphone ios geolocation geocoding
鉴于今天的 mapkit 不提供前向地理编码功能,任何人都可以提供有关我如何使用搜索栏从今天用户输入的地址返回纬度和经度坐标的帮助。如果有人可以提供示例代码,那就太好了。
【问题讨论】:
标签: iphone ios geolocation geocoding
我在 github 上的 iOS5 CoreLocation 框架中使用 CLGeocoder 进行了一些正向和反向地理编码的小工作,希望对您有所帮助。 https://github.com/Mangesh20/geocoding
【讨论】:
我为 Google 的地理编码服务器创建了转发地理编码 API。看看我的博文: http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/
【讨论】:
【讨论】:
我创建了SVGeocoder,这是一个简单的 iOS 正向和反向地理编码器类。它也使用 Google Geocoding API 并返回 MKPlacemark。
这是您对地址字符串进行地理编码的方式:
NSString *addressString = @"3245 St-Denis, Montreal"
SVGeocoder *geocodeRequest = [[SVGeocoder alloc] initWithAddress:addressString];
[geocodeRequest setDelegate:self];
[geocodeRequest startAsynchronous];
然后你像这样对一个 CLLocationCoordinate2D 对象进行反向地理编码:
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(45.54181, -73.62928);
SVGeocoder *rGeocoderRequest = [[SVGeocoder alloc] initWithCoordinate:coordinate];
[rGeocoderRequest setDelegate:self];
[rGeocoderRequest startAsynchronous];
SVGeocoderDelegate 提供以下两种方法:
- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark;
- (void)geocoder:(SVGeocoder *)geocoder didFailWithError:(NSError *)error;
【讨论】:
这里还有一个框架:https://github.com/tylerhall/CoreGeoLocation
来自文档的评论: Objective GeoCoder 和 Reverse Geocoder 主要围绕 Yahoo 的 Geocoding 服务或 Google 的 Geo API。
【讨论】:
这是当前版本的 MapKit 的一个已知问题。提交错误报告并欺骗 #6628720,以便他们优先修复它。
同时,有来自Google Maps、Yahoo Placemaker 或Cloudmade 的转发地理编码 API。
【讨论】:
MapKit 中没有这样的功能。您能做的最好的事情就是调用第三方网络服务。谷歌有一些 API 可以做到这一点,我认为雅虎也有。两者都有商业用途的限制,所以请阅读协议。
【讨论】: